Skip to content

Mask credentials in plugin tool logging#579

Open
bschwedler wants to merge 1 commit into
mainfrom
credential-handling
Open

Mask credentials in plugin tool logging#579
bschwedler wants to merge 1 commit into
mainfrom
credential-handling

Conversation

@bschwedler

Copy link
Copy Markdown
Contributor

Secret values (wizcli client secret, GH_TOKEN) were appearing unredacted in process listings, log output, and error metadata.

Add SensitiveArg to util.py to wrap secrets passed as CLI flags so
they render as *** in logs and error output while preserving the real
value for subprocess execution. Add display_command() and exec_args()
as helpers to use alongside it.

Apply throughout the plugin layer:

- wizcli: wrap client_secret in SensitiveArg; use exec_args() when
  invoking subprocess so the real value is passed to the process
- dgoss: move GH_TOKEN forwarding from image_environment (where the
  value was embedded as -e GH_TOKEN=VALUE in the command line) to
  dgoss_environment (subprocess env), passed via -e GH_TOKEN
  (name-only) so the value never appears in logs or error metadata.
  Add redacted_dgoss_environment for safe logging. Add
  container_passthrough_env_vars for the name-only -e entries.
- hadolint, oras: use display_command() for log output

Update error __str__ methods to call str(x) per item so SensitiveArg
values in cmd lists render as *** rather than raising TypeError.
@bschwedler bschwedler requested a review from ianpittwood as a code owner June 9, 2026 18:22
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

Test Results

1 652 tests  +18   1 652 ✅ +18   8m 35s ⏱️ +32s
    1 suites ± 0       0 💤 ± 0 
    1 files   ± 0       0 ❌ ± 0 

Results for commit 137bdca. ± Comparison against base commit 6bc441c.

@ianpittwood ianpittwood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to make a display_command function for each plugin's command model or create a wider spanning ShellCommand class with methods for to_shell() and to_display().

I do think we should globally mask GH_TOKEN and GITHUB_TOKEN by default regardless of whether its used or defined for an image.

The current implementation seems to accomplish what we're going for. I only think we could do it a bit cleaner.

from posit_bakery.error import BakeryToolNotFoundError


class SensitiveArg:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels excessive for something we only use once. I'm wondering if we could do per-plugin inline replacements or a smaller wrapper function that either replaces the value with *s or an output like (hidden, X characters).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants