Skip to content

Harden command redaction for spawn failures - #56

Merged
errfld merged 3 commits into
mainfrom
codex/gh-47/harden-command-redaction
Feb 15, 2026
Merged

Harden command redaction for spawn failures#56
errfld merged 3 commits into
mainfrom
codex/gh-47/harden-command-redaction

Conversation

@errfld

@errfld errfld commented Feb 9, 2026

Copy link
Copy Markdown
Owner

Closes #47

Summary

  • replace whitespace splitting with quote-aware command tokenization for redaction
  • tighten inline env-assignment detection to valid shell variable names (KEY=value)
  • keep executable identification stable for common shell patterns and redact remaining args
  • add unit coverage for quoted env assignments, long commands, and non-env commands
  • add concise learning note in AGENTS.md

Testing

  • cargo test -p git-smee-core executor::tests

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced command redaction to reliably detect and redact inline environment variables with quoted values and spaces, ensuring sensitive credentials remain properly hidden in command logs.
  • Documentation

    • Added guidelines for secure command handling using quote-aware tokenization and strict environment variable detection.

@coderabbitai

coderabbitai Bot commented Feb 9, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@errfld has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 32 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

This PR hardens command redaction in the executor by introducing quote-aware tokenization and environment variable name validation. It replaces simple whitespace splitting with a robust pipeline to prevent inline environment assignment values—including quoted values with spaces—from leaking in spawn error messages.

Changes

Cohort / File(s) Summary
Documentation
AGENTS.md
Adds learning guideline on command redaction emphasizing quote-aware tokenization and strict KEY=value detection for env secret masking.
Command Redaction & Tokenization
crates/git-smee-core/src/executor.rs
Introduces tokenize_command() for shell-aware token parsing (respecting quotes and escapes) and is_valid_env_var_name() for env-var validation. Reworks redaction logic to identify the executable via tokenization rather than naive whitespace splitting. Improves inline-env detection using split_once() and name validation. Expands test coverage for quoted env assignments, commands without env prefixes, and truncation behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 With tokenized care and quotes now aware,
No secrets leak out from the spawn-error snare!
The rabbit hops through each shell-parsed line,
Keeping KEY="value" secrets just fine.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Harden command redaction for spawn failures' directly and clearly summarizes the main change in the PR, which focuses on hardening the command redaction logic used in spawn error messages.
Linked Issues check ✅ Passed All acceptance criteria from issue #47 are met: redaction does not leak inline env assignment values, correctly identifies executables with quotes and env vars, and unit tests cover quoted env assignments, long commands, and non-env commands.
Out of Scope Changes check ✅ Passed All changes are directly related to the hardened command redaction objective: the executor.rs file implements the quote-aware tokenizer and improved env detection, while AGENTS.md adds a learning note explaining the redaction approach.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/gh-47/harden-command-redaction

Comment @coderabbitai help to get the list of available commands and usage tips.

@errfld
errfld enabled auto-merge (squash) February 15, 2026 14:07
@errfld
errfld merged commit d70c65b into main Feb 15, 2026
15 checks passed
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.

Harden command redaction for spawn failures

1 participant