Repository navigation
security(agent): make advisory command argv round-trip through Bash (#2347) - #2433
EffortlessSteven wants to merge 11 commits into
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
There was a problem hiding this comment.
Sorry @EffortlessSteven, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Summary by CodeRabbit
WalkthroughAdvisory command generation now uses Bash-safe single-quoted argument rendering. Command builders, tests, fixtures, process policy, and changelog entries were updated to reflect this behavior and validate hostile inputs and redirect-shaped gap IDs. ChangesAdvisory command quoting
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CommandBuilder
participant shell_arg
participant Bash
CommandBuilder->>shell_arg: encode interpolated argument
shell_arg-->>CommandBuilder: single-quoted token
CommandBuilder->>Bash: emit advisory command
Bash-->>CommandBuilder: preserve argv and redirect target
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 9
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/patches/2347-expectations.py:
- Around line 111-114: Update the migration validation around json_changes and
markdown_changes so an already-migrated corpus is treated as success and reruns
remain idempotent. Do not fail merely because either change counter is zero;
instead verify that no targeted double-quoted commands remain after the
migration, preserving success when the tree is already clean and avoiding
partial-migration failures.
In @.github/patches/2347.py:
- Around line 1-11: Allowlist both .github/patches/2347.py and
.github/patches/2347-expectations.py in policy/non_rust_allowlist.txt and
document the exception rationale in the PR description. In
.github/workflows/validate-2347-bash-argv.yml, move removal of the patch and
workflow files until after cargo xtask check-file-policy and
check-static-language run, so the checks inspect them.
- Around line 65-67: Update the insertion-point logic in the patch script to
target the `#[cfg(test)]` module reliably instead of using the final
newline-brace match. Anchor on a stable test-module marker or the known last
test function and, if needed, use matched-brace scanning so added tests remain
inside the test module regardless of trailing content or newline formatting.
- Around line 139-148: The temporary proof directory created in the
redirect-proof flow leaks when assertions return errors. Refactor the logic
after `create_dir_all` so its result is captured, execute
`std::fs::remove_dir_all(&root)` unconditionally after the checks, then return
the captured result while preserving existing assertion errors and cleanup
errors as appropriate.
- Around line 149-168: Update the redirect-confinement assertion in the test
around shell_arg and result.txt to check for the actual unquoted-redirection
artifact, “=threshold”, rather than “threshold”. Ensure the test fails if that
leaked file is created, and preferably verify the temporary directory contains
only the expected result.txt.
In @.github/workflows/validate-2347-bash-argv.yml:
- Around line 129-132: Add a one-line comment immediately above the permissions
block documenting that contents: write is narrowly required to push the
validated tree. Keep the existing permission scope and workflow behavior
unchanged.
- Around line 25-30: Update both checkout steps in the validation and commit
jobs to use github.event.pull_request.head.sha as the checkout ref, ensuring
both jobs operate on the asserted pull-request commit. Preserve the existing
branch-name assertion for the push target and the current checkout options,
including fetch-depth and credential handling.
- Line 147: Update the actions/download-artifact step in the commit job to
reference a reviewed full commit SHA instead of the mutable v8 tag, matching the
pinning format used by the other actions in the workflow.
- Around line 40-50: Update the fetch block in the workflow to fetch the
reviewed commit SHA instead of the mutable codex/shell-arg-escaping-2347 branch,
and validate that FETCH_HEAD exactly matches the expected SHA before importing
files with git show. Fail the job on any mismatch.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c14db329-bda9-4317-8606-75ae0705e795
📒 Files selected for processing (3)
.github/patches/2347-expectations.py.github/patches/2347.py.github/workflows/validate-2347-bash-argv.yml
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
EffortlessMetrics/ripr(auto-detected)EffortlessMetrics/em-ci(auto-detected)EffortlessMetrics/perl-lsp(auto-detected)EffortlessMetrics/unsafe-review(auto-detected)EffortlessMetrics/ub-review(auto-detected)
| if json_changes == 0 or markdown_changes == 0: | ||
| raise SystemExit( | ||
| "first-PR receipt corpus migration found no remaining JSON or Markdown double-quoted commands" | ||
| ) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Guard makes the script non-idempotent.
Once the remaining corpus is migrated, a rerun (or a rerun after a partially-applied first pass) exits non-zero even though the tree is already correct. Also, a single counter reaching zero aborts after the other file class was already written, leaving a half-migrated tree. Consider treating "already migrated" as success, or verifying absence of double-quoted commands instead of requiring a positive change count.
🧰 Tools
🪛 Ruff (0.15.21)
[warning] 112-114: Avoid specifying long messages outside the exception class
(TRY003)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/patches/2347-expectations.py around lines 111 - 114, Update the
migration validation around json_changes and markdown_changes so an
already-migrated corpus is treated as success and reruns remain idempotent. Do
not fail merely because either change counter is zero; instead verify that no
targeted double-quoted commands remain after the migration, preserving success
when the tree is already clean and avoiding partial-migration failures.
| module_end = text.rfind("\n}") | ||
| if module_end < 0: | ||
| raise SystemExit("loop_commands test module end not found") |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
rfind("\n}") anchors the insertion at the last top-level brace, not necessarily the test module.
If loop_commands.rs ever gains trailing content after the #[cfg(test)] module (or the file ends without a trailing newline before }), the tests land in the wrong scope and only fail at compile time. Anchor on a stable marker instead, e.g. the known last test function name or mod tests { plus a matched-brace scan.
🧰 Tools
🪛 Ruff (0.15.21)
[warning] 67-67: Avoid specifying long messages outside the exception class
(TRY003)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/patches/2347.py around lines 65 - 67, Update the insertion-point
logic in the patch script to target the `#[cfg(test)]` module reliably instead
of using the final newline-brace match. Anchor on a stable test-module marker or
the known last test function and, if needed, use matched-brace scanning so added
tests remain inside the test module regardless of trailing content or newline
formatting.
| let stamp = std::time::SystemTime::now() | ||
| .duration_since(std::time::UNIX_EPOCH) | ||
| .map_err(|err| format!("system clock before UNIX_EPOCH: {err}"))? | ||
| .as_nanos(); | ||
| let root = std::env::temp_dir().join(format!( | ||
| "ripr-shell-arg-redirect-{}-{stamp}", | ||
| std::process::id() | ||
| )); | ||
| std::fs::create_dir_all(&root) | ||
| .map_err(|err| format!("create redirect proof root failed: {err}"))?; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🔵 Trivial | 💤 Low value
Temp proof directory leaks when an assertion fails.
Every early return Err(...) between lines 151 and 168 skips the remove_dir_all on line 169. Not fatal for CI, but repeated local failures accumulate directories under temp_dir(). Capture the result and clean up unconditionally before returning.
Also applies to: 169-172
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/patches/2347.py around lines 139 - 148, The temporary proof
directory created in the redirect-proof flow leaks when assertions return
errors. Refactor the logic after `create_dir_all` so its result is captured,
execute `std::fs::remove_dir_all(&root)` unconditionally after the checks, then
return the captured result while preserving existing assertion errors and
cleanup errors as appropriate.
| let value = "gap:pr:amount>=threshold"; | ||
| let script = format!("printf '%s' {} > result.txt", shell_arg(value)); | ||
| let output = run_bash(&script, Some(&root))?; | ||
| if !output.status.success() { | ||
| return Err(format!( | ||
| "Bash rejected redirect proof: {}", | ||
| String::from_utf8_lossy(&output.stderr) | ||
| )); | ||
| } | ||
| let actual = std::fs::read(root.join("result.txt")) | ||
| .map_err(|err| format!("read redirect proof result failed: {err}"))?; | ||
| if actual != value.as_bytes() { | ||
| return Err(format!( | ||
| "redirect proof changed the gap id: {:?}", | ||
| String::from_utf8_lossy(&actual) | ||
| )); | ||
| } | ||
| if root.join("threshold").exists() { | ||
| return Err("redirect-shaped gap id created an unintended `threshold` file".to_string()); | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Redirect-confinement assertion checks the wrong filename, so it cannot detect a regression.
With gap:pr:amount>=threshold rendered unquoted, Bash splits at > and redirects into =threshold, not threshold. The guard on line 166 would therefore stay green even if shell_arg regressed to leaving > unquoted. Assert on the actual leaked name (and ideally that the directory contains only result.txt).
🐛 Proposed fix
- if root.join("threshold").exists() {
- return Err("redirect-shaped gap id created an unintended `threshold` file".to_string());
+ if root.join("=threshold").exists() {
+ return Err(
+ "redirect-shaped gap id opened a second redirect into `=threshold`".to_string(),
+ );
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let value = "gap:pr:amount>=threshold"; | |
| let script = format!("printf '%s' {} > result.txt", shell_arg(value)); | |
| let output = run_bash(&script, Some(&root))?; | |
| if !output.status.success() { | |
| return Err(format!( | |
| "Bash rejected redirect proof: {}", | |
| String::from_utf8_lossy(&output.stderr) | |
| )); | |
| } | |
| let actual = std::fs::read(root.join("result.txt")) | |
| .map_err(|err| format!("read redirect proof result failed: {err}"))?; | |
| if actual != value.as_bytes() { | |
| return Err(format!( | |
| "redirect proof changed the gap id: {:?}", | |
| String::from_utf8_lossy(&actual) | |
| )); | |
| } | |
| if root.join("threshold").exists() { | |
| return Err("redirect-shaped gap id created an unintended `threshold` file".to_string()); | |
| } | |
| let value = "gap:pr:amount>=threshold"; | |
| let script = format!("printf '%s' {} > result.txt", shell_arg(value)); | |
| let output = run_bash(&script, Some(&root))?; | |
| if !output.status.success() { | |
| return Err(format!( | |
| "Bash rejected redirect proof: {}", | |
| String::from_utf8_lossy(&output.stderr) | |
| )); | |
| } | |
| let actual = std::fs::read(root.join("result.txt")) | |
| .map_err(|err| format!("read redirect proof result failed: {err}"))?; | |
| if actual != value.as_bytes() { | |
| return Err(format!( | |
| "redirect proof changed the gap id: {:?}", | |
| String::from_utf8_lossy(&actual) | |
| )); | |
| } | |
| if root.join("=threshold").exists() { | |
| return Err( | |
| "redirect-shaped gap id opened a second redirect into `=threshold`".to_string(), | |
| ); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/patches/2347.py around lines 149 - 168, Update the
redirect-confinement assertion in the test around shell_arg and result.txt to
check for the actual unquoted-redirection artifact, “=threshold”, rather than
“threshold”. Ensure the test fails if that leaked file is created, and
preferably verify the temporary directory contains only the expected result.txt.
| - name: Check out the exclusively claimed branch without write credentials | ||
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 | ||
| with: | ||
| ref: fix/advisory-command-bash-argv-2347 | ||
| fetch-depth: 0 | ||
| persist-credentials: false |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Both checkouts resolve a moving branch tip while the commit job asserts the event SHA.
ref: fix/advisory-command-bash-argv-2347 fetches whatever the branch points at when each job starts, so the validate job can prove a different commit than github.event.pull_request.head.sha. The commit job then asserts equality against the event SHA on line 144, which means a push landing between the two jobs either aborts the run or, worse, lets the validate job's artifact be derived from a commit that was never the asserted one. Check out github.event.pull_request.head.sha explicitly in both jobs and keep the branch-name assertion for the push target.
🔒️ Proposed fix (apply to both checkout steps)
with:
- ref: fix/advisory-command-bash-argv-2347
+ ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0Also applies to: 134-145
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/validate-2347-bash-argv.yml around lines 25 - 30, Update
both checkout steps in the validation and commit jobs to use
github.event.pull_request.head.sha as the checkout ref, ensuring both jobs
operate on the asserted pull-request commit. Preserve the existing branch-name
assertion for the push target and the current checkout options, including
fetch-depth and credential handling.
| git fetch --no-tags origin codex/shell-arg-escaping-2347 | ||
| old="$(git rev-parse FETCH_HEAD)" | ||
| for file in \ | ||
| CHANGELOG.md \ | ||
| crates/ripr/src/output/first_pr.rs \ | ||
| crates/ripr/src/output/pilot/commands.rs \ | ||
| fixtures/first_successful_pr/python-preview-gap/expected/start-here.json \ | ||
| fixtures/first_successful_pr/python-preview-gap/expected/start-here.md | ||
| do | ||
| git show "${old}:${file}" > "${file}" | ||
| done |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- workflow file ---\n'
cat -n .github/workflows/validate-2347-bash-argv.yml | sed -n '1,220p'
printf '\n--- search for the branch name and related validation ---\n'
rg -n "codex/shell-arg-escaping-2347|FETCH_HEAD|rev-parse|git show \"\\$\\{old\\}:" .github/workflows crates fixtures -S || trueRepository: EffortlessMetrics/ripr-swarm
Length of output: 257
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- workflow file ---'
cat -n .github/workflows/validate-2347-bash-argv.yml | sed -n '1,220p'
echo
echo '--- search for the branch name and related validation ---'
rg -n "codex/shell-arg-escaping-2347|FETCH_HEAD|rev-parse|git show \"\$\{old\}:" .github/workflows crates fixtures -S || trueRepository: EffortlessMetrics/ripr-swarm
Length of output: 15191
Authorization Bypass (CWE-494): Download of Code Without Integrity Check
Reachability: Internal
Pin the imported source ref In .github/workflows/validate-2347-bash-argv.yml:40-50, the imported files come from the mutable codex/shell-arg-escaping-2347 branch tip. The job only checks the PR branch being finalized; it does not constrain this separate fetch, so the imported Rust sources can drift before the run. Pin that ref to a reviewed commit SHA and fail if FETCH_HEAD differs.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/validate-2347-bash-argv.yml around lines 40 - 50, Update
the fetch block in the workflow to fetch the reviewed commit SHA instead of the
mutable codex/shell-arg-escaping-2347 branch, and validate that FETCH_HEAD
exactly matches the expected SHA before importing files with git show. Fail the
job on any mismatch.
| permissions: | ||
| contents: write | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 10 |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Document the elevated contents: write scope.
zizmor flags the permission block as undocumented; a one-line comment stating this is the bounded push of the validated tree keeps the audit trail intact.
🧰 Tools
🪛 zizmor (1.26.1)
[warning] 130-130: permissions without explanatory comments (undocumented-permissions): needs an explanatory comment
(undocumented-permissions)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/validate-2347-bash-argv.yml around lines 129 - 132, Add a
one-line comment immediately above the permissions block documenting that
contents: write is narrowly required to push the validated tree. Keep the
existing permission scope and workflow behavior unchanged.
Source: Linters/SAST tools
| test "$(git rev-parse HEAD)" = "${{ github.event.pull_request.head.sha }}" | ||
| test "$(git branch --show-current)" = "fix/advisory-command-bash-argv-2347" | ||
| - name: Download the validated implementation tree | ||
| uses: actions/download-artifact@v8 |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- file outline ---'
ast-grep outline .github/workflows/validate-2347-bash-argv.yml --view expanded || true
echo '--- relevant lines ---'
nl -ba .github/workflows/validate-2347-bash-argv.yml | sed -n '1,240p'
echo '--- find download-artifact usages and permissions ---'
rg -n 'download-artifact|permissions:' .github/workflows/validate-2347-bash-argv.ymlRepository: EffortlessMetrics/ripr-swarm
Length of output: 310
🏁 Script executed (no clone):
#!/bin/bash
set -euo pipefail
echo '--- gh? no external query needed yet ---'
Length of output: 166
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# If the workflow references a version tag, inspect the action metadata in the repo only if vendored docs exist.
fd -a 'validate-2347-bash-argv.yml|README*|*.md' .github/workflows . || trueRepository: EffortlessMetrics/ripr-swarm
Length of output: 522
🏁 Script executed:
#!/bin/bash
set -euo pipefail
nl -ba .github/workflows/validate-2347-bash-argv.yml | sed -n '120,180p'Repository: EffortlessMetrics/ripr-swarm
Length of output: 206
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- workflow excerpt ---'
sed -n '1,240p' .github/workflows/validate-2347-bash-argv.yml
echo '--- permissions and download-artifact references ---'
grep -nE 'permissions:|download-artifact|contents:write' .github/workflows/validate-2347-bash-argv.yml || trueRepository: EffortlessMetrics/ripr-swarm
Length of output: 9514
Security Misconfiguration (CWE-494): Download of Code Without Integrity Check
Reachability: External
Pin actions/download-artifact in the commit job (.github/workflows/validate-2347-bash-argv.yml:147)
This step runs with contents: write, so the mutable v8 tag can execute unreviewed code with repository write access. Use a reviewed full commit SHA instead, matching the other pinned actions here.
🧰 Tools
🪛 zizmor (1.26.1)
[error] 147-147: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/validate-2347-bash-argv.yml at line 147, Update the
actions/download-artifact step in the commit job to reference a reviewed full
commit SHA instead of the mutable v8 tag, matching the pinning format used by
the other actions in the workflow.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Around line 26-40: Correct the CHANGELOG entry to describe the shipped
single-quote behavior: state that shell_arg renders non-safe values as
single-quoted Bash tokens and escapes embedded single quotes using the
implemented form, and update the python-preview-gap fixture description to say
the gap-id is single-quoted. Remove references to backslash-escaping `$`,
backticks, and `!` in double quotes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 1f4914e6-1652-4a96-826b-16fcc9f15d12
📒 Files selected for processing (15)
CHANGELOG.mdcrates/ripr/src/agent/loop_commands.rscrates/ripr/src/app/agent_status.rscrates/ripr/src/lsp/tests.rscrates/ripr/src/output/first_pr.rscrates/ripr/src/output/pilot/commands.rscrates/ripr/src/output/receipt_write.rsfixtures/boundary_gap/expected/llm-work-loop/path-with-spaces/review-summary.jsonfixtures/first_successful_pr/boundary-gap/expected/start-here.jsonfixtures/first_successful_pr/boundary-gap/expected/start-here.mdfixtures/first_successful_pr/output-contract-gap/expected/start-here.jsonfixtures/first_successful_pr/output-contract-gap/expected/start-here.mdfixtures/first_successful_pr/python-preview-gap/expected/start-here.jsonfixtures/first_successful_pr/python-preview-gap/expected/start-here.mdpolicy/process_allowlist.txt
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
EffortlessMetrics/ripr(auto-detected)EffortlessMetrics/em-ci(auto-detected)EffortlessMetrics/perl-lsp(auto-detected)EffortlessMetrics/unsafe-review(auto-detected)EffortlessMetrics/ub-review(auto-detected)
| - Advisory command strings rendered into first-pr start-here packets, agent | ||
| workflow manifests, and preflight recovery messages now escape the full bash | ||
| metacharacter set inside double quotes. The `shell_arg` helper previously | ||
| escaped only `\` and `"`, leaving `$`, backtick, and `!` live inside the | ||
| quoted form; in addition, thirteen `format!` sites in `first_pr.rs` bypassed | ||
| the helper entirely and interpolated paths, refs, and gap-ids raw. The | ||
| highest-impact case was a `>`-containing gap-id rendered unquoted into an | ||
| agent-packet command, where bash would parse the `>` as a redirect and | ||
| truncate a sibling file. The helper now backslash-escapes `$`, backtick, and | ||
| `!` in the quote path, and every advisory command builder routes its | ||
| interpolated values through it. The `python-preview-gap` start-here fixture | ||
| is re-blessed so its gap-id renders double-quoted, reflecting the corrected | ||
| (redirect-safe) shape. These commands remain advisory text for humans and | ||
| agents; ripr does not execute them (#2347). | ||
|
|
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Changelog describes double-quote escaping; actual fix is total single-quoting.
This entry says shell_arg "backslash-escapes $, backtick, and ! in the quote path" and that the gap-id "renders double-quoted." The shipped implementation does neither: shell_arg renders non-safe values as single-quoted Bash tokens ('...' with '\'' for embedded quotes), and the re-blessed python-preview-gap fixture shows the gap-id single-quoted, not double-quoted. This text appears to be stale wording carried over from the prior double-quote-based draft rather than the single-quote approach actually implemented here.
📝 Proposed changelog correction
-- Advisory command strings rendered into first-pr start-here packets, agent
- workflow manifests, and preflight recovery messages now escape the full bash
- metacharacter set inside double quotes. The `shell_arg` helper previously
- escaped only `\` and `"`, leaving `$`, backtick, and `!` live inside the
- quoted form; in addition, thirteen `format!` sites in `first_pr.rs` bypassed
- the helper entirely and interpolated paths, refs, and gap-ids raw. The
- highest-impact case was a `>`-containing gap-id rendered unquoted into an
- agent-packet command, where bash would parse the `>` as a redirect and
- truncate a sibling file. The helper now backslash-escapes `$`, backtick, and
- `!` in the quote path, and every advisory command builder routes its
- interpolated values through it. The `python-preview-gap` start-here fixture
- is re-blessed so its gap-id renders double-quoted, reflecting the corrected
- (redirect-safe) shape. These commands remain advisory text for humans and
- agents; ripr does not execute them (`#2347`).
+- Advisory command strings rendered into first-pr start-here packets, agent
+ workflow manifests, and preflight recovery messages now use total Bash
+ single-quoting for any non-trivially-safe value. `shell_arg` previously used
+ a different escaping strategy that left some metacharacters live inside the
+ quoted form; in addition, thirteen `format!` sites in `first_pr.rs` bypassed
+ the helper entirely and interpolated paths, refs, and gap-ids raw. The
+ highest-impact case was a `>`-containing gap-id rendered unquoted into an
+ agent-packet command, where bash would parse the `>` as a redirect and
+ truncate a sibling file. The helper now wraps every non-safe value in single
+ quotes (with the standard `'\''` splice for embedded quotes), and every
+ advisory command builder routes its interpolated values through it. The
+ `python-preview-gap` start-here fixture is re-blessed so its gap-id renders
+ single-quoted, reflecting the corrected (redirect-safe) shape. These
+ commands remain advisory text for humans and agents; ripr does not execute
+ them (`#2347`).📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| - Advisory command strings rendered into first-pr start-here packets, agent | |
| workflow manifests, and preflight recovery messages now escape the full bash | |
| metacharacter set inside double quotes. The `shell_arg` helper previously | |
| escaped only `\` and `"`, leaving `$`, backtick, and `!` live inside the | |
| quoted form; in addition, thirteen `format!` sites in `first_pr.rs` bypassed | |
| the helper entirely and interpolated paths, refs, and gap-ids raw. The | |
| highest-impact case was a `>`-containing gap-id rendered unquoted into an | |
| agent-packet command, where bash would parse the `>` as a redirect and | |
| truncate a sibling file. The helper now backslash-escapes `$`, backtick, and | |
| `!` in the quote path, and every advisory command builder routes its | |
| interpolated values through it. The `python-preview-gap` start-here fixture | |
| is re-blessed so its gap-id renders double-quoted, reflecting the corrected | |
| (redirect-safe) shape. These commands remain advisory text for humans and | |
| agents; ripr does not execute them (#2347). | |
| - Advisory command strings rendered into first-pr start-here packets, agent | |
| workflow manifests, and preflight recovery messages now use total Bash | |
| single-quoting for any non-trivially-safe value. `shell_arg` previously used | |
| a different escaping strategy that left some metacharacters live inside the | |
| quoted form; in addition, thirteen `format!` sites in `first_pr.rs` bypassed | |
| the helper entirely and interpolated paths, refs, and gap-ids raw. The | |
| highest-impact case was a `>`-containing gap-id rendered unquoted into an | |
| agent-packet command, where bash would parse the `>` as a redirect and | |
| truncate a sibling file. The helper now wraps every non-safe value in single | |
| quotes (with the standard `'\''` splice for embedded quotes), and every | |
| advisory command builder routes its interpolated values through it. The | |
| `python-preview-gap` start-here fixture is re-blessed so its gap-id renders | |
| single-quoted, reflecting the corrected (redirect-safe) shape. These | |
| commands remain advisory text for humans and agents; ripr does not execute | |
| them (`#2347`). |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@CHANGELOG.md` around lines 26 - 40, Correct the CHANGELOG entry to describe
the shipped single-quote behavior: state that shell_arg renders non-safe values
as single-quoted Bash tokens and escapes embedded single quotes using the
implemented form, and update the python-preview-gap fixture description to say
the gap-id is single-quoted. Remove references to backslash-escaping `$`,
backticks, and `!` in double quotes.
Superseded implementation vehiclePR #2435 landed the acceptance-complete source implementation as squash commit This draft is no longer an active implementation surface. Its transformation/proof history remains useful archaeology, but the final encoder, call-site routing, Bash argv proof, redirect-confinement proof, fixtures, policy entry, and changelog all shipped through #2435. Closing unmerged to leave one canonical implementation and one accepted issue closeout. |
Work in progress
Replaces obsolete draft #2386 from current
main.The validation branch currently contains only a read-only transform and proof workflow. It imports the already-reviewed call-site routing from #2386, replaces the partial encoder with one total single-quote Bash argv encoder, adds actual shell round-trip and redirect-clobber proof, and inventories every source/golden expectation that must change.
The workflow has
contents: read, persists no credentials, does not commit or push, and uploads the exact candidate patch plus named command logs. Temporary workflow and transform files are removed from the validation worktree before file-policy and diff capture, so they cannot masquerade as final implementation.No production process execution is added. These commands remain advisory text for humans and agents. No version, support tier, candidate ref, source promotion, or publication authority changes are in scope.