clawsec 0.0.1

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 (361) hide show
  1. package/README.md +560 -0
  2. package/dist/bin/clawsec.d.ts +7 -0
  3. package/dist/bin/clawsec.d.ts.map +1 -0
  4. package/dist/bin/clawsec.js +12 -0
  5. package/dist/bin/clawsec.js.map +1 -0
  6. package/dist/src/actions/block.d.ts +22 -0
  7. package/dist/src/actions/block.d.ts.map +1 -0
  8. package/dist/src/actions/block.js +83 -0
  9. package/dist/src/actions/block.js.map +1 -0
  10. package/dist/src/actions/confirm.d.ts +35 -0
  11. package/dist/src/actions/confirm.d.ts.map +1 -0
  12. package/dist/src/actions/confirm.js +156 -0
  13. package/dist/src/actions/confirm.js.map +1 -0
  14. package/dist/src/actions/executor.d.ts +64 -0
  15. package/dist/src/actions/executor.d.ts.map +1 -0
  16. package/dist/src/actions/executor.js +114 -0
  17. package/dist/src/actions/executor.js.map +1 -0
  18. package/dist/src/actions/index.d.ts +13 -0
  19. package/dist/src/actions/index.d.ts.map +1 -0
  20. package/dist/src/actions/index.js +15 -0
  21. package/dist/src/actions/index.js.map +1 -0
  22. package/dist/src/actions/log.d.ts +19 -0
  23. package/dist/src/actions/log.d.ts.map +1 -0
  24. package/dist/src/actions/log.js +63 -0
  25. package/dist/src/actions/log.js.map +1 -0
  26. package/dist/src/actions/types.d.ts +85 -0
  27. package/dist/src/actions/types.d.ts.map +1 -0
  28. package/dist/src/actions/types.js +78 -0
  29. package/dist/src/actions/types.js.map +1 -0
  30. package/dist/src/actions/warn.d.ts +22 -0
  31. package/dist/src/actions/warn.d.ts.map +1 -0
  32. package/dist/src/actions/warn.js +84 -0
  33. package/dist/src/actions/warn.js.map +1 -0
  34. package/dist/src/approval/agent-confirm.d.ts +104 -0
  35. package/dist/src/approval/agent-confirm.d.ts.map +1 -0
  36. package/dist/src/approval/agent-confirm.js +173 -0
  37. package/dist/src/approval/agent-confirm.js.map +1 -0
  38. package/dist/src/approval/index.d.ts +14 -0
  39. package/dist/src/approval/index.d.ts.map +1 -0
  40. package/dist/src/approval/index.js +9 -0
  41. package/dist/src/approval/index.js.map +1 -0
  42. package/dist/src/approval/native.d.ts +56 -0
  43. package/dist/src/approval/native.d.ts.map +1 -0
  44. package/dist/src/approval/native.js +196 -0
  45. package/dist/src/approval/native.js.map +1 -0
  46. package/dist/src/approval/store.d.ts +88 -0
  47. package/dist/src/approval/store.d.ts.map +1 -0
  48. package/dist/src/approval/store.js +192 -0
  49. package/dist/src/approval/store.js.map +1 -0
  50. package/dist/src/approval/types.d.ts +119 -0
  51. package/dist/src/approval/types.d.ts.map +1 -0
  52. package/dist/src/approval/types.js +6 -0
  53. package/dist/src/approval/types.js.map +1 -0
  54. package/dist/src/approval/webhook.d.ts +170 -0
  55. package/dist/src/approval/webhook.d.ts.map +1 -0
  56. package/dist/src/approval/webhook.js +362 -0
  57. package/dist/src/approval/webhook.js.map +1 -0
  58. package/dist/src/cli/commands/audit.d.ts +43 -0
  59. package/dist/src/cli/commands/audit.d.ts.map +1 -0
  60. package/dist/src/cli/commands/audit.js +115 -0
  61. package/dist/src/cli/commands/audit.js.map +1 -0
  62. package/dist/src/cli/commands/feedback.d.ts +27 -0
  63. package/dist/src/cli/commands/feedback.d.ts.map +1 -0
  64. package/dist/src/cli/commands/feedback.js +228 -0
  65. package/dist/src/cli/commands/feedback.js.map +1 -0
  66. package/dist/src/cli/commands/index.d.ts +11 -0
  67. package/dist/src/cli/commands/index.d.ts.map +1 -0
  68. package/dist/src/cli/commands/index.js +13 -0
  69. package/dist/src/cli/commands/index.js.map +1 -0
  70. package/dist/src/cli/commands/status.d.ts +20 -0
  71. package/dist/src/cli/commands/status.d.ts.map +1 -0
  72. package/dist/src/cli/commands/status.js +122 -0
  73. package/dist/src/cli/commands/status.js.map +1 -0
  74. package/dist/src/cli/commands/test.d.ts +23 -0
  75. package/dist/src/cli/commands/test.d.ts.map +1 -0
  76. package/dist/src/cli/commands/test.js +134 -0
  77. package/dist/src/cli/commands/test.js.map +1 -0
  78. package/dist/src/cli/commands/types.d.ts +81 -0
  79. package/dist/src/cli/commands/types.d.ts.map +1 -0
  80. package/dist/src/cli/commands/types.js +6 -0
  81. package/dist/src/cli/commands/types.js.map +1 -0
  82. package/dist/src/cli/index.d.ts +17 -0
  83. package/dist/src/cli/index.d.ts.map +1 -0
  84. package/dist/src/cli/index.js +267 -0
  85. package/dist/src/cli/index.js.map +1 -0
  86. package/dist/src/config/defaults.d.ts +20 -0
  87. package/dist/src/config/defaults.d.ts.map +1 -0
  88. package/dist/src/config/defaults.js +123 -0
  89. package/dist/src/config/defaults.js.map +1 -0
  90. package/dist/src/config/index.d.ts +8 -0
  91. package/dist/src/config/index.d.ts.map +1 -0
  92. package/dist/src/config/index.js +41 -0
  93. package/dist/src/config/index.js.map +1 -0
  94. package/dist/src/config/loader.d.ts +99 -0
  95. package/dist/src/config/loader.d.ts.map +1 -0
  96. package/dist/src/config/loader.js +242 -0
  97. package/dist/src/config/loader.js.map +1 -0
  98. package/dist/src/config/schema.d.ts +627 -0
  99. package/dist/src/config/schema.d.ts.map +1 -0
  100. package/dist/src/config/schema.js +585 -0
  101. package/dist/src/config/schema.js.map +1 -0
  102. package/dist/src/detectors/destructive/cloud-detector.d.ts +51 -0
  103. package/dist/src/detectors/destructive/cloud-detector.d.ts.map +1 -0
  104. package/dist/src/detectors/destructive/cloud-detector.js +556 -0
  105. package/dist/src/detectors/destructive/cloud-detector.js.map +1 -0
  106. package/dist/src/detectors/destructive/code-detector.d.ts +59 -0
  107. package/dist/src/detectors/destructive/code-detector.d.ts.map +1 -0
  108. package/dist/src/detectors/destructive/code-detector.js +558 -0
  109. package/dist/src/detectors/destructive/code-detector.js.map +1 -0
  110. package/dist/src/detectors/destructive/index.d.ts +54 -0
  111. package/dist/src/detectors/destructive/index.d.ts.map +1 -0
  112. package/dist/src/detectors/destructive/index.js +168 -0
  113. package/dist/src/detectors/destructive/index.js.map +1 -0
  114. package/dist/src/detectors/destructive/shell-detector.d.ts +43 -0
  115. package/dist/src/detectors/destructive/shell-detector.d.ts.map +1 -0
  116. package/dist/src/detectors/destructive/shell-detector.js +302 -0
  117. package/dist/src/detectors/destructive/shell-detector.js.map +1 -0
  118. package/dist/src/detectors/destructive/types.d.ts +143 -0
  119. package/dist/src/detectors/destructive/types.d.ts.map +1 -0
  120. package/dist/src/detectors/destructive/types.js +6 -0
  121. package/dist/src/detectors/destructive/types.js.map +1 -0
  122. package/dist/src/detectors/exfiltration/cloud-detector.d.ts +51 -0
  123. package/dist/src/detectors/exfiltration/cloud-detector.d.ts.map +1 -0
  124. package/dist/src/detectors/exfiltration/cloud-detector.js +427 -0
  125. package/dist/src/detectors/exfiltration/cloud-detector.js.map +1 -0
  126. package/dist/src/detectors/exfiltration/http-detector.d.ts +47 -0
  127. package/dist/src/detectors/exfiltration/http-detector.d.ts.map +1 -0
  128. package/dist/src/detectors/exfiltration/http-detector.js +429 -0
  129. package/dist/src/detectors/exfiltration/http-detector.js.map +1 -0
  130. package/dist/src/detectors/exfiltration/index.d.ts +44 -0
  131. package/dist/src/detectors/exfiltration/index.d.ts.map +1 -0
  132. package/dist/src/detectors/exfiltration/index.js +118 -0
  133. package/dist/src/detectors/exfiltration/index.js.map +1 -0
  134. package/dist/src/detectors/exfiltration/network-detector.d.ts +55 -0
  135. package/dist/src/detectors/exfiltration/network-detector.d.ts.map +1 -0
  136. package/dist/src/detectors/exfiltration/network-detector.js +504 -0
  137. package/dist/src/detectors/exfiltration/network-detector.js.map +1 -0
  138. package/dist/src/detectors/exfiltration/types.d.ts +139 -0
  139. package/dist/src/detectors/exfiltration/types.d.ts.map +1 -0
  140. package/dist/src/detectors/exfiltration/types.js +6 -0
  141. package/dist/src/detectors/exfiltration/types.js.map +1 -0
  142. package/dist/src/detectors/purchase/domain-detector.d.ts +44 -0
  143. package/dist/src/detectors/purchase/domain-detector.d.ts.map +1 -0
  144. package/dist/src/detectors/purchase/domain-detector.js +296 -0
  145. package/dist/src/detectors/purchase/domain-detector.js.map +1 -0
  146. package/dist/src/detectors/purchase/form-detector.d.ts +27 -0
  147. package/dist/src/detectors/purchase/form-detector.d.ts.map +1 -0
  148. package/dist/src/detectors/purchase/form-detector.js +344 -0
  149. package/dist/src/detectors/purchase/form-detector.js.map +1 -0
  150. package/dist/src/detectors/purchase/index.d.ts +65 -0
  151. package/dist/src/detectors/purchase/index.d.ts.map +1 -0
  152. package/dist/src/detectors/purchase/index.js +216 -0
  153. package/dist/src/detectors/purchase/index.js.map +1 -0
  154. package/dist/src/detectors/purchase/spend-tracker.d.ts +132 -0
  155. package/dist/src/detectors/purchase/spend-tracker.d.ts.map +1 -0
  156. package/dist/src/detectors/purchase/spend-tracker.js +313 -0
  157. package/dist/src/detectors/purchase/spend-tracker.js.map +1 -0
  158. package/dist/src/detectors/purchase/types.d.ts +139 -0
  159. package/dist/src/detectors/purchase/types.d.ts.map +1 -0
  160. package/dist/src/detectors/purchase/types.js +6 -0
  161. package/dist/src/detectors/purchase/types.js.map +1 -0
  162. package/dist/src/detectors/purchase/url-detector.d.ts +31 -0
  163. package/dist/src/detectors/purchase/url-detector.d.ts.map +1 -0
  164. package/dist/src/detectors/purchase/url-detector.js +292 -0
  165. package/dist/src/detectors/purchase/url-detector.js.map +1 -0
  166. package/dist/src/detectors/secrets/api-key-detector.d.ts +30 -0
  167. package/dist/src/detectors/secrets/api-key-detector.d.ts.map +1 -0
  168. package/dist/src/detectors/secrets/api-key-detector.js +297 -0
  169. package/dist/src/detectors/secrets/api-key-detector.js.map +1 -0
  170. package/dist/src/detectors/secrets/index.d.ts +43 -0
  171. package/dist/src/detectors/secrets/index.d.ts.map +1 -0
  172. package/dist/src/detectors/secrets/index.js +261 -0
  173. package/dist/src/detectors/secrets/index.js.map +1 -0
  174. package/dist/src/detectors/secrets/pii-detector.d.ts +54 -0
  175. package/dist/src/detectors/secrets/pii-detector.d.ts.map +1 -0
  176. package/dist/src/detectors/secrets/pii-detector.js +286 -0
  177. package/dist/src/detectors/secrets/pii-detector.js.map +1 -0
  178. package/dist/src/detectors/secrets/token-detector.d.ts +51 -0
  179. package/dist/src/detectors/secrets/token-detector.d.ts.map +1 -0
  180. package/dist/src/detectors/secrets/token-detector.js +233 -0
  181. package/dist/src/detectors/secrets/token-detector.js.map +1 -0
  182. package/dist/src/detectors/secrets/types.d.ts +157 -0
  183. package/dist/src/detectors/secrets/types.d.ts.map +1 -0
  184. package/dist/src/detectors/secrets/types.js +6 -0
  185. package/dist/src/detectors/secrets/types.js.map +1 -0
  186. package/dist/src/detectors/website/category-detector.d.ts +22 -0
  187. package/dist/src/detectors/website/category-detector.d.ts.map +1 -0
  188. package/dist/src/detectors/website/category-detector.js +162 -0
  189. package/dist/src/detectors/website/category-detector.js.map +1 -0
  190. package/dist/src/detectors/website/index.d.ts +53 -0
  191. package/dist/src/detectors/website/index.d.ts.map +1 -0
  192. package/dist/src/detectors/website/index.js +232 -0
  193. package/dist/src/detectors/website/index.js.map +1 -0
  194. package/dist/src/detectors/website/pattern-matcher.d.ts +33 -0
  195. package/dist/src/detectors/website/pattern-matcher.d.ts.map +1 -0
  196. package/dist/src/detectors/website/pattern-matcher.js +121 -0
  197. package/dist/src/detectors/website/pattern-matcher.js.map +1 -0
  198. package/dist/src/detectors/website/types.d.ts +105 -0
  199. package/dist/src/detectors/website/types.d.ts.map +1 -0
  200. package/dist/src/detectors/website/types.js +6 -0
  201. package/dist/src/detectors/website/types.js.map +1 -0
  202. package/dist/src/engine/analyzer.d.ts +87 -0
  203. package/dist/src/engine/analyzer.d.ts.map +1 -0
  204. package/dist/src/engine/analyzer.js +427 -0
  205. package/dist/src/engine/analyzer.js.map +1 -0
  206. package/dist/src/engine/cache.d.ts +80 -0
  207. package/dist/src/engine/cache.d.ts.map +1 -0
  208. package/dist/src/engine/cache.js +167 -0
  209. package/dist/src/engine/cache.js.map +1 -0
  210. package/dist/src/engine/index.d.ts +11 -0
  211. package/dist/src/engine/index.d.ts.map +1 -0
  212. package/dist/src/engine/index.js +11 -0
  213. package/dist/src/engine/index.js.map +1 -0
  214. package/dist/src/engine/llm-client.d.ts +210 -0
  215. package/dist/src/engine/llm-client.d.ts.map +1 -0
  216. package/dist/src/engine/llm-client.js +506 -0
  217. package/dist/src/engine/llm-client.js.map +1 -0
  218. package/dist/src/engine/types.d.ts +163 -0
  219. package/dist/src/engine/types.d.ts.map +1 -0
  220. package/dist/src/engine/types.js +21 -0
  221. package/dist/src/engine/types.js.map +1 -0
  222. package/dist/src/feedback/index.d.ts +9 -0
  223. package/dist/src/feedback/index.d.ts.map +1 -0
  224. package/dist/src/feedback/index.js +8 -0
  225. package/dist/src/feedback/index.js.map +1 -0
  226. package/dist/src/feedback/learner.d.ts +222 -0
  227. package/dist/src/feedback/learner.d.ts.map +1 -0
  228. package/dist/src/feedback/learner.js +401 -0
  229. package/dist/src/feedback/learner.js.map +1 -0
  230. package/dist/src/feedback/store.d.ts +113 -0
  231. package/dist/src/feedback/store.d.ts.map +1 -0
  232. package/dist/src/feedback/store.js +228 -0
  233. package/dist/src/feedback/store.js.map +1 -0
  234. package/dist/src/feedback/types.d.ts +126 -0
  235. package/dist/src/feedback/types.d.ts.map +1 -0
  236. package/dist/src/feedback/types.js +6 -0
  237. package/dist/src/feedback/types.js.map +1 -0
  238. package/dist/src/hooks/before-agent-start/handler.d.ts +37 -0
  239. package/dist/src/hooks/before-agent-start/handler.d.ts.map +1 -0
  240. package/dist/src/hooks/before-agent-start/handler.js +109 -0
  241. package/dist/src/hooks/before-agent-start/handler.js.map +1 -0
  242. package/dist/src/hooks/before-agent-start/index.d.ts +8 -0
  243. package/dist/src/hooks/before-agent-start/index.d.ts.map +1 -0
  244. package/dist/src/hooks/before-agent-start/index.js +7 -0
  245. package/dist/src/hooks/before-agent-start/index.js.map +1 -0
  246. package/dist/src/hooks/before-agent-start/prompts.d.ts +48 -0
  247. package/dist/src/hooks/before-agent-start/prompts.d.ts.map +1 -0
  248. package/dist/src/hooks/before-agent-start/prompts.js +103 -0
  249. package/dist/src/hooks/before-agent-start/prompts.js.map +1 -0
  250. package/dist/src/hooks/before-tool-call/handler.d.ts +42 -0
  251. package/dist/src/hooks/before-tool-call/handler.d.ts.map +1 -0
  252. package/dist/src/hooks/before-tool-call/handler.js +226 -0
  253. package/dist/src/hooks/before-tool-call/handler.js.map +1 -0
  254. package/dist/src/hooks/before-tool-call/index.d.ts +7 -0
  255. package/dist/src/hooks/before-tool-call/index.d.ts.map +1 -0
  256. package/dist/src/hooks/before-tool-call/index.js +6 -0
  257. package/dist/src/hooks/before-tool-call/index.js.map +1 -0
  258. package/dist/src/hooks/tool-result-persist/filter.d.ts +72 -0
  259. package/dist/src/hooks/tool-result-persist/filter.d.ts.map +1 -0
  260. package/dist/src/hooks/tool-result-persist/filter.js +305 -0
  261. package/dist/src/hooks/tool-result-persist/filter.js.map +1 -0
  262. package/dist/src/hooks/tool-result-persist/handler.d.ts +49 -0
  263. package/dist/src/hooks/tool-result-persist/handler.d.ts.map +1 -0
  264. package/dist/src/hooks/tool-result-persist/handler.js +217 -0
  265. package/dist/src/hooks/tool-result-persist/handler.js.map +1 -0
  266. package/dist/src/hooks/tool-result-persist/index.d.ts +11 -0
  267. package/dist/src/hooks/tool-result-persist/index.d.ts.map +1 -0
  268. package/dist/src/hooks/tool-result-persist/index.js +11 -0
  269. package/dist/src/hooks/tool-result-persist/index.js.map +1 -0
  270. package/dist/src/index.d.ts +256 -0
  271. package/dist/src/index.d.ts.map +1 -0
  272. package/dist/src/index.js +222 -0
  273. package/dist/src/index.js.map +1 -0
  274. package/dist/src/notifications/discord.d.ts +10 -0
  275. package/dist/src/notifications/discord.d.ts.map +1 -0
  276. package/dist/src/notifications/discord.js +218 -0
  277. package/dist/src/notifications/discord.js.map +1 -0
  278. package/dist/src/notifications/index.d.ts +37 -0
  279. package/dist/src/notifications/index.d.ts.map +1 -0
  280. package/dist/src/notifications/index.js +68 -0
  281. package/dist/src/notifications/index.js.map +1 -0
  282. package/dist/src/notifications/slack.d.ts +10 -0
  283. package/dist/src/notifications/slack.d.ts.map +1 -0
  284. package/dist/src/notifications/slack.js +218 -0
  285. package/dist/src/notifications/slack.js.map +1 -0
  286. package/dist/src/notifications/telegram.d.ts +10 -0
  287. package/dist/src/notifications/telegram.d.ts.map +1 -0
  288. package/dist/src/notifications/telegram.js +242 -0
  289. package/dist/src/notifications/telegram.js.map +1 -0
  290. package/dist/src/notifications/types.d.ts +119 -0
  291. package/dist/src/notifications/types.d.ts.map +1 -0
  292. package/dist/src/notifications/types.js +6 -0
  293. package/dist/src/notifications/types.js.map +1 -0
  294. package/dist/src/proxy/index.d.ts +8 -0
  295. package/dist/src/proxy/index.d.ts.map +1 -0
  296. package/dist/src/proxy/index.js +9 -0
  297. package/dist/src/proxy/index.js.map +1 -0
  298. package/dist/src/proxy/middleware.d.ts +55 -0
  299. package/dist/src/proxy/middleware.d.ts.map +1 -0
  300. package/dist/src/proxy/middleware.js +215 -0
  301. package/dist/src/proxy/middleware.js.map +1 -0
  302. package/dist/src/proxy/server.d.ts +57 -0
  303. package/dist/src/proxy/server.d.ts.map +1 -0
  304. package/dist/src/proxy/server.js +298 -0
  305. package/dist/src/proxy/server.js.map +1 -0
  306. package/dist/src/proxy/types.d.ts +136 -0
  307. package/dist/src/proxy/types.d.ts.map +1 -0
  308. package/dist/src/proxy/types.js +6 -0
  309. package/dist/src/proxy/types.js.map +1 -0
  310. package/dist/src/sanitization/index.d.ts +10 -0
  311. package/dist/src/sanitization/index.d.ts.map +1 -0
  312. package/dist/src/sanitization/index.js +9 -0
  313. package/dist/src/sanitization/index.js.map +1 -0
  314. package/dist/src/sanitization/patterns.d.ts +51 -0
  315. package/dist/src/sanitization/patterns.d.ts.map +1 -0
  316. package/dist/src/sanitization/patterns.js +266 -0
  317. package/dist/src/sanitization/patterns.js.map +1 -0
  318. package/dist/src/sanitization/scanner.d.ts +29 -0
  319. package/dist/src/sanitization/scanner.d.ts.map +1 -0
  320. package/dist/src/sanitization/scanner.js +328 -0
  321. package/dist/src/sanitization/scanner.js.map +1 -0
  322. package/dist/src/sanitization/types.d.ts +57 -0
  323. package/dist/src/sanitization/types.d.ts.map +1 -0
  324. package/dist/src/sanitization/types.js +5 -0
  325. package/dist/src/sanitization/types.js.map +1 -0
  326. package/openclaw.plugin.json +114 -0
  327. package/package.json +63 -0
  328. package/rules/builtin/README.md +139 -0
  329. package/rules/builtin/ai-services.yaml +70 -0
  330. package/rules/builtin/api-keys.yaml +64 -0
  331. package/rules/builtin/authentication.yaml +56 -0
  332. package/rules/builtin/aws-security.yaml +57 -0
  333. package/rules/builtin/azure-security.yaml +58 -0
  334. package/rules/builtin/cicd-security.yaml +64 -0
  335. package/rules/builtin/cloud-storage.yaml +64 -0
  336. package/rules/builtin/container-registry.yaml +55 -0
  337. package/rules/builtin/crypto-wallets.yaml +71 -0
  338. package/rules/builtin/database-nosql.yaml +58 -0
  339. package/rules/builtin/database-sql.yaml +62 -0
  340. package/rules/builtin/development-env.yaml +67 -0
  341. package/rules/builtin/docker.yaml +57 -0
  342. package/rules/builtin/filesystem.yaml +71 -0
  343. package/rules/builtin/financial-pci.yaml +61 -0
  344. package/rules/builtin/gcp-security.yaml +57 -0
  345. package/rules/builtin/git-operations.yaml +68 -0
  346. package/rules/builtin/healthcare-hipaa.yaml +64 -0
  347. package/rules/builtin/kubernetes.yaml +60 -0
  348. package/rules/builtin/messaging-services.yaml +53 -0
  349. package/rules/builtin/minimal.yaml +47 -0
  350. package/rules/builtin/mobile-development.yaml +61 -0
  351. package/rules/builtin/monitoring.yaml +63 -0
  352. package/rules/builtin/network-security.yaml +57 -0
  353. package/rules/builtin/package-managers.yaml +74 -0
  354. package/rules/builtin/payment-processing.yaml +66 -0
  355. package/rules/builtin/pii-protection.yaml +48 -0
  356. package/rules/builtin/production-strict.yaml +55 -0
  357. package/rules/builtin/secrets-management.yaml +63 -0
  358. package/rules/builtin/serverless.yaml +74 -0
  359. package/rules/builtin/ssh-security.yaml +66 -0
  360. package/rules/builtin/terraform.yaml +51 -0
  361. package/rules/builtin/web-security.yaml +62 -0
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Detection Result Cache
3
+ * Simple in-memory cache with TTL-based expiration
4
+ */
5
+ import { createHash } from 'crypto';
6
+ /**
7
+ * Default cache TTL: 5 minutes
8
+ */
9
+ export const DEFAULT_CACHE_TTL_MS = 5 * 60 * 1000;
10
+ /**
11
+ * Maximum cache size to prevent memory issues
12
+ */
13
+ export const MAX_CACHE_SIZE = 10000;
14
+ /**
15
+ * Generate a cache key from tool name and input
16
+ * Uses SHA256 hash of the JSON-serialized input
17
+ */
18
+ export function generateCacheKey(toolName, toolInput) {
19
+ const data = JSON.stringify({ toolName, toolInput });
20
+ return createHash('sha256').update(data).digest('hex').substring(0, 32);
21
+ }
22
+ /**
23
+ * In-memory detection cache implementation
24
+ */
25
+ export class InMemoryCache {
26
+ cache;
27
+ defaultTtl;
28
+ constructor(defaultTtlMs = DEFAULT_CACHE_TTL_MS) {
29
+ this.cache = new Map();
30
+ this.defaultTtl = defaultTtlMs;
31
+ }
32
+ /**
33
+ * Get a cached result by key
34
+ * Returns undefined if not found or expired
35
+ */
36
+ get(key) {
37
+ const entry = this.cache.get(key);
38
+ if (!entry) {
39
+ return undefined;
40
+ }
41
+ // Check if expired
42
+ if (this.isExpired(entry)) {
43
+ this.cache.delete(key);
44
+ return undefined;
45
+ }
46
+ // Return a copy with cached flag set
47
+ return {
48
+ ...entry.value,
49
+ cached: true,
50
+ };
51
+ }
52
+ /**
53
+ * Set a cached result
54
+ * @param key Cache key
55
+ * @param result Analysis result to cache
56
+ * @param ttl Optional TTL in milliseconds (uses default if not provided)
57
+ */
58
+ set(key, result, ttl) {
59
+ // Evict expired entries if we're at capacity
60
+ if (this.cache.size >= MAX_CACHE_SIZE) {
61
+ this.evictExpired();
62
+ // If still at capacity, evict oldest entries
63
+ if (this.cache.size >= MAX_CACHE_SIZE) {
64
+ this.evictOldest(Math.floor(MAX_CACHE_SIZE * 0.1));
65
+ }
66
+ }
67
+ const entry = {
68
+ value: { ...result, cached: false }, // Store original without cached flag
69
+ createdAt: Date.now(),
70
+ ttl: ttl ?? this.defaultTtl,
71
+ };
72
+ this.cache.set(key, entry);
73
+ }
74
+ /**
75
+ * Check if a key exists and is not expired
76
+ */
77
+ has(key) {
78
+ const entry = this.cache.get(key);
79
+ if (!entry) {
80
+ return false;
81
+ }
82
+ if (this.isExpired(entry)) {
83
+ this.cache.delete(key);
84
+ return false;
85
+ }
86
+ return true;
87
+ }
88
+ /**
89
+ * Clear all entries
90
+ */
91
+ clear() {
92
+ this.cache.clear();
93
+ }
94
+ /**
95
+ * Delete a specific entry
96
+ */
97
+ delete(key) {
98
+ return this.cache.delete(key);
99
+ }
100
+ /**
101
+ * Get the number of entries (including expired)
102
+ */
103
+ size() {
104
+ return this.cache.size;
105
+ }
106
+ /**
107
+ * Get the number of valid (non-expired) entries
108
+ */
109
+ validSize() {
110
+ let count = 0;
111
+ const now = Date.now();
112
+ for (const [, entry] of this.cache) {
113
+ if (now - entry.createdAt < entry.ttl) {
114
+ count++;
115
+ }
116
+ }
117
+ return count;
118
+ }
119
+ /**
120
+ * Check if an entry is expired
121
+ */
122
+ isExpired(entry) {
123
+ return Date.now() - entry.createdAt >= entry.ttl;
124
+ }
125
+ /**
126
+ * Evict all expired entries
127
+ */
128
+ evictExpired() {
129
+ const now = Date.now();
130
+ for (const [key, entry] of this.cache) {
131
+ if (now - entry.createdAt >= entry.ttl) {
132
+ this.cache.delete(key);
133
+ }
134
+ }
135
+ }
136
+ /**
137
+ * Evict the oldest n entries
138
+ */
139
+ evictOldest(count) {
140
+ const entries = Array.from(this.cache.entries())
141
+ .sort((a, b) => a[1].createdAt - b[1].createdAt);
142
+ for (let i = 0; i < Math.min(count, entries.length); i++) {
143
+ this.cache.delete(entries[i][0]);
144
+ }
145
+ }
146
+ }
147
+ /**
148
+ * Create a new cache instance
149
+ */
150
+ export function createCache(defaultTtlMs) {
151
+ return new InMemoryCache(defaultTtlMs);
152
+ }
153
+ /**
154
+ * Create a no-op cache that doesn't store anything
155
+ * Used when caching is disabled
156
+ */
157
+ export function createNoOpCache() {
158
+ return {
159
+ get: () => undefined,
160
+ set: () => { },
161
+ has: () => false,
162
+ clear: () => { },
163
+ delete: () => false,
164
+ size: () => 0,
165
+ };
166
+ }
167
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/engine/cache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAgB,EAAE,SAAkC;IACnF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;IACrD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,aAAa;IAChB,KAAK,CAA0C;IAC/C,UAAU,CAAS;IAE3B,YAAY,eAAuB,oBAAoB;QACrD,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,YAAY,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,GAAW;QACb,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACnB,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AAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;aAC7C,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAEnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACzD,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,YAAqB;IAC/C,OAAO,IAAI,aAAa,CAAC,YAAY,CAAC,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO;QACL,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS;QACpB,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;QACb,GAAG,EAAE,GAAG,EAAE,CAAC,KAAK;QAChB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK;QACnB,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Hybrid Detection Engine
3
+ * Re-exports for clean imports
4
+ */
5
+ export type { ThreatCategory, ToolCallContext, Detection, AnalysisResult, AnalysisAction, CacheEntry, DetectionCache, AnalyzerConfig, Analyzer, } from './types.js';
6
+ export { SEVERITY_WEIGHTS, compareSeverity, } from './types.js';
7
+ export { DEFAULT_CACHE_TTL_MS, MAX_CACHE_SIZE, generateCacheKey, InMemoryCache, createCache, createNoOpCache, } from './cache.js';
8
+ export { HybridAnalyzer, createAnalyzer, createDefaultAnalyzer, } from './analyzer.js';
9
+ export type { ConversationMessage, LLMAnalysisRequest, LLMAnalysisResult, LLMClient, OpenClawAPI, LLMClientConfig, } from './llm-client.js';
10
+ export { DEFAULT_LLM_TIMEOUT_MS, DEFAULT_LLM_CACHE_TTL_MS, MAX_LLM_CACHE_SIZE, LLMResponseCache, buildAnalysisPrompt, parseAnalysisResponse, OpenClawLLMClient, MockLLMClient, createLLMClient, createMockLLMClient, createUnavailableLLMClient, } from './llm-client.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,cAAc,EACd,eAAe,EACf,SAAS,EACT,cAAc,EACd,cAAc,EACd,UAAU,EACV,cAAc,EACd,cAAc,EACd,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,cAAc,EACd,cAAc,EACd,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACT,WAAW,EACX,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Hybrid Detection Engine
3
+ * Re-exports for clean imports
4
+ */
5
+ export { SEVERITY_WEIGHTS, compareSeverity, } from './types.js';
6
+ // Cache
7
+ export { DEFAULT_CACHE_TTL_MS, MAX_CACHE_SIZE, generateCacheKey, InMemoryCache, createCache, createNoOpCache, } from './cache.js';
8
+ // Analyzer
9
+ export { HybridAnalyzer, createAnalyzer, createDefaultAnalyzer, } from './analyzer.js';
10
+ export { DEFAULT_LLM_TIMEOUT_MS, DEFAULT_LLM_CACHE_TTL_MS, MAX_LLM_CACHE_SIZE, LLMResponseCache, buildAnalysisPrompt, parseAnalysisResponse, OpenClawLLMClient, MockLLMClient, createLLMClient, createMockLLMClient, createUnavailableLLMClient, } from './llm-client.js';
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/engine/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EACL,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,QAAQ;AACR,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,WAAW;AACX,OAAO,EACL,cAAc,EACd,cAAc,EACd,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAYvB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * LLM Client for analyzing ambiguous security detections
3
+ *
4
+ * This module provides an LLM client that analyzes ambiguous detections
5
+ * to determine if they're true threats. Used when the HybridAnalyzer
6
+ * sets requiresLLM = true for cases with ambiguous confidence (0.5-0.8).
7
+ */
8
+ import type { LLMConfig } from '../config/index.js';
9
+ import type { Detection, ToolCallContext } from './types.js';
10
+ /**
11
+ * LLM analysis result
12
+ */
13
+ export interface LLMAnalysisResult {
14
+ /** Determination of the threat level */
15
+ determination: 'threat' | 'safe' | 'uncertain';
16
+ /** Confidence in the determination (0-1) */
17
+ confidence: number;
18
+ /** Reasoning behind the determination */
19
+ reasoning: string;
20
+ /** Suggested action based on analysis */
21
+ suggestedAction: 'block' | 'confirm' | 'allow';
22
+ }
23
+ /**
24
+ * Interface for LLM clients
25
+ */
26
+ export interface LLMClient {
27
+ /** Analyze a detection and determine if it's a real threat */
28
+ analyze(request: LLMAnalysisRequest): Promise<LLMAnalysisResult>;
29
+ /** Check if the LLM client is available and configured */
30
+ isAvailable(): boolean;
31
+ }
32
+ /**
33
+ * Conversation message for context
34
+ */
35
+ export interface ConversationMessage {
36
+ role: 'user' | 'assistant' | 'system';
37
+ content: string;
38
+ }
39
+ /**
40
+ * Request to analyze a detection with LLM
41
+ */
42
+ export interface LLMAnalysisRequest {
43
+ /** The detection to analyze */
44
+ detection: Detection;
45
+ /** Context of the tool call that triggered the detection */
46
+ context: ToolCallContext;
47
+ /** Optional conversation history for additional context */
48
+ conversationHistory?: ConversationMessage[];
49
+ }
50
+ /**
51
+ * Optional OpenClaw API interface (for real LLM integration)
52
+ */
53
+ export interface OpenClawAPI {
54
+ /** Send a prompt to the LLM and get a response */
55
+ complete(prompt: string, options?: {
56
+ model?: string | null;
57
+ timeout?: number;
58
+ }): Promise<string>;
59
+ /** Check if the API is available */
60
+ isAvailable(): boolean;
61
+ }
62
+ /** Default timeout for LLM requests (30 seconds) */
63
+ export declare const DEFAULT_LLM_TIMEOUT_MS = 30000;
64
+ /** Default TTL for LLM response cache (5 minutes - longer than detection cache) */
65
+ export declare const DEFAULT_LLM_CACHE_TTL_MS: number;
66
+ /** Maximum cache size for LLM responses */
67
+ export declare const MAX_LLM_CACHE_SIZE = 500;
68
+ /**
69
+ * Generic in-memory cache for LLM responses
70
+ */
71
+ export declare class LLMResponseCache {
72
+ private cache;
73
+ private defaultTtl;
74
+ constructor(defaultTtlMs?: number);
75
+ /**
76
+ * Generate a cache key from the request
77
+ */
78
+ generateKey(request: LLMAnalysisRequest): string;
79
+ /**
80
+ * Get a cached result
81
+ */
82
+ get(key: string): LLMAnalysisResult | undefined;
83
+ /**
84
+ * Set a cached result
85
+ */
86
+ set(key: string, result: LLMAnalysisResult, ttl?: number): void;
87
+ /**
88
+ * Check if a key exists and is not expired
89
+ */
90
+ has(key: string): boolean;
91
+ /**
92
+ * Clear all entries
93
+ */
94
+ clear(): void;
95
+ /**
96
+ * Get cache size
97
+ */
98
+ size(): number;
99
+ private isExpired;
100
+ private evictExpired;
101
+ private evictOldest;
102
+ }
103
+ /**
104
+ * Build a prompt for LLM analysis of a security detection
105
+ */
106
+ export declare function buildAnalysisPrompt(request: LLMAnalysisRequest): string;
107
+ /**
108
+ * Parse LLM response to extract structured result
109
+ */
110
+ export declare function parseAnalysisResponse(response: string): LLMAnalysisResult;
111
+ /**
112
+ * Configuration for the LLM client
113
+ */
114
+ export interface LLMClientConfig {
115
+ /** LLM configuration from ClawsecConfig */
116
+ llmConfig: LLMConfig;
117
+ /** Optional timeout in milliseconds */
118
+ timeoutMs?: number;
119
+ /** Optional cache TTL in milliseconds */
120
+ cacheTtlMs?: number;
121
+ /** Whether to enable caching */
122
+ enableCache?: boolean;
123
+ }
124
+ /**
125
+ * Real LLM client that uses OpenClaw API
126
+ */
127
+ export declare class OpenClawLLMClient implements LLMClient {
128
+ private api;
129
+ private model;
130
+ private timeoutMs;
131
+ private cache;
132
+ private cacheTtlMs;
133
+ constructor(api: OpenClawAPI, config: LLMClientConfig);
134
+ isAvailable(): boolean;
135
+ analyze(request: LLMAnalysisRequest): Promise<LLMAnalysisResult>;
136
+ /**
137
+ * Clear the response cache
138
+ */
139
+ clearCache(): void;
140
+ /**
141
+ * Get cache statistics
142
+ */
143
+ getCacheStats(): {
144
+ size: number;
145
+ enabled: boolean;
146
+ };
147
+ }
148
+ /**
149
+ * Mock LLM client for testing
150
+ * Provides deterministic responses based on detection characteristics
151
+ */
152
+ export declare class MockLLMClient implements LLMClient {
153
+ private available;
154
+ private responseDelay;
155
+ private cache;
156
+ private customResponses;
157
+ constructor(options?: {
158
+ available?: boolean;
159
+ responseDelay?: number;
160
+ enableCache?: boolean;
161
+ cacheTtlMs?: number;
162
+ });
163
+ isAvailable(): boolean;
164
+ /**
165
+ * Set availability for testing
166
+ */
167
+ setAvailable(available: boolean): void;
168
+ /**
169
+ * Set a custom response for a specific category
170
+ */
171
+ setCustomResponse(category: string, response: LLMAnalysisResult): void;
172
+ analyze(request: LLMAnalysisRequest): Promise<LLMAnalysisResult>;
173
+ /**
174
+ * Generate a mock response based on detection characteristics
175
+ */
176
+ private generateMockResponse;
177
+ /**
178
+ * Clear the response cache
179
+ */
180
+ clearCache(): void;
181
+ /**
182
+ * Get cache statistics
183
+ */
184
+ getCacheStats(): {
185
+ size: number;
186
+ enabled: boolean;
187
+ };
188
+ }
189
+ /**
190
+ * Create an LLM client
191
+ *
192
+ * @param config - LLM client configuration
193
+ * @param api - Optional OpenClaw API instance (if available, creates real client)
194
+ * @returns LLM client instance
195
+ */
196
+ export declare function createLLMClient(config: LLMClientConfig, api?: OpenClawAPI): LLMClient;
197
+ /**
198
+ * Create a mock LLM client for testing
199
+ */
200
+ export declare function createMockLLMClient(options?: {
201
+ available?: boolean;
202
+ responseDelay?: number;
203
+ enableCache?: boolean;
204
+ cacheTtlMs?: number;
205
+ }): MockLLMClient;
206
+ /**
207
+ * Create an unavailable LLM client (always returns uncertain)
208
+ */
209
+ export declare function createUnavailableLLMClient(): LLMClient;
210
+ //# sourceMappingURL=llm-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"llm-client.d.ts","sourceRoot":"","sources":["../../../src/engine/llm-client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE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