Repository navigation
fix(hooks): guard-orchestrator-writes analyses scripts created by the same command and names the tried path (#1854) - #1861
Conversation
…ying it as unreadable (#1854) guard-orchestrator-writes judges a script that the same command creates from the text that command carries, and names the tried path, raw argument and base directory when it denies a missing or unresolvable script. Adds reviewer probe-script cases to Test-Hooks.ps1.
…#1854) A script created by the same command is allowed only with literal content and no src/ or tests/ mention in the command; copies, downloads and Get-Content sources are denied. Adds pipeline-form, Get-Content and Copy-Item regression cases.
|
@coderabbitai review |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughEl cambio amplía el análisis de comandos y escrituras para validar scripts lanzados por el guard. La validación distingue contenido literal, anexiones, rutas sin resolver y ejecutables. Se añaden pruebas para scripts permitidos y bloqueados, y se actualiza la documentación de la política. ChangesProtección de scripts lanzados
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No merge-blocking issue was identified; the change is ready for normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
…#1854) guard-orchestrator-writes now trusts a script that the same command creates or overwrites only when every write to it is a quoted or here-string literal (Set-Content/Add-Content -Value, Out-File/Tee-Object -InputObject, New-Item -Value, a lone literal piped in, or 'literal' > file). Every other source of content, a wildcard target, a rename, a copy or any statement the hook cannot name while the script is created is denied, naming the creating statement. Literals must not reference src/ or tests/ or launch another script, and the old text of an existing script is judged too. A & $variable launch is unresolvable when the command also writes a file. Tokens gain Literal and PipeSource; Rename-Item is modelled as a write. Adds the review repro cases and false-positive cases to Test-Hooks and documents the rules.
|
Review findings applied in Literal content checks
Second-round hardening
Verification
Pre-existing limits (they also exist on
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
guard-orchestrator-writes.ps1no longer denies, as "could not read", a probe script that the same command creates. When it does deny, it now says which path it tried.Created by the same command. A missing script is allowed when the same command writes that exact file with literal content (
Set-Content,Add-Content,Out-Fileor a redirection). It is still denied when:src/ortests/;Get-Content, a download or a copy.Denials and their messages.
An existing script that references
src/ortests/and writes files is still denied.Cause
Reproduced with reviewer payloads: an existing scratch stub run through
&, anddotnet run probe.cswith a relative path, were already allowed. The denials happen when the script is absent at hook time, typically because the same command creates it. The old messages did not record the tried path, so the exact cause behind the three denials of 2026-10-05 (PR #1852 and PR #1849) cannot be confirmed. The new messages make the next case diagnosable.Verification
Test-Hooks.ps1: 1125 cases, 0 failed (16 new, in the#1854block).adversarial-reviewerfound two majors, both fixed inc03f4ccewith regression tests:Get-Content, a download) was allowed;'...src...' | Set-Content x.ps1slipped through.Known limits
src/is not detected; the heuristic already had this limit for existing scripts.src/is denied, and the message says to split it into two calls.Fixes #1854
Summary by CodeRabbit