Skip to content

Commit

Permalink
Avoid logging ES credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
inqueue committed Jun 27, 2024
1 parent 18e4a2c commit 095509d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion esrally/utils/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import logging
import os
import re
import shlex
import subprocess
import time
Expand Down Expand Up @@ -181,7 +182,13 @@ def find_all_other_rally_processes() -> List[psutil.Process]:

def kill_all(predicate: Callable[[psutil.Process], bool]) -> None:
def kill(p: psutil.Process):
logging.getLogger(__name__).info("Killing lingering process with PID [%s] and command line [%s].", p.pid, p.cmdline())
# Do not leak Elasticsearch authentication credentials to the log
p_cmdline = p.cmdline()
for i, s in enumerate(p_cmdline):
if "--client-options" in s:
p_cmdline[i] = re.sub(r"basic_auth_password:'.+'", "basic_auth_password:'*****'", s)
p_cmdline[i] = re.sub(r"api_key:'.+'", "api_key:'*****'", s)
logging.getLogger(__name__).info("Killing lingering process with PID [%s] and command line [%s].", p.pid, p_cmdline)
p.kill()
# wait until process has terminated, at most 3 seconds. Otherwise we might run into race conditions with actor system
# sockets that are still open.
Expand Down

0 comments on commit 095509d

Please sign in to comment.