Files
289581e9c1 integrate: pre-bash guard reads $(...) and parameter defaults (#4848) (#5024)
* fix(hooks): read $(...) substitutions and parameter defaults in the root-delete guard

hasRootDelete parsed backtick substitutions but not $(...): the $ joined
the word and ( reset the rm being parsed, so rm -rf "$(echo)"/ and
rm $(:) -rf / passed while their backtick spellings were refused. A $(...)
body is now matched past quotes and nesting, scanned as its own command,
and dropped from the word, as a backtick one is. $((...)) is arithmetic:
its body is still scanned and a digit stands in for it. Once a $( never
closes, the rest of that scan reads ( and ) as separators, as before.

A parameter's default (X:-word, X-word, X:=word, X=word in dollar braces)
is now judged as the word the shell uses when the name is unset, so
rm -rf ${X:-/} is refused. Single quotes keep it literal.

Same change in both hook-handler.cjs copies, the generated fallback and
the ruflo-mods guard (0.16.3), with parity cases in mods-guard.test.ts.
The packaged helper is signed, so helpers.manifest.json needs a re-sign.

Fixes #4742

* fix(hooks): fail closed on an unclosed $( and read array/indirect defaults (ruflo-mods 0.17.2)

closeParen now skips $'...' strings with their escapes and # comments, so
rm -rf $(echo $'\'')/ and a ) inside a comment no longer end the scan early.
A $( that never closes in a command with an rm in it is refused instead of
read the old way. The parameter matcher takes an optional leading ! and a
[...] subscript, so ${A[0]:-/} and ${!X:-/} are refused. Same change in all
four guard copies, with the review's inputs as parity cases.

Refs #4742

* chore(helpers): re-sign the helpers manifest for the #4848 hook-handler guard

#4848 changes .claude/helpers/hook-handler.cjs, so the signed manifest's
hash no longer matched (guard: helper-signing.test.ts integrity mismatch).
Re-signed with the release key; helper-signing + mods-guard: 312/312.

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: Parman Mohammadalizadeh <prmma23@gmail.com>
Co-authored-by: r <r@x>
2026-11-17 15:28:35 -05:00
..