Skip to content

Mask secrets in build logs#269

Draft
pellared wants to merge 1 commit into
mainfrom
mask-secrets-in-logs-17683059294211091784
Draft

Mask secrets in build logs#269
pellared wants to merge 1 commit into
mainfrom
mask-secrets-in-logs-17683059294211091784

Conversation

@pellared
Copy link
Copy Markdown
Member

This PR introduces a security enhancement to prevent secret leakage in build logs.

Key changes:

  • Added cmd.Mask function in cmd/mask.go to sanitize command-line strings by masking leading environment variable assignments.
  • Updated runExec in build/helper.go to use cmd.Mask when logging commands.
  • Added unit tests for cmd.Mask in cmd/mask_test.go.
  • Added an integration/security test in build/security_test.go to ensure runExec correctly masks secrets in practice.
  • Updated go.mod and go.sum to include the github.com/mattn/go-shellwords dependency (which was already used but not explicitly listed in the root go.mod in a way that satisfied all modules).

The core masking logic uses github.com/mattn/go-shellwords for robust shell-like parsing, ensuring that quoted values and complex command lines are handled correctly. Actual command execution remains unaffected as the unmasked command line is still passed to cmd.Exec.


PR created automatically by Jules for task 17683059294211091784 started by @pellared

The \`runExec\` helper in \`build/helper.go\` now masks the values of leading
environment variable assignments (e.g., \`KEY=VALUE\`) with \`[MASKED]\` in its
log output. This prevents sensitive data like tokens or passwords from
leaking into build or CI/CD logs while still logging the base command.

A new \`cmd.Mask\` function has been added to the \`cmd\` package to support
this functionality, along with comprehensive unit and regression tests.
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant