Skip to content

Commit

Permalink
fix: Logging sensitive data
Browse files Browse the repository at this point in the history
Don't log sensitive data.

Since /var/log/cloud-init.log is a priviledged file, this does not expose a
secure system (no CVE). However, we don't want to log this information so that
users can file reports without having to manually redact logs.

Standardize log messages so that redacted and non-redacted logs match.
  • Loading branch information
holmanb authored and blackboxsw committed Apr 4, 2024
1 parent 4a134bf commit 2f9812e
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions cloudinit/subp.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,14 @@ def subp(
if update_env:
env.update(update_env)

if not logstring:
LOG.debug(
"Running command %s with allowed return codes %s"
" (shell=%s, capture=%s)",
args,
rcs,
shell,
capture,
)
else:
LOG.debug(
"Running hidden command to protect sensitive "
"input/output logstring: %s",
logstring,
)
LOG.debug(
"Running command %s with allowed return codes %s"
" (shell=%s, capture=%s)",
logstring if logstring else args,
rcs,
shell,
capture,
)

stdin: Union[TextIOWrapper, int]
stdout = None
Expand Down Expand Up @@ -276,7 +269,11 @@ def subp(
out, err = sp.communicate(data, timeout=timeout)
total = time.time() - before
if total > 0.1:
LOG.debug("command %s took %.3ss to run", args, total)
LOG.debug(
"%s took %.3ss to run",
logstring if logstring else args,
total,
)
except OSError as e:
raise ProcessExecutionError(
cmd=args,
Expand Down

0 comments on commit 2f9812e

Please sign in to comment.