@codyswann/lisa 2.297.2 → 2.297.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  2. package/dist/core/upstream-evidence-manifest.js +3 -2
  3. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  4. package/dist/opencode/plugin-templates/parity-safety-net.sh +65 -7
  5. package/package.json +1 -1
  6. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  7. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  8. package/plugins/lisa/.codex-plugin/skills/lisa-parity-safety-net-rules/SKILL.md +6 -1
  9. package/plugins/lisa/hooks/parity-safety-net.sh +65 -7
  10. package/plugins/lisa/skills/lisa-parity-safety-net-rules/SKILL.md +6 -1
  11. package/plugins/lisa-agy/hooks/parity-safety-net.sh +65 -7
  12. package/plugins/lisa-agy/plugin.json +1 -1
  13. package/plugins/lisa-agy/skills/lisa-parity-safety-net-rules/SKILL.md +6 -1
  14. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  15. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  16. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  17. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  18. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  19. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  20. package/plugins/lisa-copilot/hooks/parity-safety-net.sh +65 -7
  21. package/plugins/lisa-copilot/skills/lisa-parity-safety-net-rules/SKILL.md +6 -1
  22. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  23. package/plugins/lisa-cursor/hooks/parity-safety-net.sh +65 -7
  24. package/plugins/lisa-cursor/skills/lisa-parity-safety-net-rules/SKILL.md +6 -1
  25. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  27. package/plugins/lisa-expo-agy/plugin.json +1 -1
  28. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  30. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  32. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  33. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  37. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  38. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  39. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  42. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  43. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  47. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  48. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  52. package/plugins/lisa-rails-agy/plugin.json +1 -1
  53. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  57. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  58. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  62. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  63. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  65. package/plugins/src/base/hooks/parity-safety-net.sh +65 -7
  66. package/plugins/src/base/skills/lisa-parity-safety-net-rules/SKILL.md +6 -1
@@ -48,8 +48,13 @@
48
48
  # Known accepted false-positive class: this is a text scan, not a shell engine,
49
49
  # so display commands quoting a destructive string (`echo "docs about rm -rf /"`)
50
50
  # can match. Upstream exempts those via an engine-only DISPLAY_COMMANDS list a
51
- # grep hook cannot replicate. Workaround: quote-break the string or use the
52
- # gh-writer heredoc form, whose payload is stripped before the guards run.
51
+ # grep hook cannot replicate. The same text-scan limit means the rm guard treats
52
+ # a substitution-wrapped catastrophic delete as verdict-neutral (issue #1982): an
53
+ # executable `echo "$(rm -rf /)"` is blocked, but so are inert twins the shell
54
+ # would never expand — a single-quoted `echo '$(rm -rf /)'` or an escaped
55
+ # `echo "\$(rm -rf /)"` — because the scan has no quote-context awareness. That
56
+ # over-block stays inside this accepted class. Workaround: quote-break the string
57
+ # or use the gh-writer heredoc form, whose payload is stripped before the guards run.
53
58
  #
54
59
  # Operators extend the built-in rules with a project-local rule file — one
55
60
  # extended-regex (ERE) per line, blank lines and `#` comments ignored — managed
@@ -206,7 +211,17 @@ readonly RM_RF_SPLIT="$RM_CMD"'(([[:space:]][^;&|]*)?[[:space:]](-[[:alnum:]]*r[
206
211
  # review S1): a harmless `/` in a LATER statement (`rm -rf build && cd /`)
207
212
  # is never attributed to the rm in an earlier one.
208
213
  qc="'\""
209
- readonly RM_CATASTROPHIC_TARGET='([[:space:]='"$qc"'])(/|/\*|/\.\*?|~|~/\*?|\$HOME\b|\$\{HOME\}|\*)([[:space:]'"$qc"']|/?\*?['"$qc"']?$)'
214
+ # Path/home targets also accept the command-substitution closers `)` and backtick
215
+ # as a trailing boundary (issue #1982): in `echo "$(rm -rf /)"` the target `/` is
216
+ # followed by `)`, not a space or quote, so without them an executable
217
+ # substitution-wrapped `rm -rf <root>` slips past this gate. Leading boundary is
218
+ # unchanged — the target is always space-separated from the recursive+force flag.
219
+ tc="'\"\`)"
220
+ # The bare-`*` wildcard deliberately KEEPS the narrow (space/quote/end) boundary:
221
+ # admitting `)` there would misread a shell `case … in *)` default arm as a
222
+ # catastrophic `rm -rf *` (T4b F1). A genuinely substitution-wrapped bare `*`
223
+ # (`echo "$(rm -rf *)"`) is instead caught by the token-walk (guard 1b) below.
224
+ readonly RM_CATASTROPHIC_TARGET='([[:space:]='"$qc"'])((/|/\*|/\.\*?|~|~/\*?|\$HOME\b|\$\{HOME\})([[:space:]'"$tc"']|/?\*?['"$tc"']?$)|\*([[:space:]'"$qc"']|/?\*?['"$qc"']?$))'
210
225
 
211
226
  # 1b. rm target hardening (issue #1960). For every statement that invokes rm
212
227
  # with recursive+force flags, additionally block when:
@@ -224,6 +239,45 @@ project_dir="${CLAUDE_PROJECT_DIR:-$PWD}"
224
239
  tmp_dir_allow="${TMPDIR:-/tmp}"
225
240
  tmp_dir_allow="${tmp_dir_allow%/}"
226
241
  [ -n "$tmp_dir_allow" ] || tmp_dir_allow="/tmp"
242
+ # Peel command-substitution wrappers off a token so an rm nested in `$(…)`,
243
+ # backticks, `<(…)`/`>(…)`, a `"…"`/`'…'` quote, or a leading `\` alias-bypass
244
+ # (`\rm`) is recognized and its target classified as if the token were unwrapped
245
+ # (issue #1982) — substitution-wrapping is verdict-neutral for the rm guard.
246
+ # Leading wrappers (\ $( ` ( <( >( and quotes) and trailing closers () ` and
247
+ # quotes) are stripped in runs, so `"$(\rm` → `rm` and `/etc)"` → `/etc`. `$((`
248
+ # is ARITHMETIC, never command substitution: the LEADING peel stops at it (its
249
+ # case is ordered first), so the inner expression is never exposed as a command
250
+ # or a target. The trailing loop may still trim a closing `))`, but that is
251
+ # harmless — an arithmetic token like `$((10/2))` still keeps its `$` for the
252
+ # variable-target guard and can never be mis-normalized into an rm or a `/`-target.
253
+ strip_subst_wrappers() {
254
+ local t="$1" prev=""
255
+ while [ "$t" != "$prev" ]; do
256
+ prev="$t"
257
+ case "$t" in
258
+ '$(('*) break ;;
259
+ '\'*) t="${t#\\}" ;;
260
+ '$('*) t="${t#'$('}" ;;
261
+ '<('*) t="${t#'<('}" ;;
262
+ '>('*) t="${t#'>('}" ;;
263
+ '"'*) t="${t#'"'}" ;;
264
+ "'"*) t="${t#\'}" ;;
265
+ '`'*) t="${t#'`'}" ;;
266
+ '('*) t="${t#(}" ;;
267
+ esac
268
+ done
269
+ prev=""
270
+ while [ "$t" != "$prev" ]; do
271
+ prev="$t"
272
+ case "$t" in
273
+ *')') t="${t%)}" ;;
274
+ *'`') t="${t%'`'}" ;;
275
+ *'"') t="${t%'"'}" ;;
276
+ *"'") t="${t%\'}" ;;
277
+ esac
278
+ done
279
+ printf '%s' "$t"
280
+ }
227
281
  while IFS= read -r rm_stmt; do
228
282
  if ! printf '%s' "$rm_stmt" | grep -Eiq -- "$RM_RF_CLUSTER" \
229
283
  && ! printf '%s' "$rm_stmt" | grep -Eiq -- "$RM_RF_SPLIT"; then
@@ -242,10 +296,7 @@ while IFS= read -r rm_stmt; do
242
296
  set -f
243
297
  seen_rm=0
244
298
  for raw_token in $rm_stmt; do
245
- token="${raw_token#\"}"
246
- token="${token#\'}"
247
- token="${token%\"}"
248
- token="${token%\'}"
299
+ token="$(strip_subst_wrappers "$raw_token")"
249
300
  if [ "$seen_rm" -eq 0 ]; then
250
301
  # Path-prefixed spellings (`/bin/rm`, `./rm`) are still rm (F2).
251
302
  case "$token" in
@@ -276,6 +327,13 @@ while IFS= read -r rm_stmt; do
276
327
  ;;
277
328
  esac
278
329
  ;;
330
+ '*')
331
+ # Bare top-level wildcard expands to every entry in the cwd. Guard 1a no
332
+ # longer bounds `*)` (T4b F1), so a substitution-wrapped `rm -rf *` is
333
+ # caught here after the trailing-closer strip peels `*)"` down to `*`.
334
+ set +f
335
+ block "recursive forced delete of a top-level wildcard (rm -rf *)"
336
+ ;;
279
337
  *'$'*)
280
338
  case "$token" in
281
339
  '$TMPDIR' | '$TMPDIR'/* | '${TMPDIR}' | '${TMPDIR}'/*) : ;;
package/package.json CHANGED
@@ -113,7 +113,7 @@
113
113
  "brace-expansion": ">=5.0.6"
114
114
  },
115
115
  "name": "@codyswann/lisa",
116
- "version": "2.297.2",
116
+ "version": "2.297.3",
117
117
  "description": "Claude Code governance framework that applies guardrails, guidance, and automated enforcement to projects",
118
118
  "main": "dist/index.js",
119
119
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "Universal governance: agents, skills, commands, hooks, and rules for all projects.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -98,7 +98,12 @@ is screened the same as `git <destructive>`.
98
98
  Malformed hook input fails **closed** (exit 2 denies the command). A text-scan
99
99
  hook cannot exempt display commands, so prose like
100
100
  `echo "docs about rm -rf /"` can false-positive — quote-break the string or use
101
- the gh-writer heredoc form (payload is stripped before the guards run).
101
+ the gh-writer heredoc form (payload is stripped before the guards run). For the
102
+ same reason the rm guard treats substitution-wrapping as verdict-neutral (issue
103
+ #1982): an executable `echo "$(rm -rf /)"` is blocked, and so are inert twins the
104
+ shell would never expand — a single-quoted `echo '$(rm -rf /)'` or an escaped
105
+ `echo "\$(rm -rf /)"` — since the scan has no quote-context awareness. The same
106
+ quote-break or heredoc workaround applies.
102
107
 
103
108
  ## View the current rules
104
109
 
@@ -48,8 +48,13 @@
48
48
  # Known accepted false-positive class: this is a text scan, not a shell engine,
49
49
  # so display commands quoting a destructive string (`echo "docs about rm -rf /"`)
50
50
  # can match. Upstream exempts those via an engine-only DISPLAY_COMMANDS list a
51
- # grep hook cannot replicate. Workaround: quote-break the string or use the
52
- # gh-writer heredoc form, whose payload is stripped before the guards run.
51
+ # grep hook cannot replicate. The same text-scan limit means the rm guard treats
52
+ # a substitution-wrapped catastrophic delete as verdict-neutral (issue #1982): an
53
+ # executable `echo "$(rm -rf /)"` is blocked, but so are inert twins the shell
54
+ # would never expand — a single-quoted `echo '$(rm -rf /)'` or an escaped
55
+ # `echo "\$(rm -rf /)"` — because the scan has no quote-context awareness. That
56
+ # over-block stays inside this accepted class. Workaround: quote-break the string
57
+ # or use the gh-writer heredoc form, whose payload is stripped before the guards run.
53
58
  #
54
59
  # Operators extend the built-in rules with a project-local rule file — one
55
60
  # extended-regex (ERE) per line, blank lines and `#` comments ignored — managed
@@ -206,7 +211,17 @@ readonly RM_RF_SPLIT="$RM_CMD"'(([[:space:]][^;&|]*)?[[:space:]](-[[:alnum:]]*r[
206
211
  # review S1): a harmless `/` in a LATER statement (`rm -rf build && cd /`)
207
212
  # is never attributed to the rm in an earlier one.
208
213
  qc="'\""
209
- readonly RM_CATASTROPHIC_TARGET='([[:space:]='"$qc"'])(/|/\*|/\.\*?|~|~/\*?|\$HOME\b|\$\{HOME\}|\*)([[:space:]'"$qc"']|/?\*?['"$qc"']?$)'
214
+ # Path/home targets also accept the command-substitution closers `)` and backtick
215
+ # as a trailing boundary (issue #1982): in `echo "$(rm -rf /)"` the target `/` is
216
+ # followed by `)`, not a space or quote, so without them an executable
217
+ # substitution-wrapped `rm -rf <root>` slips past this gate. Leading boundary is
218
+ # unchanged — the target is always space-separated from the recursive+force flag.
219
+ tc="'\"\`)"
220
+ # The bare-`*` wildcard deliberately KEEPS the narrow (space/quote/end) boundary:
221
+ # admitting `)` there would misread a shell `case … in *)` default arm as a
222
+ # catastrophic `rm -rf *` (T4b F1). A genuinely substitution-wrapped bare `*`
223
+ # (`echo "$(rm -rf *)"`) is instead caught by the token-walk (guard 1b) below.
224
+ readonly RM_CATASTROPHIC_TARGET='([[:space:]='"$qc"'])((/|/\*|/\.\*?|~|~/\*?|\$HOME\b|\$\{HOME\})([[:space:]'"$tc"']|/?\*?['"$tc"']?$)|\*([[:space:]'"$qc"']|/?\*?['"$qc"']?$))'
210
225
 
211
226
  # 1b. rm target hardening (issue #1960). For every statement that invokes rm
212
227
  # with recursive+force flags, additionally block when:
@@ -224,6 +239,45 @@ project_dir="${CLAUDE_PROJECT_DIR:-$PWD}"
224
239
  tmp_dir_allow="${TMPDIR:-/tmp}"
225
240
  tmp_dir_allow="${tmp_dir_allow%/}"
226
241
  [ -n "$tmp_dir_allow" ] || tmp_dir_allow="/tmp"
242
+ # Peel command-substitution wrappers off a token so an rm nested in `$(…)`,
243
+ # backticks, `<(…)`/`>(…)`, a `"…"`/`'…'` quote, or a leading `\` alias-bypass
244
+ # (`\rm`) is recognized and its target classified as if the token were unwrapped
245
+ # (issue #1982) — substitution-wrapping is verdict-neutral for the rm guard.
246
+ # Leading wrappers (\ $( ` ( <( >( and quotes) and trailing closers () ` and
247
+ # quotes) are stripped in runs, so `"$(\rm` → `rm` and `/etc)"` → `/etc`. `$((`
248
+ # is ARITHMETIC, never command substitution: the LEADING peel stops at it (its
249
+ # case is ordered first), so the inner expression is never exposed as a command
250
+ # or a target. The trailing loop may still trim a closing `))`, but that is
251
+ # harmless — an arithmetic token like `$((10/2))` still keeps its `$` for the
252
+ # variable-target guard and can never be mis-normalized into an rm or a `/`-target.
253
+ strip_subst_wrappers() {
254
+ local t="$1" prev=""
255
+ while [ "$t" != "$prev" ]; do
256
+ prev="$t"
257
+ case "$t" in
258
+ '$(('*) break ;;
259
+ '\'*) t="${t#\\}" ;;
260
+ '$('*) t="${t#'$('}" ;;
261
+ '<('*) t="${t#'<('}" ;;
262
+ '>('*) t="${t#'>('}" ;;
263
+ '"'*) t="${t#'"'}" ;;
264
+ "'"*) t="${t#\'}" ;;
265
+ '`'*) t="${t#'`'}" ;;
266
+ '('*) t="${t#(}" ;;
267
+ esac
268
+ done
269
+ prev=""
270
+ while [ "$t" != "$prev" ]; do
271
+ prev="$t"
272
+ case "$t" in
273
+ *')') t="${t%)}" ;;
274
+ *'`') t="${t%'`'}" ;;
275
+ *'"') t="${t%'"'}" ;;
276
+ *"'") t="${t%\'}" ;;
277
+ esac
278
+ done
279
+ printf '%s' "$t"
280
+ }
227
281
  while IFS= read -r rm_stmt; do
228
282
  if ! printf '%s' "$rm_stmt" | grep -Eiq -- "$RM_RF_CLUSTER" \
229
283
  && ! printf '%s' "$rm_stmt" | grep -Eiq -- "$RM_RF_SPLIT"; then
@@ -242,10 +296,7 @@ while IFS= read -r rm_stmt; do
242
296
  set -f
243
297
  seen_rm=0
244
298
  for raw_token in $rm_stmt; do
245
- token="${raw_token#\"}"
246
- token="${token#\'}"
247
- token="${token%\"}"
248
- token="${token%\'}"
299
+ token="$(strip_subst_wrappers "$raw_token")"
249
300
  if [ "$seen_rm" -eq 0 ]; then
250
301
  # Path-prefixed spellings (`/bin/rm`, `./rm`) are still rm (F2).
251
302
  case "$token" in
@@ -276,6 +327,13 @@ while IFS= read -r rm_stmt; do
276
327
  ;;
277
328
  esac
278
329
  ;;
330
+ '*')
331
+ # Bare top-level wildcard expands to every entry in the cwd. Guard 1a no
332
+ # longer bounds `*)` (T4b F1), so a substitution-wrapped `rm -rf *` is
333
+ # caught here after the trailing-closer strip peels `*)"` down to `*`.
334
+ set +f
335
+ block "recursive forced delete of a top-level wildcard (rm -rf *)"
336
+ ;;
279
337
  *'$'*)
280
338
  case "$token" in
281
339
  '$TMPDIR' | '$TMPDIR'/* | '${TMPDIR}' | '${TMPDIR}'/*) : ;;
@@ -98,7 +98,12 @@ is screened the same as `git <destructive>`.
98
98
  Malformed hook input fails **closed** (exit 2 denies the command). A text-scan
99
99
  hook cannot exempt display commands, so prose like
100
100
  `echo "docs about rm -rf /"` can false-positive — quote-break the string or use
101
- the gh-writer heredoc form (payload is stripped before the guards run).
101
+ the gh-writer heredoc form (payload is stripped before the guards run). For the
102
+ same reason the rm guard treats substitution-wrapping as verdict-neutral (issue
103
+ #1982): an executable `echo "$(rm -rf /)"` is blocked, and so are inert twins the
104
+ shell would never expand — a single-quoted `echo '$(rm -rf /)'` or an escaped
105
+ `echo "\$(rm -rf /)"` — since the scan has no quote-context awareness. The same
106
+ quote-break or heredoc workaround applies.
102
107
 
103
108
  ## View the current rules
104
109
 
@@ -48,8 +48,13 @@
48
48
  # Known accepted false-positive class: this is a text scan, not a shell engine,
49
49
  # so display commands quoting a destructive string (`echo "docs about rm -rf /"`)
50
50
  # can match. Upstream exempts those via an engine-only DISPLAY_COMMANDS list a
51
- # grep hook cannot replicate. Workaround: quote-break the string or use the
52
- # gh-writer heredoc form, whose payload is stripped before the guards run.
51
+ # grep hook cannot replicate. The same text-scan limit means the rm guard treats
52
+ # a substitution-wrapped catastrophic delete as verdict-neutral (issue #1982): an
53
+ # executable `echo "$(rm -rf /)"` is blocked, but so are inert twins the shell
54
+ # would never expand — a single-quoted `echo '$(rm -rf /)'` or an escaped
55
+ # `echo "\$(rm -rf /)"` — because the scan has no quote-context awareness. That
56
+ # over-block stays inside this accepted class. Workaround: quote-break the string
57
+ # or use the gh-writer heredoc form, whose payload is stripped before the guards run.
53
58
  #
54
59
  # Operators extend the built-in rules with a project-local rule file — one
55
60
  # extended-regex (ERE) per line, blank lines and `#` comments ignored — managed
@@ -206,7 +211,17 @@ readonly RM_RF_SPLIT="$RM_CMD"'(([[:space:]][^;&|]*)?[[:space:]](-[[:alnum:]]*r[
206
211
  # review S1): a harmless `/` in a LATER statement (`rm -rf build && cd /`)
207
212
  # is never attributed to the rm in an earlier one.
208
213
  qc="'\""
209
- readonly RM_CATASTROPHIC_TARGET='([[:space:]='"$qc"'])(/|/\*|/\.\*?|~|~/\*?|\$HOME\b|\$\{HOME\}|\*)([[:space:]'"$qc"']|/?\*?['"$qc"']?$)'
214
+ # Path/home targets also accept the command-substitution closers `)` and backtick
215
+ # as a trailing boundary (issue #1982): in `echo "$(rm -rf /)"` the target `/` is
216
+ # followed by `)`, not a space or quote, so without them an executable
217
+ # substitution-wrapped `rm -rf <root>` slips past this gate. Leading boundary is
218
+ # unchanged — the target is always space-separated from the recursive+force flag.
219
+ tc="'\"\`)"
220
+ # The bare-`*` wildcard deliberately KEEPS the narrow (space/quote/end) boundary:
221
+ # admitting `)` there would misread a shell `case … in *)` default arm as a
222
+ # catastrophic `rm -rf *` (T4b F1). A genuinely substitution-wrapped bare `*`
223
+ # (`echo "$(rm -rf *)"`) is instead caught by the token-walk (guard 1b) below.
224
+ readonly RM_CATASTROPHIC_TARGET='([[:space:]='"$qc"'])((/|/\*|/\.\*?|~|~/\*?|\$HOME\b|\$\{HOME\})([[:space:]'"$tc"']|/?\*?['"$tc"']?$)|\*([[:space:]'"$qc"']|/?\*?['"$qc"']?$))'
210
225
 
211
226
  # 1b. rm target hardening (issue #1960). For every statement that invokes rm
212
227
  # with recursive+force flags, additionally block when:
@@ -224,6 +239,45 @@ project_dir="${CLAUDE_PROJECT_DIR:-$PWD}"
224
239
  tmp_dir_allow="${TMPDIR:-/tmp}"
225
240
  tmp_dir_allow="${tmp_dir_allow%/}"
226
241
  [ -n "$tmp_dir_allow" ] || tmp_dir_allow="/tmp"
242
+ # Peel command-substitution wrappers off a token so an rm nested in `$(…)`,
243
+ # backticks, `<(…)`/`>(…)`, a `"…"`/`'…'` quote, or a leading `\` alias-bypass
244
+ # (`\rm`) is recognized and its target classified as if the token were unwrapped
245
+ # (issue #1982) — substitution-wrapping is verdict-neutral for the rm guard.
246
+ # Leading wrappers (\ $( ` ( <( >( and quotes) and trailing closers () ` and
247
+ # quotes) are stripped in runs, so `"$(\rm` → `rm` and `/etc)"` → `/etc`. `$((`
248
+ # is ARITHMETIC, never command substitution: the LEADING peel stops at it (its
249
+ # case is ordered first), so the inner expression is never exposed as a command
250
+ # or a target. The trailing loop may still trim a closing `))`, but that is
251
+ # harmless — an arithmetic token like `$((10/2))` still keeps its `$` for the
252
+ # variable-target guard and can never be mis-normalized into an rm or a `/`-target.
253
+ strip_subst_wrappers() {
254
+ local t="$1" prev=""
255
+ while [ "$t" != "$prev" ]; do
256
+ prev="$t"
257
+ case "$t" in
258
+ '$(('*) break ;;
259
+ '\'*) t="${t#\\}" ;;
260
+ '$('*) t="${t#'$('}" ;;
261
+ '<('*) t="${t#'<('}" ;;
262
+ '>('*) t="${t#'>('}" ;;
263
+ '"'*) t="${t#'"'}" ;;
264
+ "'"*) t="${t#\'}" ;;
265
+ '`'*) t="${t#'`'}" ;;
266
+ '('*) t="${t#(}" ;;
267
+ esac
268
+ done
269
+ prev=""
270
+ while [ "$t" != "$prev" ]; do
271
+ prev="$t"
272
+ case "$t" in
273
+ *')') t="${t%)}" ;;
274
+ *'`') t="${t%'`'}" ;;
275
+ *'"') t="${t%'"'}" ;;
276
+ *"'") t="${t%\'}" ;;
277
+ esac
278
+ done
279
+ printf '%s' "$t"
280
+ }
227
281
  while IFS= read -r rm_stmt; do
228
282
  if ! printf '%s' "$rm_stmt" | grep -Eiq -- "$RM_RF_CLUSTER" \
229
283
  && ! printf '%s' "$rm_stmt" | grep -Eiq -- "$RM_RF_SPLIT"; then
@@ -242,10 +296,7 @@ while IFS= read -r rm_stmt; do
242
296
  set -f
243
297
  seen_rm=0
244
298
  for raw_token in $rm_stmt; do
245
- token="${raw_token#\"}"
246
- token="${token#\'}"
247
- token="${token%\"}"
248
- token="${token%\'}"
299
+ token="$(strip_subst_wrappers "$raw_token")"
249
300
  if [ "$seen_rm" -eq 0 ]; then
250
301
  # Path-prefixed spellings (`/bin/rm`, `./rm`) are still rm (F2).
251
302
  case "$token" in
@@ -276,6 +327,13 @@ while IFS= read -r rm_stmt; do
276
327
  ;;
277
328
  esac
278
329
  ;;
330
+ '*')
331
+ # Bare top-level wildcard expands to every entry in the cwd. Guard 1a no
332
+ # longer bounds `*)` (T4b F1), so a substitution-wrapped `rm -rf *` is
333
+ # caught here after the trailing-closer strip peels `*)"` down to `*`.
334
+ set +f
335
+ block "recursive forced delete of a top-level wildcard (rm -rf *)"
336
+ ;;
279
337
  *'$'*)
280
338
  case "$token" in
281
339
  '$TMPDIR' | '$TMPDIR'/* | '${TMPDIR}' | '${TMPDIR}'/*) : ;;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -98,7 +98,12 @@ is screened the same as `git <destructive>`.
98
98
  Malformed hook input fails **closed** (exit 2 denies the command). A text-scan
99
99
  hook cannot exempt display commands, so prose like
100
100
  `echo "docs about rm -rf /"` can false-positive — quote-break the string or use
101
- the gh-writer heredoc form (payload is stripped before the guards run).
101
+ the gh-writer heredoc form (payload is stripped before the guards run). For the
102
+ same reason the rm guard treats substitution-wrapping as verdict-neutral (issue
103
+ #1982): an executable `echo "$(rm -rf /)"` is blocked, and so are inert twins the
104
+ shell would never expand — a single-quoted `echo '$(rm -rf /)'` or an escaped
105
+ `echo "\$(rm -rf /)"` — since the scan has no quote-context awareness. The same
106
+ quote-break or heredoc workaround applies.
102
107
 
103
108
  ## View the current rules
104
109
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "AWS CDK-specific Lisa plugin.",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -48,8 +48,13 @@
48
48
  # Known accepted false-positive class: this is a text scan, not a shell engine,
49
49
  # so display commands quoting a destructive string (`echo "docs about rm -rf /"`)
50
50
  # can match. Upstream exempts those via an engine-only DISPLAY_COMMANDS list a
51
- # grep hook cannot replicate. Workaround: quote-break the string or use the
52
- # gh-writer heredoc form, whose payload is stripped before the guards run.
51
+ # grep hook cannot replicate. The same text-scan limit means the rm guard treats
52
+ # a substitution-wrapped catastrophic delete as verdict-neutral (issue #1982): an
53
+ # executable `echo "$(rm -rf /)"` is blocked, but so are inert twins the shell
54
+ # would never expand — a single-quoted `echo '$(rm -rf /)'` or an escaped
55
+ # `echo "\$(rm -rf /)"` — because the scan has no quote-context awareness. That
56
+ # over-block stays inside this accepted class. Workaround: quote-break the string
57
+ # or use the gh-writer heredoc form, whose payload is stripped before the guards run.
53
58
  #
54
59
  # Operators extend the built-in rules with a project-local rule file — one
55
60
  # extended-regex (ERE) per line, blank lines and `#` comments ignored — managed
@@ -206,7 +211,17 @@ readonly RM_RF_SPLIT="$RM_CMD"'(([[:space:]][^;&|]*)?[[:space:]](-[[:alnum:]]*r[
206
211
  # review S1): a harmless `/` in a LATER statement (`rm -rf build && cd /`)
207
212
  # is never attributed to the rm in an earlier one.
208
213
  qc="'\""
209
- readonly RM_CATASTROPHIC_TARGET='([[:space:]='"$qc"'])(/|/\*|/\.\*?|~|~/\*?|\$HOME\b|\$\{HOME\}|\*)([[:space:]'"$qc"']|/?\*?['"$qc"']?$)'
214
+ # Path/home targets also accept the command-substitution closers `)` and backtick
215
+ # as a trailing boundary (issue #1982): in `echo "$(rm -rf /)"` the target `/` is
216
+ # followed by `)`, not a space or quote, so without them an executable
217
+ # substitution-wrapped `rm -rf <root>` slips past this gate. Leading boundary is
218
+ # unchanged — the target is always space-separated from the recursive+force flag.
219
+ tc="'\"\`)"
220
+ # The bare-`*` wildcard deliberately KEEPS the narrow (space/quote/end) boundary:
221
+ # admitting `)` there would misread a shell `case … in *)` default arm as a
222
+ # catastrophic `rm -rf *` (T4b F1). A genuinely substitution-wrapped bare `*`
223
+ # (`echo "$(rm -rf *)"`) is instead caught by the token-walk (guard 1b) below.
224
+ readonly RM_CATASTROPHIC_TARGET='([[:space:]='"$qc"'])((/|/\*|/\.\*?|~|~/\*?|\$HOME\b|\$\{HOME\})([[:space:]'"$tc"']|/?\*?['"$tc"']?$)|\*([[:space:]'"$qc"']|/?\*?['"$qc"']?$))'
210
225
 
211
226
  # 1b. rm target hardening (issue #1960). For every statement that invokes rm
212
227
  # with recursive+force flags, additionally block when:
@@ -224,6 +239,45 @@ project_dir="${CLAUDE_PROJECT_DIR:-$PWD}"
224
239
  tmp_dir_allow="${TMPDIR:-/tmp}"
225
240
  tmp_dir_allow="${tmp_dir_allow%/}"
226
241
  [ -n "$tmp_dir_allow" ] || tmp_dir_allow="/tmp"
242
+ # Peel command-substitution wrappers off a token so an rm nested in `$(…)`,
243
+ # backticks, `<(…)`/`>(…)`, a `"…"`/`'…'` quote, or a leading `\` alias-bypass
244
+ # (`\rm`) is recognized and its target classified as if the token were unwrapped
245
+ # (issue #1982) — substitution-wrapping is verdict-neutral for the rm guard.
246
+ # Leading wrappers (\ $( ` ( <( >( and quotes) and trailing closers () ` and
247
+ # quotes) are stripped in runs, so `"$(\rm` → `rm` and `/etc)"` → `/etc`. `$((`
248
+ # is ARITHMETIC, never command substitution: the LEADING peel stops at it (its
249
+ # case is ordered first), so the inner expression is never exposed as a command
250
+ # or a target. The trailing loop may still trim a closing `))`, but that is
251
+ # harmless — an arithmetic token like `$((10/2))` still keeps its `$` for the
252
+ # variable-target guard and can never be mis-normalized into an rm or a `/`-target.
253
+ strip_subst_wrappers() {
254
+ local t="$1" prev=""
255
+ while [ "$t" != "$prev" ]; do
256
+ prev="$t"
257
+ case "$t" in
258
+ '$(('*) break ;;
259
+ '\'*) t="${t#\\}" ;;
260
+ '$('*) t="${t#'$('}" ;;
261
+ '<('*) t="${t#'<('}" ;;
262
+ '>('*) t="${t#'>('}" ;;
263
+ '"'*) t="${t#'"'}" ;;
264
+ "'"*) t="${t#\'}" ;;
265
+ '`'*) t="${t#'`'}" ;;
266
+ '('*) t="${t#(}" ;;
267
+ esac
268
+ done
269
+ prev=""
270
+ while [ "$t" != "$prev" ]; do
271
+ prev="$t"
272
+ case "$t" in
273
+ *')') t="${t%)}" ;;
274
+ *'`') t="${t%'`'}" ;;
275
+ *'"') t="${t%'"'}" ;;
276
+ *"'") t="${t%\'}" ;;
277
+ esac
278
+ done
279
+ printf '%s' "$t"
280
+ }
227
281
  while IFS= read -r rm_stmt; do
228
282
  if ! printf '%s' "$rm_stmt" | grep -Eiq -- "$RM_RF_CLUSTER" \
229
283
  && ! printf '%s' "$rm_stmt" | grep -Eiq -- "$RM_RF_SPLIT"; then
@@ -242,10 +296,7 @@ while IFS= read -r rm_stmt; do
242
296
  set -f
243
297
  seen_rm=0
244
298
  for raw_token in $rm_stmt; do
245
- token="${raw_token#\"}"
246
- token="${token#\'}"
247
- token="${token%\"}"
248
- token="${token%\'}"
299
+ token="$(strip_subst_wrappers "$raw_token")"
249
300
  if [ "$seen_rm" -eq 0 ]; then
250
301
  # Path-prefixed spellings (`/bin/rm`, `./rm`) are still rm (F2).
251
302
  case "$token" in
@@ -276,6 +327,13 @@ while IFS= read -r rm_stmt; do
276
327
  ;;
277
328
  esac
278
329
  ;;
330
+ '*')
331
+ # Bare top-level wildcard expands to every entry in the cwd. Guard 1a no
332
+ # longer bounds `*)` (T4b F1), so a substitution-wrapped `rm -rf *` is
333
+ # caught here after the trailing-closer strip peels `*)"` down to `*`.
334
+ set +f
335
+ block "recursive forced delete of a top-level wildcard (rm -rf *)"
336
+ ;;
279
337
  *'$'*)
280
338
  case "$token" in
281
339
  '$TMPDIR' | '$TMPDIR'/* | '${TMPDIR}' | '${TMPDIR}'/*) : ;;
@@ -98,7 +98,12 @@ is screened the same as `git <destructive>`.
98
98
  Malformed hook input fails **closed** (exit 2 denies the command). A text-scan
99
99
  hook cannot exempt display commands, so prose like
100
100
  `echo "docs about rm -rf /"` can false-positive — quote-break the string or use
101
- the gh-writer heredoc form (payload is stripped before the guards run).
101
+ the gh-writer heredoc form (payload is stripped before the guards run). For the
102
+ same reason the rm guard treats substitution-wrapping as verdict-neutral (issue
103
+ #1982): an executable `echo "$(rm -rf /)"` is blocked, and so are inert twins the
104
+ shell would never expand — a single-quoted `echo '$(rm -rf /)'` or an escaped
105
+ `echo "\$(rm -rf /)"` — since the scan has no quote-context awareness. The same
106
+ quote-break or heredoc workaround applies.
102
107
 
103
108
  ## View the current rules
104
109
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa",
3
- "version": "2.297.2",
3
+ "version": "2.297.3",
4
4
  "description": "Universal governance — agents, skills, commands, hooks, and rules for all projects",
5
5
  "author": {
6
6
  "name": "Cody Swann"