@cybedefend/vibedefend 1.8.3 → 1.9.0

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 (320) hide show
  1. package/README.md +135 -16
  2. package/dist/clients/antigravity.js +30 -6
  3. package/dist/clients/antigravity.js.map +1 -1
  4. package/dist/clients/claude-code.js +209 -17
  5. package/dist/clients/claude-code.js.map +1 -1
  6. package/dist/clients/codex.js +171 -11
  7. package/dist/clients/codex.js.map +1 -1
  8. package/dist/clients/cursor.js +149 -9
  9. package/dist/clients/cursor.js.map +1 -1
  10. package/dist/clients/dependency-check-wiring.js +24 -0
  11. package/dist/clients/dependency-check-wiring.js.map +1 -0
  12. package/dist/clients/opencode-plugin.js +905 -0
  13. package/dist/clients/opencode-plugin.js.map +1 -0
  14. package/dist/clients/opencode.js +653 -0
  15. package/dist/clients/opencode.js.map +1 -0
  16. package/dist/clients/registry.js +2 -0
  17. package/dist/clients/registry.js.map +1 -1
  18. package/dist/clients/vscode.js +106 -12
  19. package/dist/clients/vscode.js.map +1 -1
  20. package/dist/clients/windsurf.js +9 -1
  21. package/dist/clients/windsurf.js.map +1 -1
  22. package/dist/commands/mcp/index.js +11 -0
  23. package/dist/commands/mcp/index.js.map +1 -1
  24. package/dist/config.js +3 -0
  25. package/dist/config.js.map +1 -1
  26. package/dist/diagnostics.js +22 -3
  27. package/dist/diagnostics.js.map +1 -1
  28. package/dist/doctor.js +26 -1
  29. package/dist/doctor.js.map +1 -1
  30. package/dist/guards-evaluator/command-analysis.js +347 -86
  31. package/dist/guards-evaluator/command-analysis.js.map +1 -1
  32. package/dist/guards-evaluator/command-view.js +116 -16
  33. package/dist/guards-evaluator/command-view.js.map +1 -1
  34. package/dist/guards-evaluator/evaluate.js +185 -41
  35. package/dist/guards-evaluator/evaluate.js.map +1 -1
  36. package/dist/guards-evaluator/file-reads.js +202 -0
  37. package/dist/guards-evaluator/file-reads.js.map +1 -0
  38. package/dist/guards-evaluator/index.js +1 -1
  39. package/dist/guards-evaluator/index.js.map +1 -1
  40. package/dist/guards-evaluator/inline-danger.js +299 -0
  41. package/dist/guards-evaluator/inline-danger.js.map +1 -0
  42. package/dist/guards-evaluator/normalize.js +1186 -55
  43. package/dist/guards-evaluator/normalize.js.map +1 -1
  44. package/dist/guards-evaluator/regex.js +91 -4
  45. package/dist/guards-evaluator/regex.js.map +1 -1
  46. package/dist/guards-evaluator/shell-files.js +587 -0
  47. package/dist/guards-evaluator/shell-files.js.map +1 -0
  48. package/dist/guards-evaluator/triage.js +32 -2
  49. package/dist/guards-evaluator/triage.js.map +1 -1
  50. package/dist/hook-runner.js +25598 -5432
  51. package/dist/hooks/install.js +8 -3
  52. package/dist/hooks/install.js.map +1 -1
  53. package/dist/hooks/runtime/antigravity-session.js +109 -50
  54. package/dist/hooks/runtime/antigravity-session.js.map +1 -1
  55. package/dist/hooks/runtime/apply-patch.js +92 -0
  56. package/dist/hooks/runtime/apply-patch.js.map +1 -0
  57. package/dist/hooks/runtime/caller-gate.js +27 -0
  58. package/dist/hooks/runtime/caller-gate.js.map +1 -0
  59. package/dist/hooks/runtime/code-mode.js +259 -0
  60. package/dist/hooks/runtime/code-mode.js.map +1 -0
  61. package/dist/hooks/runtime/dependency-check/api.js +179 -0
  62. package/dist/hooks/runtime/dependency-check/api.js.map +1 -0
  63. package/dist/hooks/runtime/dependency-check/capabilities.js +99 -0
  64. package/dist/hooks/runtime/dependency-check/capabilities.js.map +1 -0
  65. package/dist/hooks/runtime/dependency-check/checked-packages.js +48 -0
  66. package/dist/hooks/runtime/dependency-check/checked-packages.js.map +1 -0
  67. package/dist/hooks/runtime/dependency-check/commands/cwd.js +154 -0
  68. package/dist/hooks/runtime/dependency-check/commands/cwd.js.map +1 -0
  69. package/dist/hooks/runtime/dependency-check/commands/env.js +99 -0
  70. package/dist/hooks/runtime/dependency-check/commands/env.js.map +1 -0
  71. package/dist/hooks/runtime/dependency-check/commands/flags.js +164 -0
  72. package/dist/hooks/runtime/dependency-check/commands/flags.js.map +1 -0
  73. package/dist/hooks/runtime/dependency-check/commands/managers.js +418 -0
  74. package/dist/hooks/runtime/dependency-check/commands/managers.js.map +1 -0
  75. package/dist/hooks/runtime/dependency-check/commands/peel.js +111 -0
  76. package/dist/hooks/runtime/dependency-check/commands/peel.js.map +1 -0
  77. package/dist/hooks/runtime/dependency-check/commands/shell.js +217 -0
  78. package/dist/hooks/runtime/dependency-check/commands/shell.js.map +1 -0
  79. package/dist/hooks/runtime/dependency-check/commands/types.js +4 -0
  80. package/dist/hooks/runtime/dependency-check/commands/types.js.map +1 -0
  81. package/dist/hooks/runtime/dependency-check/commands.js +34 -0
  82. package/dist/hooks/runtime/dependency-check/commands.js.map +1 -0
  83. package/dist/hooks/runtime/dependency-check/deadlines.js +69 -0
  84. package/dist/hooks/runtime/dependency-check/deadlines.js.map +1 -0
  85. package/dist/hooks/runtime/dependency-check/dispatch.js +344 -0
  86. package/dist/hooks/runtime/dependency-check/dispatch.js.map +1 -0
  87. package/dist/hooks/runtime/dependency-check/entering.js +63 -0
  88. package/dist/hooks/runtime/dependency-check/entering.js.map +1 -0
  89. package/dist/hooks/runtime/dependency-check/exec-cache.js +36 -0
  90. package/dist/hooks/runtime/dependency-check/exec-cache.js.map +1 -0
  91. package/dist/hooks/runtime/dependency-check/git-blob.js +116 -0
  92. package/dist/hooks/runtime/dependency-check/git-blob.js.map +1 -0
  93. package/dist/hooks/runtime/dependency-check/hook.js +418 -0
  94. package/dist/hooks/runtime/dependency-check/hook.js.map +1 -0
  95. package/dist/hooks/runtime/dependency-check/local-store.js +74 -0
  96. package/dist/hooks/runtime/dependency-check/local-store.js.map +1 -0
  97. package/dist/hooks/runtime/dependency-check/lockfile-walk.js +89 -0
  98. package/dist/hooks/runtime/dependency-check/lockfile-walk.js.map +1 -0
  99. package/dist/hooks/runtime/dependency-check/lockfiles/bun.js +153 -0
  100. package/dist/hooks/runtime/dependency-check/lockfiles/bun.js.map +1 -0
  101. package/dist/hooks/runtime/dependency-check/lockfiles/by-name.js +46 -0
  102. package/dist/hooks/runtime/dependency-check/lockfiles/by-name.js.map +1 -0
  103. package/dist/hooks/runtime/dependency-check/lockfiles/cargo.js +91 -0
  104. package/dist/hooks/runtime/dependency-check/lockfiles/cargo.js.map +1 -0
  105. package/dist/hooks/runtime/dependency-check/lockfiles/composer.js +98 -0
  106. package/dist/hooks/runtime/dependency-check/lockfiles/composer.js.map +1 -0
  107. package/dist/hooks/runtime/dependency-check/lockfiles/gemfile.js +88 -0
  108. package/dist/hooks/runtime/dependency-check/lockfiles/gemfile.js.map +1 -0
  109. package/dist/hooks/runtime/dependency-check/lockfiles/go-mod.js +154 -0
  110. package/dist/hooks/runtime/dependency-check/lockfiles/go-mod.js.map +1 -0
  111. package/dist/hooks/runtime/dependency-check/lockfiles/gradle-lockfile.js +27 -0
  112. package/dist/hooks/runtime/dependency-check/lockfiles/gradle-lockfile.js.map +1 -0
  113. package/dist/hooks/runtime/dependency-check/lockfiles/graph.js +131 -0
  114. package/dist/hooks/runtime/dependency-check/lockfiles/graph.js.map +1 -0
  115. package/dist/hooks/runtime/dependency-check/lockfiles/npm.js +107 -0
  116. package/dist/hooks/runtime/dependency-check/lockfiles/npm.js.map +1 -0
  117. package/dist/hooks/runtime/dependency-check/lockfiles/nuget-packages-lock.js +60 -0
  118. package/dist/hooks/runtime/dependency-check/lockfiles/nuget-packages-lock.js.map +1 -0
  119. package/dist/hooks/runtime/dependency-check/lockfiles/pins.js +105 -0
  120. package/dist/hooks/runtime/dependency-check/lockfiles/pins.js.map +1 -0
  121. package/dist/hooks/runtime/dependency-check/lockfiles/pip-report.js +34 -0
  122. package/dist/hooks/runtime/dependency-check/lockfiles/pip-report.js.map +1 -0
  123. package/dist/hooks/runtime/dependency-check/lockfiles/pnpm.js +109 -0
  124. package/dist/hooks/runtime/dependency-check/lockfiles/pnpm.js.map +1 -0
  125. package/dist/hooks/runtime/dependency-check/lockfiles/poetry.js +105 -0
  126. package/dist/hooks/runtime/dependency-check/lockfiles/poetry.js.map +1 -0
  127. package/dist/hooks/runtime/dependency-check/lockfiles/uv.js +181 -0
  128. package/dist/hooks/runtime/dependency-check/lockfiles/uv.js.map +1 -0
  129. package/dist/hooks/runtime/dependency-check/lockfiles/yaml.js +319 -0
  130. package/dist/hooks/runtime/dependency-check/lockfiles/yaml.js.map +1 -0
  131. package/dist/hooks/runtime/dependency-check/lockfiles/yarn-berry.js +71 -0
  132. package/dist/hooks/runtime/dependency-check/lockfiles/yarn-berry.js.map +1 -0
  133. package/dist/hooks/runtime/dependency-check/lockfiles/yarn1.js +144 -0
  134. package/dist/hooks/runtime/dependency-check/lockfiles/yarn1.js.map +1 -0
  135. package/dist/hooks/runtime/dependency-check/manifests/apply.js +110 -0
  136. package/dist/hooks/runtime/dependency-check/manifests/apply.js.map +1 -0
  137. package/dist/hooks/runtime/dependency-check/manifests/diff.js +127 -0
  138. package/dist/hooks/runtime/dependency-check/manifests/diff.js.map +1 -0
  139. package/dist/hooks/runtime/dependency-check/manifests/edit.js +259 -0
  140. package/dist/hooks/runtime/dependency-check/manifests/edit.js.map +1 -0
  141. package/dist/hooks/runtime/dependency-check/manifests/json.js +109 -0
  142. package/dist/hooks/runtime/dependency-check/manifests/json.js.map +1 -0
  143. package/dist/hooks/runtime/dependency-check/manifests/kind.js +40 -0
  144. package/dist/hooks/runtime/dependency-check/manifests/kind.js.map +1 -0
  145. package/dist/hooks/runtime/dependency-check/manifests/patch.js +179 -0
  146. package/dist/hooks/runtime/dependency-check/manifests/patch.js.map +1 -0
  147. package/dist/hooks/runtime/dependency-check/manifests/text.js +665 -0
  148. package/dist/hooks/runtime/dependency-check/manifests/text.js.map +1 -0
  149. package/dist/hooks/runtime/dependency-check/manifests/toml.js +350 -0
  150. package/dist/hooks/runtime/dependency-check/manifests/toml.js.map +1 -0
  151. package/dist/hooks/runtime/dependency-check/manifests.js +14 -0
  152. package/dist/hooks/runtime/dependency-check/manifests.js.map +1 -0
  153. package/dist/hooks/runtime/dependency-check/messages.js +270 -0
  154. package/dist/hooks/runtime/dependency-check/messages.js.map +1 -0
  155. package/dist/hooks/runtime/dependency-check/net-baseline.js +157 -0
  156. package/dist/hooks/runtime/dependency-check/net-baseline.js.map +1 -0
  157. package/dist/hooks/runtime/dependency-check/net-state.js +70 -0
  158. package/dist/hooks/runtime/dependency-check/net-state.js.map +1 -0
  159. package/dist/hooks/runtime/dependency-check/pending-forces.js +54 -0
  160. package/dist/hooks/runtime/dependency-check/pending-forces.js.map +1 -0
  161. package/dist/hooks/runtime/dependency-check/post-tool-use.js +108 -0
  162. package/dist/hooks/runtime/dependency-check/post-tool-use.js.map +1 -0
  163. package/dist/hooks/runtime/dependency-check/ranges.js +369 -0
  164. package/dist/hooks/runtime/dependency-check/ranges.js.map +1 -0
  165. package/dist/hooks/runtime/dependency-check/requirement-files.js +144 -0
  166. package/dist/hooks/runtime/dependency-check/requirement-files.js.map +1 -0
  167. package/dist/hooks/runtime/dependency-check/resolvers/bun.js +38 -0
  168. package/dist/hooks/runtime/dependency-check/resolvers/bun.js.map +1 -0
  169. package/dist/hooks/runtime/dependency-check/resolvers/bundler.js +218 -0
  170. package/dist/hooks/runtime/dependency-check/resolvers/bundler.js.map +1 -0
  171. package/dist/hooks/runtime/dependency-check/resolvers/cargo.js +303 -0
  172. package/dist/hooks/runtime/dependency-check/resolvers/cargo.js.map +1 -0
  173. package/dist/hooks/runtime/dependency-check/resolvers/composer.js +250 -0
  174. package/dist/hooks/runtime/dependency-check/resolvers/composer.js.map +1 -0
  175. package/dist/hooks/runtime/dependency-check/resolvers/config-files.js +27 -0
  176. package/dist/hooks/runtime/dependency-check/resolvers/config-files.js.map +1 -0
  177. package/dist/hooks/runtime/dependency-check/resolvers/direct-only-registry.js +409 -0
  178. package/dist/hooks/runtime/dependency-check/resolvers/direct-only-registry.js.map +1 -0
  179. package/dist/hooks/runtime/dependency-check/resolvers/direct-only.js +290 -0
  180. package/dist/hooks/runtime/dependency-check/resolvers/direct-only.js.map +1 -0
  181. package/dist/hooks/runtime/dependency-check/resolvers/gem.js +89 -0
  182. package/dist/hooks/runtime/dependency-check/resolvers/gem.js.map +1 -0
  183. package/dist/hooks/runtime/dependency-check/resolvers/go.js +313 -0
  184. package/dist/hooks/runtime/dependency-check/resolvers/go.js.map +1 -0
  185. package/dist/hooks/runtime/dependency-check/resolvers/npm.js +81 -0
  186. package/dist/hooks/runtime/dependency-check/resolvers/npm.js.map +1 -0
  187. package/dist/hooks/runtime/dependency-check/resolvers/pip.js +229 -0
  188. package/dist/hooks/runtime/dependency-check/resolvers/pip.js.map +1 -0
  189. package/dist/hooks/runtime/dependency-check/resolvers/pipx.js +8 -0
  190. package/dist/hooks/runtime/dependency-check/resolvers/pipx.js.map +1 -0
  191. package/dist/hooks/runtime/dependency-check/resolvers/pnpm.js +68 -0
  192. package/dist/hooks/runtime/dependency-check/resolvers/pnpm.js.map +1 -0
  193. package/dist/hooks/runtime/dependency-check/resolvers/poetry.js +70 -0
  194. package/dist/hooks/runtime/dependency-check/resolvers/poetry.js.map +1 -0
  195. package/dist/hooks/runtime/dependency-check/resolvers/project.js +208 -0
  196. package/dist/hooks/runtime/dependency-check/resolvers/project.js.map +1 -0
  197. package/dist/hooks/runtime/dependency-check/resolvers/python-index.js +270 -0
  198. package/dist/hooks/runtime/dependency-check/resolvers/python-index.js.map +1 -0
  199. package/dist/hooks/runtime/dependency-check/resolvers/python.js +229 -0
  200. package/dist/hooks/runtime/dependency-check/resolvers/python.js.map +1 -0
  201. package/dist/hooks/runtime/dependency-check/resolvers/registry.js +221 -0
  202. package/dist/hooks/runtime/dependency-check/resolvers/registry.js.map +1 -0
  203. package/dist/hooks/runtime/dependency-check/resolvers/shared.js +440 -0
  204. package/dist/hooks/runtime/dependency-check/resolvers/shared.js.map +1 -0
  205. package/dist/hooks/runtime/dependency-check/resolvers/tree.js +131 -0
  206. package/dist/hooks/runtime/dependency-check/resolvers/tree.js.map +1 -0
  207. package/dist/hooks/runtime/dependency-check/resolvers/uv.js +433 -0
  208. package/dist/hooks/runtime/dependency-check/resolvers/uv.js.map +1 -0
  209. package/dist/hooks/runtime/dependency-check/resolvers/xml-lite.js +132 -0
  210. package/dist/hooks/runtime/dependency-check/resolvers/xml-lite.js.map +1 -0
  211. package/dist/hooks/runtime/dependency-check/resolvers/yarn-berry.js +106 -0
  212. package/dist/hooks/runtime/dependency-check/resolvers/yarn-berry.js.map +1 -0
  213. package/dist/hooks/runtime/dependency-check/sandbox.js +328 -0
  214. package/dist/hooks/runtime/dependency-check/sandbox.js.map +1 -0
  215. package/dist/hooks/runtime/dependency-check/specs.js +171 -0
  216. package/dist/hooks/runtime/dependency-check/specs.js.map +1 -0
  217. package/dist/hooks/runtime/dependency-check/static-view.js +90 -0
  218. package/dist/hooks/runtime/dependency-check/static-view.js.map +1 -0
  219. package/dist/hooks/runtime/dependency-check/stop-net.js +278 -0
  220. package/dist/hooks/runtime/dependency-check/stop-net.js.map +1 -0
  221. package/dist/hooks/runtime/dependency-check/stop-wiring.js +94 -0
  222. package/dist/hooks/runtime/dependency-check/stop-wiring.js.map +1 -0
  223. package/dist/hooks/runtime/dependency-check/tool-call.js +130 -0
  224. package/dist/hooks/runtime/dependency-check/tool-call.js.map +1 -0
  225. package/dist/hooks/runtime/dependency-check/types.js +96 -0
  226. package/dist/hooks/runtime/dependency-check/types.js.map +1 -0
  227. package/dist/hooks/runtime/emit.js +240 -52
  228. package/dist/hooks/runtime/emit.js.map +1 -1
  229. package/dist/hooks/runtime/exit-deadlock-guard.js +24 -8
  230. package/dist/hooks/runtime/exit-deadlock-guard.js.map +1 -1
  231. package/dist/hooks/runtime/fetch-rules.js +78 -29
  232. package/dist/hooks/runtime/fetch-rules.js.map +1 -1
  233. package/dist/hooks/runtime/grep-include.js +228 -0
  234. package/dist/hooks/runtime/grep-include.js.map +1 -0
  235. package/dist/hooks/runtime/pre-compact.js +1 -1
  236. package/dist/hooks/runtime/pre-compact.js.map +1 -1
  237. package/dist/hooks/runtime/pre-invocation.js +3 -3
  238. package/dist/hooks/runtime/pre-invocation.js.map +1 -1
  239. package/dist/hooks/runtime/repo-registry.js +72 -0
  240. package/dist/hooks/runtime/repo-registry.js.map +1 -0
  241. package/dist/hooks/runtime/repo-scope.js +75 -0
  242. package/dist/hooks/runtime/repo-scope.js.map +1 -0
  243. package/dist/hooks/runtime/resolve.js +11 -2
  244. package/dist/hooks/runtime/resolve.js.map +1 -1
  245. package/dist/hooks/runtime/runner-args.js +17 -2
  246. package/dist/hooks/runtime/runner-args.js.map +1 -1
  247. package/dist/hooks/runtime/script-resolve.js +21 -5
  248. package/dist/hooks/runtime/script-resolve.js.map +1 -1
  249. package/dist/hooks/runtime/session-activation.js +71 -18
  250. package/dist/hooks/runtime/session-activation.js.map +1 -1
  251. package/dist/hooks/runtime/session-review.js +136 -66
  252. package/dist/hooks/runtime/session-review.js.map +1 -1
  253. package/dist/hooks/runtime/session-start.js +68 -13
  254. package/dist/hooks/runtime/session-start.js.map +1 -1
  255. package/dist/hooks/runtime/session-writes.js +11 -5
  256. package/dist/hooks/runtime/session-writes.js.map +1 -1
  257. package/dist/hooks/runtime/shell-writes.js +7 -88
  258. package/dist/hooks/runtime/shell-writes.js.map +1 -1
  259. package/dist/hooks/runtime/sniff.js +227 -2
  260. package/dist/hooks/runtime/sniff.js.map +1 -1
  261. package/dist/hooks/runtime/target-resolve.js +32 -17
  262. package/dist/hooks/runtime/target-resolve.js.map +1 -1
  263. package/dist/hooks/runtime/unmapped-tools.js +77 -1
  264. package/dist/hooks/runtime/unmapped-tools.js.map +1 -1
  265. package/dist/hooks/runtime/user-prompt-submit.js +1 -1
  266. package/dist/hooks/runtime/user-prompt-submit.js.map +1 -1
  267. package/dist/hooks/runtime/work-dir.js +3 -0
  268. package/dist/hooks/runtime/work-dir.js.map +1 -1
  269. package/dist/hooks/shim.js +27 -20
  270. package/dist/hooks/shim.js.map +1 -1
  271. package/dist/index.js +40 -3
  272. package/dist/index.js.map +1 -1
  273. package/dist/install-scope.js +12 -0
  274. package/dist/install-scope.js.map +1 -0
  275. package/dist/install.js +188 -78
  276. package/dist/install.js.map +1 -1
  277. package/dist/link.js +55 -5
  278. package/dist/link.js.map +1 -1
  279. package/dist/mcp/config/hook.js +25 -0
  280. package/dist/mcp/config/hook.js.map +1 -1
  281. package/dist/org.js +3 -1
  282. package/dist/org.js.map +1 -1
  283. package/dist/prompts.js +96 -12
  284. package/dist/prompts.js.map +1 -1
  285. package/dist/refresh-hooks.js +67 -15
  286. package/dist/refresh-hooks.js.map +1 -1
  287. package/dist/repo/exclude-block.js +112 -0
  288. package/dist/repo/exclude-block.js.map +1 -0
  289. package/dist/repo/footer.js +93 -0
  290. package/dist/repo/footer.js.map +1 -0
  291. package/dist/repo/git-repo.js +77 -0
  292. package/dist/repo/git-repo.js.map +1 -0
  293. package/dist/repo/guarded-write.js +45 -0
  294. package/dist/repo/guarded-write.js.map +1 -0
  295. package/dist/repo/install-repo.js +508 -0
  296. package/dist/repo/install-repo.js.map +1 -0
  297. package/dist/repo/machine-wiring.js +122 -0
  298. package/dist/repo/machine-wiring.js.map +1 -0
  299. package/dist/repo/mcp-json.js +57 -0
  300. package/dist/repo/mcp-json.js.map +1 -0
  301. package/dist/repo/registry.js +53 -0
  302. package/dist/repo/registry.js.map +1 -0
  303. package/dist/repo/repo-mode-guard.js +83 -0
  304. package/dist/repo/repo-mode-guard.js.map +1 -0
  305. package/dist/repo/repo-setups.js +123 -0
  306. package/dist/repo/repo-setups.js.map +1 -0
  307. package/dist/repo/repo-status.js +283 -0
  308. package/dist/repo/repo-status.js.map +1 -0
  309. package/dist/repo/uninstall-repo.js +56 -0
  310. package/dist/repo/uninstall-repo.js.map +1 -0
  311. package/dist/repo/unsupported.js +14 -0
  312. package/dist/repo/unsupported.js.map +1 -0
  313. package/dist/shim.js +9 -7
  314. package/dist/status.js +53 -11
  315. package/dist/status.js.map +1 -1
  316. package/dist/uninstall.js +51 -3
  317. package/dist/uninstall.js.map +1 -1
  318. package/dist/update.js +6 -1
  319. package/dist/update.js.map +1 -1
  320. package/package.json +5 -2
@@ -24,9 +24,12 @@
24
24
  * measurement; keeping the orchestration here means both see the same verdict.
25
25
  */
26
26
  import { parse as shellParse } from 'shell-quote';
27
- import { evaluate } from './evaluate.js';
27
+ import { evaluate, MAX_TARGET_BYTES, COMMAND_TOO_LONG } from './evaluate.js';
28
+ import { evaluateFileRead, evaluateFileWrite } from './file-reads.js';
28
29
  import { extractInlineCode } from './inline-code.js';
29
- import { normalizeCommand } from './normalize.js';
30
+ import { codeDanger, shellCommandsInCode } from './inline-danger.js';
31
+ import { canonicalExec, normalizeCommand } from './normalize.js';
32
+ import { shellFileAccess } from './shell-files.js';
30
33
  import { isCatastrophicPathArg, triageCommand } from './triage.js';
31
34
  const SEVERITY_RANK = {
32
35
  critical: 4,
@@ -37,6 +40,10 @@ const SEVERITY_RANK = {
37
40
  const VERDICT_RANK = { deny: 3, warn: 2, allow: 1 };
38
41
  /** Shell operators that end a simple command segment. */
39
42
  const SEGMENT_OPS = new Set([';', '&&', '||', '|', '|&', '&', '(', ')']);
43
+ /** Redirect operators; the next token is a file, not the command. */
44
+ const REDIRECT_OPS = new Set(['>', '>>', '<', '>|', '&>', '&>>', '<>', '>&', '<&', '<<<', '<<', '<<-']);
45
+ /** Input redirects: a segment with one of these and no command word reads that file. */
46
+ const INPUT_REDIRECT_OPS = new Set(['<', '<>', '<<<']);
40
47
  /** Leading wrappers that don't change what runs; skipped to expose the real exe. */
41
48
  const TRANSPARENT_PREFIXES = new Set([
42
49
  'sudo', 'doas', 'nohup', 'command', 'time', 'nice', 'stdbuf', 'setsid', 'env',
@@ -50,14 +57,19 @@ const LONG_TO_SHORT = {
50
57
  chown: { recursive: 'R' },
51
58
  };
52
59
  const MAX_FORMS = 64;
53
- function canonicalExecutable(token) {
54
- // strip a single leading backslash (`\rm`), take the basename, lower-case.
55
- const noEsc = token.startsWith('\\') ? token.slice(1) : token;
56
- const base = noEsc.split('/').pop() ?? noEsc;
57
- return base.toLowerCase();
58
- }
59
- /** Stronger of two decisions: deny > warn > allow; ties broken by severity. */
60
+ /** The executable name the normalizer gives (`\rm`, `/bin/rm`, `git.exe`). */
61
+ const canonicalExecutable = canonicalExec;
62
+ /**
63
+ * Stronger of two decisions: deny > warn > allow; ties broken by severity. A
64
+ * failed-closed deny beats everything and stays as it is: with a rule's id
65
+ * merged in, the judge step would be asked to clear it. The mark counts on a
66
+ * deny only, so nothing that lost its deny can outrank one.
67
+ */
60
68
  function strongest(a, b) {
69
+ if (a.failedClosed && a.verdict === 'deny')
70
+ return a;
71
+ if (b.failedClosed && b.verdict === 'deny')
72
+ return b;
61
73
  const av = VERDICT_RANK[a.verdict];
62
74
  const bv = VERDICT_RANK[b.verdict];
63
75
  if (bv > av)
@@ -73,44 +85,6 @@ function mergeMatched(primary, other) {
73
85
  const ids = [...new Set([...primary.matchedRuleIds, ...other.matchedRuleIds])];
74
86
  return { ...primary, matchedRuleIds: ids };
75
87
  }
76
- /**
77
- * Split a raw command line into ordered token segments. Each segment keeps its
78
- * tokens in ORIGINAL order (no reordering) so argument masking downstream still
79
- * works. `$VAR` is preserved (never substituted to empty). Op objects and the
80
- * argv path's bare-string ops both split a segment.
81
- */
82
- function tokenSegments(raw) {
83
- let tokens;
84
- try {
85
- tokens = shellParse(raw, (k) => '$' + k);
86
- }
87
- catch {
88
- return [raw.split(/\s+/).filter(Boolean)];
89
- }
90
- const segments = [];
91
- let current = [];
92
- for (const tok of tokens) {
93
- if (typeof tok === 'object' && 'op' in tok) {
94
- if (current.length)
95
- segments.push(current);
96
- current = [];
97
- continue;
98
- }
99
- if (typeof tok === 'string') {
100
- if (SEGMENT_OPS.has(tok)) {
101
- if (current.length)
102
- segments.push(current);
103
- current = [];
104
- continue;
105
- }
106
- current.push(tok);
107
- }
108
- // patterns/comments: ignore for canonical evaluation (the raw form still runs)
109
- }
110
- if (current.length)
111
- segments.push(current);
112
- return segments;
113
- }
114
88
  /** Drop leading `VAR=value` assignments and transparent wrappers to expose the real exe. */
115
89
  function stripLeading(tokens) {
116
90
  let i = 0;
@@ -176,10 +150,113 @@ function canonicalizeSegment(tokens) {
176
150
  const argv = rest.map((t) => t); // in-place, order + quote boundaries preserved
177
151
  return { command: exe, argv };
178
152
  }
179
- function evaluateCommandForm(rules, req, command, argv) {
180
- const target = { type: 'command', command, argv, cwd: req.cwd };
153
+ /** A word as a shell reads it back: quoted when a blank or an operator would split it. */
154
+ function requote(word) {
155
+ if (/^[A-Za-z0-9_@%+=:,.\/~^$*?[\]{}!#-]+$/.test(word))
156
+ return word;
157
+ if (!word.includes("'"))
158
+ return `'${word}'`;
159
+ return `"${word.replace(/[\\"]/g, '\\$&')}"`;
160
+ }
161
+ /**
162
+ * Evaluate one form of a command, given word by word. The words are put back
163
+ * into a command line (each one quoted where it needs to be) so the rules read
164
+ * it through the command views, exactly as they read what the agent typed: a
165
+ * quoted string stays data, an agent scratch directory is not `/tmp`.
166
+ */
167
+ function evaluateCommandForm(rules, req, words) {
168
+ const target = {
169
+ type: 'command',
170
+ command: words[0] ?? '',
171
+ argv: words.slice(1),
172
+ cwd: req.cwd,
173
+ raw: words.map(requote).join(' '),
174
+ };
181
175
  return evaluate(rules, { ...req, target });
182
176
  }
177
+ /** The request for a command found inside another (a script line, a string given to a shell). */
178
+ function innerCommandRequest(req, command) {
179
+ let words;
180
+ try {
181
+ words = shellParse(command, (k) => '$' + k).filter((t) => typeof t === 'string');
182
+ }
183
+ catch {
184
+ words = command.split(/\s+/).filter(Boolean);
185
+ }
186
+ return {
187
+ ...req,
188
+ target: { type: 'command', command: words[0] ?? '', argv: words.slice(1), cwd: req.cwd, raw: command },
189
+ };
190
+ }
191
+ /**
192
+ * The forms of one recovered command the rules are asked about: its canonical
193
+ * form (executable by name, `--recursive --force` as `-rf`, wrappers dropped),
194
+ * and for a command found inside another (`bash -c "sudo …"`) the words as
195
+ * they were written, so a wrapper such as `sudo` is still seen.
196
+ */
197
+ function formsOfCommand(cmd) {
198
+ const words = cmd.argv && cmd.argv.length > 0 ? cmd.argv : cmd.raw.split(/\s+/).filter(Boolean);
199
+ if (words.length === 0)
200
+ return [];
201
+ const forms = [];
202
+ const at = cmd.executable === '' ? -1 : words.findIndex((w) => canonicalExecutable(w) === cmd.executable);
203
+ if (at >= 0) {
204
+ const canon = canonicalizeSegment([cmd.executable, ...words.slice(at + 1)]);
205
+ if (canon)
206
+ forms.push([canon.command, ...canon.argv]);
207
+ }
208
+ if (cmd.depth > 0 && at !== 0)
209
+ forms.push(words);
210
+ return forms;
211
+ }
212
+ /**
213
+ * Files a bare input redirection reads: a segment with an input redirect
214
+ * (`< f`, `<> f`, `<<< f`) and NO command word runs no program but reads the
215
+ * file, as `cat f` does (`$(< .env)`, a top-level `< .env`). The secret-read
216
+ * rules key on a command verb, so the guard evaluates `cat <file>` for each so
217
+ * the SAME rules fire — no new rule. Output redirect targets are not reads.
218
+ */
219
+ function inputRedirectReads(text) {
220
+ let tokens;
221
+ try {
222
+ tokens = shellParse(text, (k) => '$' + k);
223
+ }
224
+ catch {
225
+ return [];
226
+ }
227
+ const reads = [];
228
+ let hasCommand = false;
229
+ let read = null;
230
+ let pending = null;
231
+ const flush = () => {
232
+ if (!hasCommand && read !== null)
233
+ reads.push(read);
234
+ hasCommand = false;
235
+ read = null;
236
+ pending = null;
237
+ };
238
+ for (const tok of tokens) {
239
+ if (typeof tok === 'object' && tok !== null && 'op' in tok) {
240
+ if (SEGMENT_OPS.has(tok.op))
241
+ flush();
242
+ else if (REDIRECT_OPS.has(tok.op))
243
+ pending = INPUT_REDIRECT_OPS.has(tok.op) ? 'input' : 'other';
244
+ continue;
245
+ }
246
+ const s = typeof tok === 'string' ? tok : typeof tok === 'object' && tok !== null && 'pattern' in tok ? tok.pattern : null;
247
+ if (s === null)
248
+ continue;
249
+ if (pending) {
250
+ if (pending === 'input')
251
+ read = s; // the latest input-redirected file wins, as the shell keeps the last
252
+ pending = null;
253
+ continue;
254
+ }
255
+ hasCommand = true;
256
+ }
257
+ flush();
258
+ return reads;
259
+ }
183
260
  /** The judge reads at most this many scripts per command. */
184
261
  export const MAX_JUDGED_SCRIPTS = 3;
185
262
  /**
@@ -206,66 +283,139 @@ function addScript(list, script) {
206
283
  return;
207
284
  list.push(script);
208
285
  }
209
- function addInline(list, command) {
210
- for (const code of extractInlineCode(command)) {
211
- addScript(list, { origin: 'inline', language: code.language, label: 'inline', body: code.code, truncated: false });
212
- }
286
+ /** The read budget was spent, or the deadline passed: refuse the whole call. */
287
+ const ANALYSIS_TIMED_OUT = 'This command took too long to check, so it was refused. Split it into smaller commands.';
288
+ const bytesOf = (text) => Buffer.byteLength(text, 'utf8');
289
+ function refusedAnalysis(message, forms) {
290
+ return {
291
+ decision: { verdict: 'deny', matchedRuleIds: [], message, maxSeverity: 'critical', failedClosed: true },
292
+ routeHint: 'none',
293
+ evaluatedForms: forms,
294
+ scripts: [],
295
+ };
213
296
  }
214
297
  /**
215
298
  * Script hops: a command's script (hop 0 → 1), and a script that script or a
216
299
  * package script runs (hop 1 → 2). A third level is not read.
217
300
  */
218
301
  const MAX_SCRIPT_HOPS = 2;
302
+ /**
303
+ * The script a command runs: the one its line names, else the first one a
304
+ * command substitution names. Inside double quotes a substitution is one word
305
+ * of the line (`echo "$(bash x.sh)"`), so only its own text, which the
306
+ * normalizer keeps with its quotes, names the script. One script per command,
307
+ * as for the line alone, so the reads stay what they were.
308
+ */
309
+ function executedScript(resolveScript, rawCommand, substitutions) {
310
+ for (const text of [rawCommand, ...substitutions]) {
311
+ const script = resolveScript(text);
312
+ if (script)
313
+ return script;
314
+ }
315
+ return null;
316
+ }
219
317
  export function analyzeCommandAction(rules, req, rawCommand, opts = {}) {
220
318
  const forms = [];
221
319
  let decision = evaluate(rules, req); // candidate (a): the raw action, as today
320
+ // Nothing below can change that answer, and on a refused command all of it
321
+ // would run on megabytes: 36 s on 8 MB of `$(`.
322
+ if (decision.failedClosed && decision.verdict === 'deny') {
323
+ return { decision, routeHint: 'none', evaluatedForms: forms, scripts: [] };
324
+ }
325
+ // Bounds on how much the analysis reads and how long it runs. The budget
326
+ // counts the command, every substitution text and every script content, over
327
+ // ONE call's script hops (shared via `_budget`); the deadline (epoch ms) is
328
+ // the caller's wall-clock limit, checked between the units below. Either one
329
+ // crossed refuses the whole call — a guard that can be grown or slowed into
330
+ // an allow is a bypass.
331
+ const budget = opts._budget ?? { used: 0, cap: opts.budgetBytes ?? MAX_TARGET_BYTES };
332
+ budget.used += bytesOf(rawCommand);
333
+ const overBounds = () => {
334
+ if (budget.used > budget.cap)
335
+ return refusedAnalysis(COMMAND_TOO_LONG, forms);
336
+ if (opts.deadlineAt !== undefined && Date.now() >= opts.deadlineAt) {
337
+ return refusedAnalysis(ANALYSIS_TIMED_OUT, forms);
338
+ }
339
+ return null;
340
+ };
341
+ {
342
+ const stop = overBounds();
343
+ if (stop)
344
+ return stop;
345
+ }
222
346
  // The scripts this command runs, for the script judge. Collecting one never
223
347
  // changes the verdict here.
224
348
  const scripts = [];
349
+ let inlineCode = [];
225
350
  try {
226
- addInline(scripts, rawCommand);
351
+ inlineCode = extractInlineCode(rawCommand);
352
+ for (const code of inlineCode) {
353
+ addScript(scripts, { origin: 'inline', language: code.language, label: 'inline', body: code.code, truncated: false });
354
+ }
227
355
  }
228
356
  catch {
229
357
  /* never throw */
230
358
  }
359
+ // Candidate set (b): the canonical form of every command the normalizer
360
+ // recovered, at any depth (top level, `bash -c`, `eval`, `$( … )`, a heredoc
361
+ // fed to a shell, `xargs`, `find -exec`, a variable the command assigned).
362
+ // Each is read from its WORDS, never from text put back together: a quoted
363
+ // string stays one word, and the body of a heredoc written to a file is not
364
+ // a list of commands.
365
+ let normalize;
366
+ let triage;
231
367
  try {
232
- // Candidate set (b): in-place canonical forms of each top-level segment.
233
- for (const seg of tokenSegments(rawCommand)) {
234
- const canon = canonicalizeSegment(seg);
235
- if (!canon)
236
- continue;
237
- const form = [canon.command, ...canon.argv].join(' ');
238
- if (forms.length < MAX_FORMS && !forms.includes(form)) {
368
+ normalize = normalizeCommand(rawCommand);
369
+ for (const sub of normalize.substitutions)
370
+ budget.used += bytesOf(sub);
371
+ {
372
+ const stop = overBounds();
373
+ if (stop)
374
+ return stop;
375
+ }
376
+ for (const cmd of normalize.commands) {
377
+ {
378
+ const stop = overBounds();
379
+ if (stop)
380
+ return stop;
381
+ }
382
+ for (const words of formsOfCommand(cmd)) {
383
+ const form = words.join(' ');
384
+ if (forms.length >= MAX_FORMS || forms.includes(form))
385
+ continue;
239
386
  forms.push(form);
240
- decision = strongest(decision, evaluateCommandForm(rules, req, canon.command, canon.argv));
387
+ decision = strongest(decision, evaluateCommandForm(rules, req, words));
241
388
  }
242
389
  }
390
+ triage = triageCommand(normalize);
243
391
  }
244
392
  catch {
245
393
  /* never throw */
246
394
  }
247
- // Candidate set (c): de-nested inner commands (bash -c, eval, $(), heredoc,
248
- // xargs, find -exec). normalize recovers them; we evaluate each inner raw the
249
- // same way (one more de-obfuscation hop).
250
- let normalize;
251
- let triage;
395
+ // Candidate set (d): a bare input redirection reads a file (`$(< .env)`, a
396
+ // top-level `< .env`). The shell runs no command, so set (b) sees none; the
397
+ // read is evaluated as `cat <file>` so the secret-read rules fire on it.
252
398
  try {
253
- normalize = normalizeCommand(rawCommand);
254
- for (const cmd of normalize.commands) {
255
- if (cmd.depth === 0)
256
- continue; // top-level already covered above
257
- for (const seg of tokenSegments(cmd.raw)) {
258
- const canon = canonicalizeSegment(seg);
259
- if (!canon)
260
- continue;
261
- const form = [canon.command, ...canon.argv].join(' ');
399
+ for (const text of [rawCommand, ...(normalize?.substitutions ?? [])]) {
400
+ for (const file of inputRedirectReads(text)) {
401
+ const form = `cat ${file}`;
262
402
  if (forms.length < MAX_FORMS && !forms.includes(form)) {
263
403
  forms.push(form);
264
- decision = strongest(decision, evaluateCommandForm(rules, req, canon.command, canon.argv));
404
+ decision = strongest(decision, evaluateCommandForm(rules, req, ['cat', file]));
265
405
  }
266
406
  }
267
407
  }
268
- triage = triageCommand(normalize);
408
+ }
409
+ catch {
410
+ /* never throw */
411
+ }
412
+ // The file rules, applied to the files the command reads and writes: a file
413
+ // is the same file whatever tool touches it (shell-files.ts).
414
+ try {
415
+ // At equal strength the file rule speaks: its message names the file.
416
+ const files = fileAccessDecision(rules, req, normalize, opts);
417
+ if (files)
418
+ decision = strongest(files, decision);
269
419
  }
270
420
  catch {
271
421
  /* never throw */
@@ -287,6 +437,50 @@ export function analyzeCommandAction(rules, req, rawCommand, opts = {}) {
287
437
  ...(supplementReason ? [supplementReason] : []),
288
438
  ...(triage?.class === 'dangerous' ? triage.reasons : []),
289
439
  ];
440
+ // Program text handed to an interpreter (`python3 -c`, `node -e`, a heredoc,
441
+ // an awk program). The rules do not read code; what it hands to a shell is a
442
+ // command like any other, and two acts are dangerous on their face
443
+ // (inline-danger.ts).
444
+ const hop = opts._scriptHop ?? 0;
445
+ try {
446
+ const programs = [...inlineCode];
447
+ for (const cmd of normalize?.commands ?? []) {
448
+ if (!AWK_NAMES.has(cmd.executable))
449
+ continue;
450
+ for (const word of cmd.argv ?? [])
451
+ if (word.includes('system'))
452
+ programs.push({ language: 'awk', code: word });
453
+ }
454
+ for (const program of programs) {
455
+ const danger = codeDanger(program.code, req.homeDir);
456
+ if (danger)
457
+ localReasons.push(danger);
458
+ if (hop >= MAX_SCRIPT_HOPS)
459
+ continue;
460
+ for (const inner of shellCommandsInCode(program.language, program.code)) {
461
+ if (forms.length >= MAX_FORMS)
462
+ break;
463
+ {
464
+ const stop = overBounds();
465
+ if (stop)
466
+ return stop;
467
+ }
468
+ forms.push(`code:${inner}`);
469
+ const innerAnalysis = analyzeCommandAction(rules, innerCommandRequest(req, inner), inner, {
470
+ ...opts,
471
+ _scriptHop: hop + 1,
472
+ _budget: budget, // one budget across this call's hops
473
+ });
474
+ // Bounds crossed deeper in.
475
+ if (innerAnalysis.decision.failedClosed && innerAnalysis.decision.verdict === 'deny')
476
+ return innerAnalysis;
477
+ decision = strongest(decision, innerAnalysis.decision);
478
+ }
479
+ }
480
+ }
481
+ catch {
482
+ /* never throw */
483
+ }
290
484
  for (const reason of localReasons) {
291
485
  const local = localBlockDecision(rules, reason);
292
486
  if (!local)
@@ -303,12 +497,23 @@ export function analyzeCommandAction(rules, req, rawCommand, opts = {}) {
303
497
  // of its inner commands in. A script the agent WROTE this session that runs
304
498
  // something dangerous is the write-then-run blind spot; a script that is only
305
499
  // suspicious escalates the judge route rather than hard-blocking (FP-averse).
306
- const hop = opts._scriptHop ?? 0;
307
500
  let scriptEscalation = 'none';
308
501
  if (opts.resolveScript && hop < MAX_SCRIPT_HOPS) {
309
502
  try {
310
- const script = opts.resolveScript(rawCommand);
503
+ {
504
+ const stop = overBounds();
505
+ if (stop)
506
+ return stop;
507
+ }
508
+ const script = executedScript(opts.resolveScript, rawCommand, normalize?.substitutions ?? []);
311
509
  if (script) {
510
+ if (typeof script.content === 'string')
511
+ budget.used += bytesOf(script.content);
512
+ {
513
+ const stop = overBounds();
514
+ if (stop)
515
+ return stop;
516
+ }
312
517
  const writtenHere = script.path ? opts.wasWrittenThisSession?.(script.path) ?? false : false;
313
518
  const language = script.language ?? (script.kind === 'shell' ? 'shell' : undefined);
314
519
  if (script.kind !== 'npm-script' &&
@@ -325,14 +530,19 @@ export function analyzeCommandAction(rules, req, rawCommand, opts = {}) {
325
530
  });
326
531
  }
327
532
  for (const inner of script.shellCommands.slice(0, MAX_FORMS)) {
328
- const innerReq = {
329
- ...req,
330
- target: { type: 'command', command: inner.split(/\s+/)[0] ?? '', argv: [], cwd: req.cwd },
331
- };
332
- const innerAnalysis = analyzeCommandAction(rules, innerReq, inner, {
533
+ {
534
+ const stop = overBounds();
535
+ if (stop)
536
+ return stop;
537
+ }
538
+ const innerAnalysis = analyzeCommandAction(rules, innerCommandRequest(req, inner), inner, {
333
539
  ...opts,
334
540
  _scriptHop: hop + 1,
541
+ _budget: budget, // one budget across this call's script hops
335
542
  });
543
+ // Bounds crossed deeper in.
544
+ if (innerAnalysis.decision.failedClosed && innerAnalysis.decision.verdict === 'deny')
545
+ return innerAnalysis;
336
546
  decision = strongest(decision, innerAnalysis.decision);
337
547
  if (innerAnalysis.routeHint === 'catch')
338
548
  scriptEscalation = 'catch';
@@ -359,11 +569,56 @@ export function analyzeCommandAction(rules, req, rawCommand, opts = {}) {
359
569
  /* never throw */
360
570
  }
361
571
  }
572
+ // Inline code a command substitution runs (`echo "$(python3 -c '…')"`), read
573
+ // from the substitution's own text: on the line it is one quoted word. After
574
+ // the files, so it never takes a file's place among the scripts judged.
575
+ try {
576
+ for (const text of normalize?.substitutions ?? []) {
577
+ for (const code of extractInlineCode(text)) {
578
+ addScript(scripts, { origin: 'inline', language: code.language, label: 'inline', body: code.code, truncated: false });
579
+ }
580
+ }
581
+ }
582
+ catch {
583
+ /* never throw */
584
+ }
362
585
  let routeHint = decideRouteHint(decision, triage, normalize);
363
586
  if (routeHint === 'none' && scriptEscalation === 'catch')
364
587
  routeHint = 'catch';
365
588
  return { decision, normalize, triage, localBlockReason, routeHint, evaluatedForms: forms, scripts };
366
589
  }
590
+ // ---------------------------------------------------------------------------
591
+ // The file rules, applied to what a command reads and writes
592
+ // ---------------------------------------------------------------------------
593
+ /**
594
+ * The rule that says whether a shell command may read what the file rules
595
+ * protect. Its effective action caps every read found here: a project that
596
+ * set it to `warn` is warned, one that turned it off is left alone.
597
+ */
598
+ const SHELL_READ_RULE = 'fs.read.secrets_via_shell';
599
+ function fileAccessDecision(rules, req, normalize, opts) {
600
+ const access = shellFileAccess(normalize);
601
+ if (access.reads.length === 0 && access.writes.length === 0)
602
+ return null;
603
+ let decision = null;
604
+ const fold = (d) => {
605
+ if (!d || d.verdict === 'allow')
606
+ return;
607
+ decision = decision ? strongest(decision, d) : d;
608
+ };
609
+ const shellRead = rules.find((r) => (r.builtinKey ?? r.id) === SHELL_READ_RULE);
610
+ const readCap = shellRead ? shellRead.action : 'deny';
611
+ // A refusal (a path too long to check, a rule that failed) is no rule's
612
+ // answer about a read: the project's cap does not lower it.
613
+ const capped = (d) => d && !d.failedClosed && readCap === 'warn' && d.verdict === 'deny' ? { ...d, verdict: 'warn' } : d;
614
+ if (readCap !== 'off') {
615
+ for (const read of access.reads)
616
+ fold(capped(evaluateFileRead(rules, req, read, opts.resolvePaths)));
617
+ }
618
+ for (const write of access.writes)
619
+ fold(evaluateFileWrite(rules, req, write, opts.resolvePaths));
620
+ return decision;
621
+ }
367
622
  /**
368
623
  * A curated, LOW-false-positive local-deny supplement for dangerous families
369
624
  * the built-in regex corpus does not yet cover after de-obfuscation. Each
@@ -394,7 +649,12 @@ const LOCAL_BLOCK_RULES = {
394
649
  'rm-rf-root-home': 'fs.delete.root_or_home',
395
650
  'chmod-777-broad': 'shell.priv.chmod_777',
396
651
  'encoded-pipe-to-shell': 'shell.exec.dynamic_eval',
652
+ // inline-danger.ts
653
+ 'code-deletes-root-home': 'fs.delete.root_or_home',
654
+ 'code-reverse-shell': 'shell.net.netcat',
655
+ 'code-runs-download': 'shell.net.pipe_to_shell',
397
656
  };
657
+ const AWK_NAMES = new Set(['awk', 'gawk', 'mawk', 'nawk']);
398
658
  function localBlockDecision(rules, reason) {
399
659
  const key = LOCAL_BLOCK_RULES[reason];
400
660
  const rule = key ? rules.find((r) => (r.builtinKey ?? r.id) === key) : undefined;
@@ -496,7 +756,8 @@ function uploadOperands(args) {
496
756
  }
497
757
  /** One effective command, read by its executable, flags and operands. */
498
758
  function commandDanger(cmd) {
499
- const tokens = cmd.raw.split(/\s+/).filter(Boolean);
759
+ // The words as the shell splits them: a quoted argument is one word.
760
+ const tokens = cmd.argv && cmd.argv.length > 0 ? cmd.argv : cmd.raw.split(/\s+/).filter(Boolean);
500
761
  if (runsUnder(tokens, PRIVILEGE_WRAPPERS))
501
762
  return 'privilege-escalation';
502
763
  const at = tokens.findIndex((t) => canonicalExecutable(t) === cmd.executable);