Mask secrets in build logs#269
Conversation
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.
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
This PR introduces a security enhancement to prevent secret leakage in build logs.
Key changes:
cmd.Maskfunction incmd/mask.goto sanitize command-line strings by masking leading environment variable assignments.runExecinbuild/helper.goto usecmd.Maskwhen logging commands.cmd.Maskincmd/mask_test.go.build/security_test.goto ensurerunExeccorrectly masks secrets in practice.go.modandgo.sumto include thegithub.com/mattn/go-shellwordsdependency (which was already used but not explicitly listed in the rootgo.modin a way that satisfied all modules).The core masking logic uses
github.com/mattn/go-shellwordsfor 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 tocmd.Exec.PR created automatically by Jules for task 17683059294211091784 started by @pellared