Mask credentials in plugin tool logging#579
Open
bschwedler wants to merge 1 commit into
Open
Conversation
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.
ianpittwood
requested changes
Jun 16, 2026
ianpittwood
left a comment
Contributor
There was a problem hiding this comment.
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: |
Contributor
There was a problem hiding this comment.
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Secret values (wizcli client secret, GH_TOKEN) were appearing unredacted in process listings, log output, and error metadata.