Skip to content

Redact container env vars in logs#192

Merged
pjbgf merged 1 commit into
mainfrom
log
Jul 23, 2026
Merged

Redact container env vars in logs#192
pjbgf merged 1 commit into
mainfrom
log

Conversation

@pjbgf

@pjbgf pjbgf commented Jul 23, 2026

Copy link
Copy Markdown
Member

No description provided.

Entire-Checkpoint: 01KY7V1VPA7BTC8YG9XWSA4DC4
Copilot AI review requested due to automatic review settings July 23, 2026 16:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a small utility to redact explicit -e/--env values from container runner argument lists before they’re written to debug logs, reducing the chance of leaking secrets in log output.

Changes:

  • Introduces container.RedactEnvArgs to copy and redact env flag values in an args slice.
  • Adds unit tests covering separate and inline -e/--env forms plus non-env args.
  • Updates Docker/Podman runner and profile container exec debug logging to use the redacted args.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
internal/runners/util/container/redact.go Adds the argument redaction helper used for safe logging.
internal/runners/util/container/redact_test.go Adds tests to validate redaction behavior and non-mutation of input args.
internal/runners/podman/run.go Logs redacted args instead of raw args for Podman execution.
internal/runners/docker/run.go Logs redacted args instead of raw args for Docker execution.
internal/profiles/profiles.go Logs redacted args instead of raw args when starting the profile container.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +32
func RedactEnvArgs(args []string) []string {
redacted := append([]string(nil), args...)

for i := 0; i < len(redacted); i++ {
switch redacted[i] {
case "-e", "--env":
if i+1 < len(redacted) {
redacted[i+1] = redactEnvSpec(redacted[i+1])
i++
}
default:
for _, prefix := range []string{"-e=", "--env="} {
if spec, ok := strings.CutPrefix(redacted[i], prefix); ok {
redacted[i] = prefix + redactEnvSpec(spec)
break
}
}
}
}

return redacted
}
@pjbgf
pjbgf merged commit 43b5fcf into main Jul 23, 2026
6 checks passed
@pjbgf
pjbgf deleted the log branch July 23, 2026 18:24
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