Skip to content

security(agent): make advisory command argv round-trip through Bash (#2347) - #2433

Closed
EffortlessSteven wants to merge 11 commits into
mainfrom
fix/advisory-command-bash-argv-2347
Closed

EffortlessSteven wants to merge 11 commits into
mainfrom
fix/advisory-command-bash-argv-2347

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

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.

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@sourcery-ai sourcery-ai Bot 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.

Sorry @EffortlessSteven, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1f9aa8f1-78d7-4ea9-ae39-e9df26d022b2

📥 Commits

Reviewing files that changed from the base of the PR and between 5e84587 and 2f49157.

📒 Files selected for processing (1)
  • crates/ripr/src/agent/loop_commands.rs
🔗 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)

Summary by CodeRabbit

  • Bug Fixes

    • Improved quoting and escaping in generated advisory commands, including paths, gap IDs, modes, and verification commands.
    • Prevented shell metacharacters from being interpreted when commands are copied or reviewed.
    • Ensured generated commands cannot accidentally create unintended redirect targets.
  • Tests

    • Added coverage for hostile characters, empty values, spaces, and redirect scenarios.
    • Updated expected command output to reflect safer quoting.

Walkthrough

Advisory 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.

Changes

Advisory command quoting

Layer / File(s) Summary
Shell quoting implementation and validation
crates/ripr/src/agent/loop_commands.rs, policy/process_allowlist.txt
shell_arg uses single-quoted Bash tokens, with Unix tests covering metacharacters, round trips, and redirect confinement.
Advisory command builder integration
crates/ripr/src/output/first_pr.rs, crates/ripr/src/output/pilot/commands.rs
Recovery, regeneration, agent-packet, gap-ledger, and retry commands route interpolated values through shell_arg.
Command expectations and release documentation
crates/ripr/src/app/agent_status.rs, crates/ripr/src/lsp/tests.rs, crates/ripr/src/output/receipt_write.rs, fixtures/..., CHANGELOG.md
Tests, generated fixtures, and changelog text reflect the single-quoted command format and quoted gap IDs.

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
Loading

Possibly related PRs

Suggested labels: full-ci

Poem

I’m a rabbit with quotes in my pack,
Keeping wild shell characters back.
Gap IDs stay tight,
Redirects behave right,
And commands hop safely on track.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description does not use the required template and omits most required sections like Summary, Scope, Proof, and Gates. Rewrite it using the repository template and fill in the required sections, especially Summary, Scope, Proof, and relevant checkboxes.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: advisory command argv now round-trips through Bash.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/advisory-command-bash-argv-2347

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

@coderabbitai coderabbitai Bot 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 526ab40 and 9ef036d.

📒 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)

Comment thread .github/patches/2347-expectations.py Outdated
Comment on lines +111 to +114
if json_changes == 0 or markdown_changes == 0:
raise SystemExit(
"first-PR receipt corpus migration found no remaining JSON or Markdown double-quoted commands"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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.

Comment thread .github/patches/2347.py Resolved
Comment thread .github/patches/2347.py Outdated
Comment on lines +65 to +67
module_end = text.rfind("\n}")
if module_end < 0:
raise SystemExit("loop_commands test module end not found")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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.

Comment thread .github/patches/2347.py Outdated
Comment on lines +139 to +148
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}"))?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 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.

Comment thread .github/patches/2347.py Outdated
Comment on lines +149 to +168
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());
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 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.

Suggested change
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.

Comment on lines +25 to +30
- 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ 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: 0

Also 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.

Comment on lines +40 to +50
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 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 || true

Repository: 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 || true

Repository: 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.

Comment on lines +129 to +132
permissions:
contents: write
runs-on: ubuntu-24.04
timeout-minutes: 10

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 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.yml

Repository: 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 . || true

Repository: 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 || true

Repository: 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.

@coderabbitai coderabbitai Bot 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9ef036d and 5e84587.

📒 Files selected for processing (15)
  • CHANGELOG.md
  • crates/ripr/src/agent/loop_commands.rs
  • crates/ripr/src/app/agent_status.rs
  • crates/ripr/src/lsp/tests.rs
  • crates/ripr/src/output/first_pr.rs
  • crates/ripr/src/output/pilot/commands.rs
  • crates/ripr/src/output/receipt_write.rs
  • fixtures/boundary_gap/expected/llm-work-loop/path-with-spaces/review-summary.json
  • fixtures/first_successful_pr/boundary-gap/expected/start-here.json
  • fixtures/first_successful_pr/boundary-gap/expected/start-here.md
  • fixtures/first_successful_pr/output-contract-gap/expected/start-here.json
  • fixtures/first_successful_pr/output-contract-gap/expected/start-here.md
  • fixtures/first_successful_pr/python-preview-gap/expected/start-here.json
  • fixtures/first_successful_pr/python-preview-gap/expected/start-here.md
  • policy/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)

Comment thread CHANGELOG.md
Comment on lines +26 to +40
- 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).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 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.

Suggested change
- 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.

Copy link
Copy Markdown
Member Author

Superseded implementation vehicle

PR #2435 landed the acceptance-complete source implementation as squash commit 236df22b761545926d09cab8d257afca0314a1c0 and closed #2347.

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.

This was referenced Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Run required, advisory, and release-like CI lanes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant