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.
- package/README.md +560 -0
- package/dist/bin/clawsec.d.ts +7 -0
- package/dist/bin/clawsec.d.ts.map +1 -0
- package/dist/bin/clawsec.js +12 -0
- package/dist/bin/clawsec.js.map +1 -0
- package/dist/src/actions/block.d.ts +22 -0
- package/dist/src/actions/block.d.ts.map +1 -0
- package/dist/src/actions/block.js +83 -0
- package/dist/src/actions/block.js.map +1 -0
- package/dist/src/actions/confirm.d.ts +35 -0
- package/dist/src/actions/confirm.d.ts.map +1 -0
- package/dist/src/actions/confirm.js +156 -0
- package/dist/src/actions/confirm.js.map +1 -0
- package/dist/src/actions/executor.d.ts +64 -0
- package/dist/src/actions/executor.d.ts.map +1 -0
- package/dist/src/actions/executor.js +114 -0
- package/dist/src/actions/executor.js.map +1 -0
- package/dist/src/actions/index.d.ts +13 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +15 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/actions/log.d.ts +19 -0
- package/dist/src/actions/log.d.ts.map +1 -0
- package/dist/src/actions/log.js +63 -0
- package/dist/src/actions/log.js.map +1 -0
- package/dist/src/actions/types.d.ts +85 -0
- package/dist/src/actions/types.d.ts.map +1 -0
- package/dist/src/actions/types.js +78 -0
- package/dist/src/actions/types.js.map +1 -0
- package/dist/src/actions/warn.d.ts +22 -0
- package/dist/src/actions/warn.d.ts.map +1 -0
- package/dist/src/actions/warn.js +84 -0
- package/dist/src/actions/warn.js.map +1 -0
- package/dist/src/approval/agent-confirm.d.ts +104 -0
- package/dist/src/approval/agent-confirm.d.ts.map +1 -0
- package/dist/src/approval/agent-confirm.js +173 -0
- package/dist/src/approval/agent-confirm.js.map +1 -0
- package/dist/src/approval/index.d.ts +14 -0
- package/dist/src/approval/index.d.ts.map +1 -0
- package/dist/src/approval/index.js +9 -0
- package/dist/src/approval/index.js.map +1 -0
- package/dist/src/approval/native.d.ts +56 -0
- package/dist/src/approval/native.d.ts.map +1 -0
- package/dist/src/approval/native.js +196 -0
- package/dist/src/approval/native.js.map +1 -0
- package/dist/src/approval/store.d.ts +88 -0
- package/dist/src/approval/store.d.ts.map +1 -0
- package/dist/src/approval/store.js +192 -0
- package/dist/src/approval/store.js.map +1 -0
- package/dist/src/approval/types.d.ts +119 -0
- package/dist/src/approval/types.d.ts.map +1 -0
- package/dist/src/approval/types.js +6 -0
- package/dist/src/approval/types.js.map +1 -0
- package/dist/src/approval/webhook.d.ts +170 -0
- package/dist/src/approval/webhook.d.ts.map +1 -0
- package/dist/src/approval/webhook.js +362 -0
- package/dist/src/approval/webhook.js.map +1 -0
- package/dist/src/cli/commands/audit.d.ts +43 -0
- package/dist/src/cli/commands/audit.d.ts.map +1 -0
- package/dist/src/cli/commands/audit.js +115 -0
- package/dist/src/cli/commands/audit.js.map +1 -0
- package/dist/src/cli/commands/feedback.d.ts +27 -0
- package/dist/src/cli/commands/feedback.d.ts.map +1 -0
- package/dist/src/cli/commands/feedback.js +228 -0
- package/dist/src/cli/commands/feedback.js.map +1 -0
- package/dist/src/cli/commands/index.d.ts +11 -0
- package/dist/src/cli/commands/index.d.ts.map +1 -0
- package/dist/src/cli/commands/index.js +13 -0
- package/dist/src/cli/commands/index.js.map +1 -0
- package/dist/src/cli/commands/status.d.ts +20 -0
- package/dist/src/cli/commands/status.d.ts.map +1 -0
- package/dist/src/cli/commands/status.js +122 -0
- package/dist/src/cli/commands/status.js.map +1 -0
- package/dist/src/cli/commands/test.d.ts +23 -0
- package/dist/src/cli/commands/test.d.ts.map +1 -0
- package/dist/src/cli/commands/test.js +134 -0
- package/dist/src/cli/commands/test.js.map +1 -0
- package/dist/src/cli/commands/types.d.ts +81 -0
- package/dist/src/cli/commands/types.d.ts.map +1 -0
- package/dist/src/cli/commands/types.js +6 -0
- package/dist/src/cli/commands/types.js.map +1 -0
- package/dist/src/cli/index.d.ts +17 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +267 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/config/defaults.d.ts +20 -0
- package/dist/src/config/defaults.d.ts.map +1 -0
- package/dist/src/config/defaults.js +123 -0
- package/dist/src/config/defaults.js.map +1 -0
- package/dist/src/config/index.d.ts +8 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +41 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/config/loader.d.ts +99 -0
- package/dist/src/config/loader.d.ts.map +1 -0
- package/dist/src/config/loader.js +242 -0
- package/dist/src/config/loader.js.map +1 -0
- package/dist/src/config/schema.d.ts +627 -0
- package/dist/src/config/schema.d.ts.map +1 -0
- package/dist/src/config/schema.js +585 -0
- package/dist/src/config/schema.js.map +1 -0
- package/dist/src/detectors/destructive/cloud-detector.d.ts +51 -0
- package/dist/src/detectors/destructive/cloud-detector.d.ts.map +1 -0
- package/dist/src/detectors/destructive/cloud-detector.js +556 -0
- package/dist/src/detectors/destructive/cloud-detector.js.map +1 -0
- package/dist/src/detectors/destructive/code-detector.d.ts +59 -0
- package/dist/src/detectors/destructive/code-detector.d.ts.map +1 -0
- package/dist/src/detectors/destructive/code-detector.js +558 -0
- package/dist/src/detectors/destructive/code-detector.js.map +1 -0
- package/dist/src/detectors/destructive/index.d.ts +54 -0
- package/dist/src/detectors/destructive/index.d.ts.map +1 -0
- package/dist/src/detectors/destructive/index.js +168 -0
- package/dist/src/detectors/destructive/index.js.map +1 -0
- package/dist/src/detectors/destructive/shell-detector.d.ts +43 -0
- package/dist/src/detectors/destructive/shell-detector.d.ts.map +1 -0
- package/dist/src/detectors/destructive/shell-detector.js +302 -0
- package/dist/src/detectors/destructive/shell-detector.js.map +1 -0
- package/dist/src/detectors/destructive/types.d.ts +143 -0
- package/dist/src/detectors/destructive/types.d.ts.map +1 -0
- package/dist/src/detectors/destructive/types.js +6 -0
- package/dist/src/detectors/destructive/types.js.map +1 -0
- package/dist/src/detectors/exfiltration/cloud-detector.d.ts +51 -0
- package/dist/src/detectors/exfiltration/cloud-detector.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/cloud-detector.js +427 -0
- package/dist/src/detectors/exfiltration/cloud-detector.js.map +1 -0
- package/dist/src/detectors/exfiltration/http-detector.d.ts +47 -0
- package/dist/src/detectors/exfiltration/http-detector.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/http-detector.js +429 -0
- package/dist/src/detectors/exfiltration/http-detector.js.map +1 -0
- package/dist/src/detectors/exfiltration/index.d.ts +44 -0
- package/dist/src/detectors/exfiltration/index.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/index.js +118 -0
- package/dist/src/detectors/exfiltration/index.js.map +1 -0
- package/dist/src/detectors/exfiltration/network-detector.d.ts +55 -0
- package/dist/src/detectors/exfiltration/network-detector.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/network-detector.js +504 -0
- package/dist/src/detectors/exfiltration/network-detector.js.map +1 -0
- package/dist/src/detectors/exfiltration/types.d.ts +139 -0
- package/dist/src/detectors/exfiltration/types.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/types.js +6 -0
- package/dist/src/detectors/exfiltration/types.js.map +1 -0
- package/dist/src/detectors/purchase/domain-detector.d.ts +44 -0
- package/dist/src/detectors/purchase/domain-detector.d.ts.map +1 -0
- package/dist/src/detectors/purchase/domain-detector.js +296 -0
- package/dist/src/detectors/purchase/domain-detector.js.map +1 -0
- package/dist/src/detectors/purchase/form-detector.d.ts +27 -0
- package/dist/src/detectors/purchase/form-detector.d.ts.map +1 -0
- package/dist/src/detectors/purchase/form-detector.js +344 -0
- package/dist/src/detectors/purchase/form-detector.js.map +1 -0
- package/dist/src/detectors/purchase/index.d.ts +65 -0
- package/dist/src/detectors/purchase/index.d.ts.map +1 -0
- package/dist/src/detectors/purchase/index.js +216 -0
- package/dist/src/detectors/purchase/index.js.map +1 -0
- package/dist/src/detectors/purchase/spend-tracker.d.ts +132 -0
- package/dist/src/detectors/purchase/spend-tracker.d.ts.map +1 -0
- package/dist/src/detectors/purchase/spend-tracker.js +313 -0
- package/dist/src/detectors/purchase/spend-tracker.js.map +1 -0
- package/dist/src/detectors/purchase/types.d.ts +139 -0
- package/dist/src/detectors/purchase/types.d.ts.map +1 -0
- package/dist/src/detectors/purchase/types.js +6 -0
- package/dist/src/detectors/purchase/types.js.map +1 -0
- package/dist/src/detectors/purchase/url-detector.d.ts +31 -0
- package/dist/src/detectors/purchase/url-detector.d.ts.map +1 -0
- package/dist/src/detectors/purchase/url-detector.js +292 -0
- package/dist/src/detectors/purchase/url-detector.js.map +1 -0
- package/dist/src/detectors/secrets/api-key-detector.d.ts +30 -0
- package/dist/src/detectors/secrets/api-key-detector.d.ts.map +1 -0
- package/dist/src/detectors/secrets/api-key-detector.js +297 -0
- package/dist/src/detectors/secrets/api-key-detector.js.map +1 -0
- package/dist/src/detectors/secrets/index.d.ts +43 -0
- package/dist/src/detectors/secrets/index.d.ts.map +1 -0
- package/dist/src/detectors/secrets/index.js +261 -0
- package/dist/src/detectors/secrets/index.js.map +1 -0
- package/dist/src/detectors/secrets/pii-detector.d.ts +54 -0
- package/dist/src/detectors/secrets/pii-detector.d.ts.map +1 -0
- package/dist/src/detectors/secrets/pii-detector.js +286 -0
- package/dist/src/detectors/secrets/pii-detector.js.map +1 -0
- package/dist/src/detectors/secrets/token-detector.d.ts +51 -0
- package/dist/src/detectors/secrets/token-detector.d.ts.map +1 -0
- package/dist/src/detectors/secrets/token-detector.js +233 -0
- package/dist/src/detectors/secrets/token-detector.js.map +1 -0
- package/dist/src/detectors/secrets/types.d.ts +157 -0
- package/dist/src/detectors/secrets/types.d.ts.map +1 -0
- package/dist/src/detectors/secrets/types.js +6 -0
- package/dist/src/detectors/secrets/types.js.map +1 -0
- package/dist/src/detectors/website/category-detector.d.ts +22 -0
- package/dist/src/detectors/website/category-detector.d.ts.map +1 -0
- package/dist/src/detectors/website/category-detector.js +162 -0
- package/dist/src/detectors/website/category-detector.js.map +1 -0
- package/dist/src/detectors/website/index.d.ts +53 -0
- package/dist/src/detectors/website/index.d.ts.map +1 -0
- package/dist/src/detectors/website/index.js +232 -0
- package/dist/src/detectors/website/index.js.map +1 -0
- package/dist/src/detectors/website/pattern-matcher.d.ts +33 -0
- package/dist/src/detectors/website/pattern-matcher.d.ts.map +1 -0
- package/dist/src/detectors/website/pattern-matcher.js +121 -0
- package/dist/src/detectors/website/pattern-matcher.js.map +1 -0
- package/dist/src/detectors/website/types.d.ts +105 -0
- package/dist/src/detectors/website/types.d.ts.map +1 -0
- package/dist/src/detectors/website/types.js +6 -0
- package/dist/src/detectors/website/types.js.map +1 -0
- package/dist/src/engine/analyzer.d.ts +87 -0
- package/dist/src/engine/analyzer.d.ts.map +1 -0
- package/dist/src/engine/analyzer.js +427 -0
- package/dist/src/engine/analyzer.js.map +1 -0
- package/dist/src/engine/cache.d.ts +80 -0
- package/dist/src/engine/cache.d.ts.map +1 -0
- package/dist/src/engine/cache.js +167 -0
- package/dist/src/engine/cache.js.map +1 -0
- package/dist/src/engine/index.d.ts +11 -0
- package/dist/src/engine/index.d.ts.map +1 -0
- package/dist/src/engine/index.js +11 -0
- package/dist/src/engine/index.js.map +1 -0
- package/dist/src/engine/llm-client.d.ts +210 -0
- package/dist/src/engine/llm-client.d.ts.map +1 -0
- package/dist/src/engine/llm-client.js +506 -0
- package/dist/src/engine/llm-client.js.map +1 -0
- package/dist/src/engine/types.d.ts +163 -0
- package/dist/src/engine/types.d.ts.map +1 -0
- package/dist/src/engine/types.js +21 -0
- package/dist/src/engine/types.js.map +1 -0
- package/dist/src/feedback/index.d.ts +9 -0
- package/dist/src/feedback/index.d.ts.map +1 -0
- package/dist/src/feedback/index.js +8 -0
- package/dist/src/feedback/index.js.map +1 -0
- package/dist/src/feedback/learner.d.ts +222 -0
- package/dist/src/feedback/learner.d.ts.map +1 -0
- package/dist/src/feedback/learner.js +401 -0
- package/dist/src/feedback/learner.js.map +1 -0
- package/dist/src/feedback/store.d.ts +113 -0
- package/dist/src/feedback/store.d.ts.map +1 -0
- package/dist/src/feedback/store.js +228 -0
- package/dist/src/feedback/store.js.map +1 -0
- package/dist/src/feedback/types.d.ts +126 -0
- package/dist/src/feedback/types.d.ts.map +1 -0
- package/dist/src/feedback/types.js +6 -0
- package/dist/src/feedback/types.js.map +1 -0
- package/dist/src/hooks/before-agent-start/handler.d.ts +37 -0
- package/dist/src/hooks/before-agent-start/handler.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start/handler.js +109 -0
- package/dist/src/hooks/before-agent-start/handler.js.map +1 -0
- package/dist/src/hooks/before-agent-start/index.d.ts +8 -0
- package/dist/src/hooks/before-agent-start/index.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start/index.js +7 -0
- package/dist/src/hooks/before-agent-start/index.js.map +1 -0
- package/dist/src/hooks/before-agent-start/prompts.d.ts +48 -0
- package/dist/src/hooks/before-agent-start/prompts.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start/prompts.js +103 -0
- package/dist/src/hooks/before-agent-start/prompts.js.map +1 -0
- package/dist/src/hooks/before-tool-call/handler.d.ts +42 -0
- package/dist/src/hooks/before-tool-call/handler.d.ts.map +1 -0
- package/dist/src/hooks/before-tool-call/handler.js +226 -0
- package/dist/src/hooks/before-tool-call/handler.js.map +1 -0
- package/dist/src/hooks/before-tool-call/index.d.ts +7 -0
- package/dist/src/hooks/before-tool-call/index.d.ts.map +1 -0
- package/dist/src/hooks/before-tool-call/index.js +6 -0
- package/dist/src/hooks/before-tool-call/index.js.map +1 -0
- package/dist/src/hooks/tool-result-persist/filter.d.ts +72 -0
- package/dist/src/hooks/tool-result-persist/filter.d.ts.map +1 -0
- package/dist/src/hooks/tool-result-persist/filter.js +305 -0
- package/dist/src/hooks/tool-result-persist/filter.js.map +1 -0
- package/dist/src/hooks/tool-result-persist/handler.d.ts +49 -0
- package/dist/src/hooks/tool-result-persist/handler.d.ts.map +1 -0
- package/dist/src/hooks/tool-result-persist/handler.js +217 -0
- package/dist/src/hooks/tool-result-persist/handler.js.map +1 -0
- package/dist/src/hooks/tool-result-persist/index.d.ts +11 -0
- package/dist/src/hooks/tool-result-persist/index.d.ts.map +1 -0
- package/dist/src/hooks/tool-result-persist/index.js +11 -0
- package/dist/src/hooks/tool-result-persist/index.js.map +1 -0
- package/dist/src/index.d.ts +256 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +222 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/notifications/discord.d.ts +10 -0
- package/dist/src/notifications/discord.d.ts.map +1 -0
- package/dist/src/notifications/discord.js +218 -0
- package/dist/src/notifications/discord.js.map +1 -0
- package/dist/src/notifications/index.d.ts +37 -0
- package/dist/src/notifications/index.d.ts.map +1 -0
- package/dist/src/notifications/index.js +68 -0
- package/dist/src/notifications/index.js.map +1 -0
- package/dist/src/notifications/slack.d.ts +10 -0
- package/dist/src/notifications/slack.d.ts.map +1 -0
- package/dist/src/notifications/slack.js +218 -0
- package/dist/src/notifications/slack.js.map +1 -0
- package/dist/src/notifications/telegram.d.ts +10 -0
- package/dist/src/notifications/telegram.d.ts.map +1 -0
- package/dist/src/notifications/telegram.js +242 -0
- package/dist/src/notifications/telegram.js.map +1 -0
- package/dist/src/notifications/types.d.ts +119 -0
- package/dist/src/notifications/types.d.ts.map +1 -0
- package/dist/src/notifications/types.js +6 -0
- package/dist/src/notifications/types.js.map +1 -0
- package/dist/src/proxy/index.d.ts +8 -0
- package/dist/src/proxy/index.d.ts.map +1 -0
- package/dist/src/proxy/index.js +9 -0
- package/dist/src/proxy/index.js.map +1 -0
- package/dist/src/proxy/middleware.d.ts +55 -0
- package/dist/src/proxy/middleware.d.ts.map +1 -0
- package/dist/src/proxy/middleware.js +215 -0
- package/dist/src/proxy/middleware.js.map +1 -0
- package/dist/src/proxy/server.d.ts +57 -0
- package/dist/src/proxy/server.d.ts.map +1 -0
- package/dist/src/proxy/server.js +298 -0
- package/dist/src/proxy/server.js.map +1 -0
- package/dist/src/proxy/types.d.ts +136 -0
- package/dist/src/proxy/types.d.ts.map +1 -0
- package/dist/src/proxy/types.js +6 -0
- package/dist/src/proxy/types.js.map +1 -0
- package/dist/src/sanitization/index.d.ts +10 -0
- package/dist/src/sanitization/index.d.ts.map +1 -0
- package/dist/src/sanitization/index.js +9 -0
- package/dist/src/sanitization/index.js.map +1 -0
- package/dist/src/sanitization/patterns.d.ts +51 -0
- package/dist/src/sanitization/patterns.d.ts.map +1 -0
- package/dist/src/sanitization/patterns.js +266 -0
- package/dist/src/sanitization/patterns.js.map +1 -0
- package/dist/src/sanitization/scanner.d.ts +29 -0
- package/dist/src/sanitization/scanner.d.ts.map +1 -0
- package/dist/src/sanitization/scanner.js +328 -0
- package/dist/src/sanitization/scanner.js.map +1 -0
- package/dist/src/sanitization/types.d.ts +57 -0
- package/dist/src/sanitization/types.d.ts.map +1 -0
- package/dist/src/sanitization/types.js +5 -0
- package/dist/src/sanitization/types.js.map +1 -0
- package/openclaw.plugin.json +114 -0
- package/package.json +63 -0
- package/rules/builtin/README.md +139 -0
- package/rules/builtin/ai-services.yaml +70 -0
- package/rules/builtin/api-keys.yaml +64 -0
- package/rules/builtin/authentication.yaml +56 -0
- package/rules/builtin/aws-security.yaml +57 -0
- package/rules/builtin/azure-security.yaml +58 -0
- package/rules/builtin/cicd-security.yaml +64 -0
- package/rules/builtin/cloud-storage.yaml +64 -0
- package/rules/builtin/container-registry.yaml +55 -0
- package/rules/builtin/crypto-wallets.yaml +71 -0
- package/rules/builtin/database-nosql.yaml +58 -0
- package/rules/builtin/database-sql.yaml +62 -0
- package/rules/builtin/development-env.yaml +67 -0
- package/rules/builtin/docker.yaml +57 -0
- package/rules/builtin/filesystem.yaml +71 -0
- package/rules/builtin/financial-pci.yaml +61 -0
- package/rules/builtin/gcp-security.yaml +57 -0
- package/rules/builtin/git-operations.yaml +68 -0
- package/rules/builtin/healthcare-hipaa.yaml +64 -0
- package/rules/builtin/kubernetes.yaml +60 -0
- package/rules/builtin/messaging-services.yaml +53 -0
- package/rules/builtin/minimal.yaml +47 -0
- package/rules/builtin/mobile-development.yaml +61 -0
- package/rules/builtin/monitoring.yaml +63 -0
- package/rules/builtin/network-security.yaml +57 -0
- package/rules/builtin/package-managers.yaml +74 -0
- package/rules/builtin/payment-processing.yaml +66 -0
- package/rules/builtin/pii-protection.yaml +48 -0
- package/rules/builtin/production-strict.yaml +55 -0
- package/rules/builtin/secrets-management.yaml +63 -0
- package/rules/builtin/serverless.yaml +74 -0
- package/rules/builtin/ssh-security.yaml +66 -0
- package/rules/builtin/terraform.yaml +51 -0
- package/rules/builtin/web-security.yaml +62 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Filtering Logic for Tool Result Persist Hook
|
|
3
|
+
*
|
|
4
|
+
* Scans tool outputs for secrets/PII and redacts sensitive data
|
|
5
|
+
* before it's persisted.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Common secret patterns for direct text scanning
|
|
9
|
+
* These are simplified patterns - the main detection is done by the secrets detector
|
|
10
|
+
*/
|
|
11
|
+
const SECRET_PATTERNS = [
|
|
12
|
+
// OpenAI API keys
|
|
13
|
+
{
|
|
14
|
+
pattern: /sk-[a-zA-Z0-9]{20,}/g,
|
|
15
|
+
type: 'openai-api-key',
|
|
16
|
+
description: 'OpenAI API key',
|
|
17
|
+
},
|
|
18
|
+
// Anthropic API keys
|
|
19
|
+
{
|
|
20
|
+
pattern: /sk-ant-[a-zA-Z0-9-]{20,}/g,
|
|
21
|
+
type: 'anthropic-api-key',
|
|
22
|
+
description: 'Anthropic API key',
|
|
23
|
+
},
|
|
24
|
+
// AWS Access Key ID
|
|
25
|
+
{
|
|
26
|
+
pattern: /AKIA[0-9A-Z]{16}/g,
|
|
27
|
+
type: 'aws-access-key',
|
|
28
|
+
description: 'AWS access key ID',
|
|
29
|
+
},
|
|
30
|
+
// AWS Secret Access Key (context-based)
|
|
31
|
+
{
|
|
32
|
+
pattern: /(?:aws[_-]?secret[_-]?access[_-]?key|secret[_-]?key)\s*[:=]\s*['"]?([A-Za-z0-9/+=]{40})['"]?/gi,
|
|
33
|
+
type: 'aws-secret-key',
|
|
34
|
+
description: 'AWS secret access key',
|
|
35
|
+
},
|
|
36
|
+
// GitHub tokens
|
|
37
|
+
{
|
|
38
|
+
pattern: /gh[pous]_[a-zA-Z0-9]{36,}/g,
|
|
39
|
+
type: 'github-token',
|
|
40
|
+
description: 'GitHub token',
|
|
41
|
+
},
|
|
42
|
+
// GitHub classic tokens
|
|
43
|
+
{
|
|
44
|
+
pattern: /ghp_[a-zA-Z0-9]{36}/g,
|
|
45
|
+
type: 'github-pat',
|
|
46
|
+
description: 'GitHub personal access token',
|
|
47
|
+
},
|
|
48
|
+
// Stripe API keys
|
|
49
|
+
{
|
|
50
|
+
pattern: /sk_live_[a-zA-Z0-9]{24,}/g,
|
|
51
|
+
type: 'stripe-api-key',
|
|
52
|
+
description: 'Stripe live API key',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
pattern: /sk_test_[a-zA-Z0-9]{24,}/g,
|
|
56
|
+
type: 'stripe-test-key',
|
|
57
|
+
description: 'Stripe test API key',
|
|
58
|
+
},
|
|
59
|
+
// Slack tokens
|
|
60
|
+
{
|
|
61
|
+
pattern: /xox[baprs]-[0-9]{10,}-[0-9]{10,}-[a-zA-Z0-9]{24,}/g,
|
|
62
|
+
type: 'slack-token',
|
|
63
|
+
description: 'Slack token',
|
|
64
|
+
},
|
|
65
|
+
// Google API keys
|
|
66
|
+
{
|
|
67
|
+
pattern: /AIza[0-9A-Za-z_-]{35}/g,
|
|
68
|
+
type: 'google-api-key',
|
|
69
|
+
description: 'Google API key',
|
|
70
|
+
},
|
|
71
|
+
// JWT tokens
|
|
72
|
+
{
|
|
73
|
+
pattern: /eyJ[a-zA-Z0-9_-]*\.eyJ[a-zA-Z0-9_-]*\.[a-zA-Z0-9_-]*/g,
|
|
74
|
+
type: 'jwt',
|
|
75
|
+
description: 'JWT token',
|
|
76
|
+
},
|
|
77
|
+
// Bearer tokens
|
|
78
|
+
{
|
|
79
|
+
pattern: /Bearer\s+[a-zA-Z0-9_-]{20,}/gi,
|
|
80
|
+
type: 'bearer-token',
|
|
81
|
+
description: 'Bearer token',
|
|
82
|
+
},
|
|
83
|
+
// SSN (Social Security Number)
|
|
84
|
+
{
|
|
85
|
+
pattern: /\b\d{3}-\d{2}-\d{4}\b/g,
|
|
86
|
+
type: 'ssn',
|
|
87
|
+
description: 'Social Security Number',
|
|
88
|
+
},
|
|
89
|
+
// Credit card numbers (basic patterns)
|
|
90
|
+
{
|
|
91
|
+
pattern: /\b4[0-9]{3}[- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}\b/g,
|
|
92
|
+
type: 'credit-card',
|
|
93
|
+
description: 'Credit card number (Visa)',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
pattern: /\b5[1-5][0-9]{2}[- ]?[0-9]{4}[- ]?[0-9]{4}[- ]?[0-9]{4}\b/g,
|
|
97
|
+
type: 'credit-card',
|
|
98
|
+
description: 'Credit card number (Mastercard)',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
pattern: /\b3[47][0-9]{2}[- ]?[0-9]{6}[- ]?[0-9]{5}\b/g,
|
|
102
|
+
type: 'credit-card',
|
|
103
|
+
description: 'Credit card number (Amex)',
|
|
104
|
+
},
|
|
105
|
+
// Private keys
|
|
106
|
+
{
|
|
107
|
+
pattern: /-----BEGIN (?:RSA |DSA |EC |OPENSSH )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |DSA |EC |OPENSSH )?PRIVATE KEY-----/g,
|
|
108
|
+
type: 'private-key',
|
|
109
|
+
description: 'Private key',
|
|
110
|
+
},
|
|
111
|
+
// Generic API key patterns
|
|
112
|
+
{
|
|
113
|
+
pattern: /(?:api[_-]?key|apikey)\s*[:=]\s*['"]?([a-zA-Z0-9_-]{20,})['"]?/gi,
|
|
114
|
+
type: 'generic-api-key',
|
|
115
|
+
description: 'Generic API key',
|
|
116
|
+
},
|
|
117
|
+
// Generic secret/password patterns
|
|
118
|
+
{
|
|
119
|
+
pattern: /(?:password|passwd|pwd|secret)\s*[:=]\s*['"]?([^\s'"]{8,})['"]?/gi,
|
|
120
|
+
type: 'password',
|
|
121
|
+
description: 'Password or secret',
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
/**
|
|
125
|
+
* Redact a single string value using pattern matching
|
|
126
|
+
*
|
|
127
|
+
* @param text - The text to scan and redact
|
|
128
|
+
* @returns FilterResult with redacted text and list of redactions
|
|
129
|
+
*/
|
|
130
|
+
export function redactString(text) {
|
|
131
|
+
const redactions = [];
|
|
132
|
+
let filteredText = text;
|
|
133
|
+
// Track which redactions we've already recorded to avoid duplicates
|
|
134
|
+
const recordedTypes = new Set();
|
|
135
|
+
for (const secretPattern of SECRET_PATTERNS) {
|
|
136
|
+
// Reset the pattern's lastIndex in case it was used before
|
|
137
|
+
secretPattern.pattern.lastIndex = 0;
|
|
138
|
+
// Check if pattern matches
|
|
139
|
+
const matches = filteredText.match(secretPattern.pattern);
|
|
140
|
+
if (matches && matches.length > 0) {
|
|
141
|
+
// Replace all matches
|
|
142
|
+
filteredText = filteredText.replace(secretPattern.pattern, `[REDACTED:${secretPattern.type}]`);
|
|
143
|
+
// Record the redaction (only once per type)
|
|
144
|
+
if (!recordedTypes.has(secretPattern.type)) {
|
|
145
|
+
redactions.push({
|
|
146
|
+
type: secretPattern.type,
|
|
147
|
+
description: secretPattern.description,
|
|
148
|
+
});
|
|
149
|
+
recordedTypes.add(secretPattern.type);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
filteredOutput: filteredText,
|
|
155
|
+
redactions,
|
|
156
|
+
wasRedacted: redactions.length > 0,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Recursively filter an object, redacting secrets in string values
|
|
161
|
+
*
|
|
162
|
+
* @param obj - The object to filter
|
|
163
|
+
* @returns FilterResult with filtered object and aggregated redactions
|
|
164
|
+
*/
|
|
165
|
+
export function redactObject(obj) {
|
|
166
|
+
const redactions = [];
|
|
167
|
+
const recordedTypes = new Set();
|
|
168
|
+
const filtered = {};
|
|
169
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
170
|
+
const result = filterValue(value);
|
|
171
|
+
filtered[key] = result.filteredOutput;
|
|
172
|
+
// Aggregate redactions (avoiding duplicates)
|
|
173
|
+
for (const redaction of result.redactions) {
|
|
174
|
+
if (!recordedTypes.has(redaction.type)) {
|
|
175
|
+
redactions.push(redaction);
|
|
176
|
+
recordedTypes.add(redaction.type);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
filteredOutput: filtered,
|
|
182
|
+
redactions,
|
|
183
|
+
wasRedacted: redactions.length > 0,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Recursively filter an array, redacting secrets in string values
|
|
188
|
+
*
|
|
189
|
+
* @param arr - The array to filter
|
|
190
|
+
* @returns FilterResult with filtered array and aggregated redactions
|
|
191
|
+
*/
|
|
192
|
+
export function redactArray(arr) {
|
|
193
|
+
const redactions = [];
|
|
194
|
+
const recordedTypes = new Set();
|
|
195
|
+
const filtered = [];
|
|
196
|
+
for (const item of arr) {
|
|
197
|
+
const result = filterValue(item);
|
|
198
|
+
filtered.push(result.filteredOutput);
|
|
199
|
+
// Aggregate redactions (avoiding duplicates)
|
|
200
|
+
for (const redaction of result.redactions) {
|
|
201
|
+
if (!recordedTypes.has(redaction.type)) {
|
|
202
|
+
redactions.push(redaction);
|
|
203
|
+
recordedTypes.add(redaction.type);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
filteredOutput: filtered,
|
|
209
|
+
redactions,
|
|
210
|
+
wasRedacted: redactions.length > 0,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Filter any value, dispatching to the appropriate handler based on type
|
|
215
|
+
*
|
|
216
|
+
* @param value - The value to filter (can be any type)
|
|
217
|
+
* @returns FilterResult with filtered value and redactions
|
|
218
|
+
*/
|
|
219
|
+
export function filterValue(value) {
|
|
220
|
+
// Handle null/undefined
|
|
221
|
+
if (value === null || value === undefined) {
|
|
222
|
+
return {
|
|
223
|
+
filteredOutput: value,
|
|
224
|
+
redactions: [],
|
|
225
|
+
wasRedacted: false,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
// Handle strings
|
|
229
|
+
if (typeof value === 'string') {
|
|
230
|
+
return redactString(value);
|
|
231
|
+
}
|
|
232
|
+
// Handle arrays
|
|
233
|
+
if (Array.isArray(value)) {
|
|
234
|
+
return redactArray(value);
|
|
235
|
+
}
|
|
236
|
+
// Handle objects
|
|
237
|
+
if (typeof value === 'object') {
|
|
238
|
+
return redactObject(value);
|
|
239
|
+
}
|
|
240
|
+
// Pass through primitives (numbers, booleans, etc.)
|
|
241
|
+
return {
|
|
242
|
+
filteredOutput: value,
|
|
243
|
+
redactions: [],
|
|
244
|
+
wasRedacted: false,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Convert secrets detection results to redactions
|
|
249
|
+
*
|
|
250
|
+
* @param detections - Array of detection results from the secrets detector
|
|
251
|
+
* @returns Array of redactions based on the detections
|
|
252
|
+
*/
|
|
253
|
+
export function detectionsToRedactions(detections) {
|
|
254
|
+
const redactions = [];
|
|
255
|
+
const recordedTypes = new Set();
|
|
256
|
+
for (const detection of detections) {
|
|
257
|
+
if (!detection.detected || !detection.metadata) {
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
// Build type string from metadata
|
|
261
|
+
let type = detection.metadata.type;
|
|
262
|
+
if (detection.metadata.provider) {
|
|
263
|
+
type = `${detection.metadata.provider}-${type}`;
|
|
264
|
+
}
|
|
265
|
+
else if (detection.metadata.subtype) {
|
|
266
|
+
type = detection.metadata.subtype;
|
|
267
|
+
}
|
|
268
|
+
// Avoid duplicate redaction entries
|
|
269
|
+
if (!recordedTypes.has(type)) {
|
|
270
|
+
redactions.push({
|
|
271
|
+
type,
|
|
272
|
+
description: detection.reason,
|
|
273
|
+
});
|
|
274
|
+
recordedTypes.add(type);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return redactions;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Main filter function that combines pattern-based filtering
|
|
281
|
+
* with detection-based redaction info
|
|
282
|
+
*
|
|
283
|
+
* @param output - The tool output to filter
|
|
284
|
+
* @param detections - Optional array of detection results for more accurate redaction types
|
|
285
|
+
* @returns FilterResult with filtered output and redactions
|
|
286
|
+
*/
|
|
287
|
+
export function filterOutput(output, detections) {
|
|
288
|
+
// Filter the output using pattern matching
|
|
289
|
+
const filterResult = filterValue(output);
|
|
290
|
+
// If we have detections, enhance redaction list with more specific types
|
|
291
|
+
if (detections && detections.length > 0) {
|
|
292
|
+
const detectionRedactions = detectionsToRedactions(detections);
|
|
293
|
+
// Merge detection-based redactions with pattern-based redactions
|
|
294
|
+
// Detection-based are more authoritative
|
|
295
|
+
const recordedTypes = new Set(filterResult.redactions.map((r) => r.type));
|
|
296
|
+
for (const redaction of detectionRedactions) {
|
|
297
|
+
if (!recordedTypes.has(redaction.type)) {
|
|
298
|
+
filterResult.redactions.push(redaction);
|
|
299
|
+
recordedTypes.add(redaction.type);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return filterResult;
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../../src/hooks/tool-result-persist/filter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuCH;;;GAGG;AACH,MAAM,eAAe,GAAoB;IACvC,kBAAkB;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AAM,UAAU,YAAY,CAC1B,MAAe,EACf,UAAqC;IAErC,2CAA2C;IAC3C,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IAEzC,yEAAyE;IACzE,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;QAE/D,iEAAiE;QACjE,yCAAyC;QACzC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1E,KAAK,MAAM,SAAS,IAAI,mBAAmB,EAAE,CAAC;YAC5C,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;gBACvC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBACxC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Result Persist Hook Handler
|
|
3
|
+
*
|
|
4
|
+
* Hook handler that scans tool outputs for secrets/PII, prompt injections,
|
|
5
|
+
* and filters sensitive data before it's persisted.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolResultPersistHandler } from '../../index.js';
|
|
8
|
+
import type { ClawsecConfig } from '../../config/schema.js';
|
|
9
|
+
/**
|
|
10
|
+
* Options for creating a tool-result-persist handler
|
|
11
|
+
*/
|
|
12
|
+
export interface ToolResultPersistHandlerOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Whether to enable output filtering (redacting secrets)
|
|
15
|
+
* @default true
|
|
16
|
+
*/
|
|
17
|
+
filter?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to enable prompt injection scanning
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
scanInjections?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Create the tool-result-persist handler
|
|
26
|
+
*
|
|
27
|
+
* This handler runs after a tool executes but before the result is persisted.
|
|
28
|
+
* It scans the output for secrets/PII and prompt injections, then redacts
|
|
29
|
+
* or blocks sensitive data.
|
|
30
|
+
*
|
|
31
|
+
* Flow:
|
|
32
|
+
* 1. Check if plugin is enabled
|
|
33
|
+
* 2. Check if filtering/scanning is enabled
|
|
34
|
+
* 3. Run prompt injection scanner on tool output
|
|
35
|
+
* 4. If injection detected with block action, block the output
|
|
36
|
+
* 5. Run secrets detector on tool output
|
|
37
|
+
* 6. Filter output if secrets detected
|
|
38
|
+
* 7. Return result with filtered output and redaction metadata
|
|
39
|
+
*
|
|
40
|
+
* @param config - Clawsec configuration
|
|
41
|
+
* @param options - Optional handler options
|
|
42
|
+
* @returns ToolResultPersistHandler function
|
|
43
|
+
*/
|
|
44
|
+
export declare function createToolResultPersistHandler(config: ClawsecConfig, options?: ToolResultPersistHandlerOptions): ToolResultPersistHandler;
|
|
45
|
+
/**
|
|
46
|
+
* Create a default tool-result-persist handler with default configuration
|
|
47
|
+
*/
|
|
48
|
+
export declare function createDefaultToolResultPersistHandler(): ToolResultPersistHandler;
|
|
49
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/hooks/tool-result-persist/handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAGV,wBAAwB,EACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAO5D;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAkDD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,+BAA+B,GACxC,wBAAwB,CA6F1B;AAED;;GAEG;AACH,wBAAgB,qCAAqC,IAAI,wBAAwB,CAmEhF"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Result Persist Hook Handler
|
|
3
|
+
*
|
|
4
|
+
* Hook handler that scans tool outputs for secrets/PII, prompt injections,
|
|
5
|
+
* and filters sensitive data before it's persisted.
|
|
6
|
+
*/
|
|
7
|
+
import { createSecretsDetector } from '../../detectors/secrets/index.js';
|
|
8
|
+
import { scan, sanitize } from '../../sanitization/scanner.js';
|
|
9
|
+
import { filterOutput } from './filter.js';
|
|
10
|
+
/**
|
|
11
|
+
* Create an allow result with no filtering
|
|
12
|
+
*/
|
|
13
|
+
function createAllowResult() {
|
|
14
|
+
return {
|
|
15
|
+
allow: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a block result for detected prompt injections
|
|
20
|
+
*/
|
|
21
|
+
function createBlockResult(redactions) {
|
|
22
|
+
return {
|
|
23
|
+
allow: false,
|
|
24
|
+
redactions,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a result with filtered output and redaction info
|
|
29
|
+
*/
|
|
30
|
+
function createFilteredResult(filteredOutput, redactions) {
|
|
31
|
+
return {
|
|
32
|
+
allow: true,
|
|
33
|
+
filteredOutput,
|
|
34
|
+
redactions,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Convert tool output to string for scanning
|
|
39
|
+
*/
|
|
40
|
+
function outputToString(output) {
|
|
41
|
+
if (typeof output === 'string') {
|
|
42
|
+
return output;
|
|
43
|
+
}
|
|
44
|
+
if (output !== null && output !== undefined) {
|
|
45
|
+
return JSON.stringify(output);
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create the tool-result-persist handler
|
|
51
|
+
*
|
|
52
|
+
* This handler runs after a tool executes but before the result is persisted.
|
|
53
|
+
* It scans the output for secrets/PII and prompt injections, then redacts
|
|
54
|
+
* or blocks sensitive data.
|
|
55
|
+
*
|
|
56
|
+
* Flow:
|
|
57
|
+
* 1. Check if plugin is enabled
|
|
58
|
+
* 2. Check if filtering/scanning is enabled
|
|
59
|
+
* 3. Run prompt injection scanner on tool output
|
|
60
|
+
* 4. If injection detected with block action, block the output
|
|
61
|
+
* 5. Run secrets detector on tool output
|
|
62
|
+
* 6. Filter output if secrets detected
|
|
63
|
+
* 7. Return result with filtered output and redaction metadata
|
|
64
|
+
*
|
|
65
|
+
* @param config - Clawsec configuration
|
|
66
|
+
* @param options - Optional handler options
|
|
67
|
+
* @returns ToolResultPersistHandler function
|
|
68
|
+
*/
|
|
69
|
+
export function createToolResultPersistHandler(config, options) {
|
|
70
|
+
const filterEnabled = options?.filter ?? true;
|
|
71
|
+
const scanInjectionsEnabled = options?.scanInjections ?? true;
|
|
72
|
+
// Create secrets detector from config
|
|
73
|
+
const secretsDetector = createSecretsDetector({
|
|
74
|
+
enabled: config.rules?.secrets?.enabled ?? true,
|
|
75
|
+
severity: config.rules?.secrets?.severity ?? 'critical',
|
|
76
|
+
action: config.rules?.secrets?.action ?? 'block',
|
|
77
|
+
});
|
|
78
|
+
// Create scanner config from sanitization rules
|
|
79
|
+
const sanitizationConfig = config.rules?.sanitization;
|
|
80
|
+
const scannerConfig = {
|
|
81
|
+
enabled: sanitizationConfig?.enabled ?? true,
|
|
82
|
+
categories: {
|
|
83
|
+
instructionOverride: sanitizationConfig?.categories?.instructionOverride ?? true,
|
|
84
|
+
systemLeak: sanitizationConfig?.categories?.systemLeak ?? true,
|
|
85
|
+
jailbreak: sanitizationConfig?.categories?.jailbreak ?? true,
|
|
86
|
+
encodedPayload: sanitizationConfig?.categories?.encodedPayload ?? true,
|
|
87
|
+
},
|
|
88
|
+
minConfidence: sanitizationConfig?.minConfidence ?? 0.5,
|
|
89
|
+
redactMatches: sanitizationConfig?.redactMatches ?? false,
|
|
90
|
+
};
|
|
91
|
+
return async (context) => {
|
|
92
|
+
// 1. Check if plugin is globally disabled
|
|
93
|
+
if (config.global?.enabled === false) {
|
|
94
|
+
return createAllowResult();
|
|
95
|
+
}
|
|
96
|
+
// Convert output to string for scanning
|
|
97
|
+
const toolOutputString = outputToString(context.toolOutput);
|
|
98
|
+
// 2. Run prompt injection scanner if enabled
|
|
99
|
+
if (scanInjectionsEnabled && sanitizationConfig?.enabled !== false && toolOutputString) {
|
|
100
|
+
const scanResult = scan(toolOutputString, scannerConfig);
|
|
101
|
+
if (scanResult.hasInjection) {
|
|
102
|
+
const injectionRedactions = scanResult.matches.map(match => ({
|
|
103
|
+
type: `injection-${match.category}`,
|
|
104
|
+
description: `Prompt injection detected: ${match.match.substring(0, 50)}${match.match.length > 50 ? '...' : ''}`,
|
|
105
|
+
}));
|
|
106
|
+
// If action is 'block', reject the output entirely
|
|
107
|
+
if (sanitizationConfig?.action === 'block') {
|
|
108
|
+
return createBlockResult(injectionRedactions);
|
|
109
|
+
}
|
|
110
|
+
// If redactMatches is enabled, sanitize the output
|
|
111
|
+
if (sanitizationConfig?.redactMatches) {
|
|
112
|
+
const sanitizedOutput = sanitize(toolOutputString, scanResult.matches);
|
|
113
|
+
return createFilteredResult(sanitizedOutput, injectionRedactions);
|
|
114
|
+
}
|
|
115
|
+
// Otherwise, just log/warn and continue
|
|
116
|
+
// The redactions are passed for logging purposes
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// 3. Check if secrets filtering is disabled
|
|
120
|
+
if (!filterEnabled || config.rules?.secrets?.enabled === false) {
|
|
121
|
+
return createAllowResult();
|
|
122
|
+
}
|
|
123
|
+
// 4. Run secrets detector on the tool output
|
|
124
|
+
let detections = [];
|
|
125
|
+
try {
|
|
126
|
+
detections = await secretsDetector.detectAll({
|
|
127
|
+
toolName: context.toolName,
|
|
128
|
+
toolInput: context.toolInput,
|
|
129
|
+
toolOutput: toolOutputString,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
catch {
|
|
133
|
+
// If detection fails, allow the output through without filtering
|
|
134
|
+
// This ensures tool results aren't lost due to detector errors
|
|
135
|
+
return createAllowResult();
|
|
136
|
+
}
|
|
137
|
+
// 5. Filter output with pattern matching (catches secrets detector might have missed)
|
|
138
|
+
const filterResult = filterOutput(context.toolOutput, detections);
|
|
139
|
+
// 6. If nothing was redacted, allow through unchanged
|
|
140
|
+
if (!filterResult.wasRedacted) {
|
|
141
|
+
return createAllowResult();
|
|
142
|
+
}
|
|
143
|
+
// 7. Return filtered result with redaction metadata
|
|
144
|
+
return createFilteredResult(filterResult.filteredOutput, filterResult.redactions);
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Create a default tool-result-persist handler with default configuration
|
|
149
|
+
*/
|
|
150
|
+
export function createDefaultToolResultPersistHandler() {
|
|
151
|
+
const defaultConfig = {
|
|
152
|
+
version: '1.0',
|
|
153
|
+
global: {
|
|
154
|
+
enabled: true,
|
|
155
|
+
logLevel: 'info',
|
|
156
|
+
},
|
|
157
|
+
llm: {
|
|
158
|
+
enabled: true,
|
|
159
|
+
model: null,
|
|
160
|
+
},
|
|
161
|
+
rules: {
|
|
162
|
+
purchase: {
|
|
163
|
+
enabled: true,
|
|
164
|
+
severity: 'critical',
|
|
165
|
+
action: 'block',
|
|
166
|
+
spendLimits: { perTransaction: 100, daily: 500 },
|
|
167
|
+
domains: { mode: 'blocklist', blocklist: [] },
|
|
168
|
+
},
|
|
169
|
+
website: {
|
|
170
|
+
enabled: true,
|
|
171
|
+
mode: 'blocklist',
|
|
172
|
+
severity: 'high',
|
|
173
|
+
action: 'block',
|
|
174
|
+
blocklist: [],
|
|
175
|
+
allowlist: [],
|
|
176
|
+
},
|
|
177
|
+
destructive: {
|
|
178
|
+
enabled: true,
|
|
179
|
+
severity: 'critical',
|
|
180
|
+
action: 'confirm',
|
|
181
|
+
shell: { enabled: true },
|
|
182
|
+
cloud: { enabled: true },
|
|
183
|
+
code: { enabled: true },
|
|
184
|
+
},
|
|
185
|
+
secrets: {
|
|
186
|
+
enabled: true,
|
|
187
|
+
severity: 'critical',
|
|
188
|
+
action: 'block',
|
|
189
|
+
},
|
|
190
|
+
exfiltration: {
|
|
191
|
+
enabled: true,
|
|
192
|
+
severity: 'high',
|
|
193
|
+
action: 'block',
|
|
194
|
+
},
|
|
195
|
+
sanitization: {
|
|
196
|
+
enabled: true,
|
|
197
|
+
severity: 'high',
|
|
198
|
+
action: 'block',
|
|
199
|
+
minConfidence: 0.5,
|
|
200
|
+
redactMatches: false,
|
|
201
|
+
categories: {
|
|
202
|
+
instructionOverride: true,
|
|
203
|
+
systemLeak: true,
|
|
204
|
+
jailbreak: true,
|
|
205
|
+
encodedPayload: true,
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
approval: {
|
|
210
|
+
native: { enabled: true, timeout: 300 },
|
|
211
|
+
agentConfirm: { enabled: true, parameterName: '_clawsec_confirm' },
|
|
212
|
+
webhook: { enabled: false, url: undefined, timeout: 30, headers: {} },
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
return createToolResultPersistHandler(defaultConfig);
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../../../src/hooks/tool-result-persist/handler.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,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,EAAE,IAAI;gBACb,QAAQ,EAAE,MAAM;gBAChB,MAAM,EAAE,OAAO;gBACf,aAAa,EAAE,GAAG;gBAClB,aAAa,EAAE,KAAK;gBACpB,UAAU,EAAE;oBACV,mBAAmB,EAAE,IAAI;oBACzB,UAAU,EAAE,IAAI;oBAChB,SAAS,EAAE,IAAI;oBACf,cAAc,EAAE,IAAI;iBACrB;aACF;SACF;QACD,QAAQ,EAAE;YACR,MAAM,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE;YACvC,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAAE;YAClE,OAAO,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;SACtE;KACF,CAAC;IAEF,OAAO,8BAA8B,CAAC,aAAa,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Result Persist Hook
|
|
3
|
+
*
|
|
4
|
+
* Scans tool outputs for secrets/PII and filters sensitive data
|
|
5
|
+
* before persistence.
|
|
6
|
+
*/
|
|
7
|
+
export { createToolResultPersistHandler, createDefaultToolResultPersistHandler, } from './handler.js';
|
|
8
|
+
export type { ToolResultPersistHandlerOptions } from './handler.js';
|
|
9
|
+
export { filterOutput, filterValue, redactString, redactObject, redactArray, detectionsToRedactions, } from './filter.js';
|
|
10
|
+
export type { Redaction, FilterResult } from './filter.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/tool-result-persist/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,GACtC,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,sBAAsB,GACvB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Result Persist Hook
|
|
3
|
+
*
|
|
4
|
+
* Scans tool outputs for secrets/PII and filters sensitive data
|
|
5
|
+
* before persistence.
|
|
6
|
+
*/
|
|
7
|
+
// Handler exports
|
|
8
|
+
export { createToolResultPersistHandler, createDefaultToolResultPersistHandler, } from './handler.js';
|
|
9
|
+
// Filter exports
|
|
10
|
+
export { filterOutput, filterValue, redactString, redactObject, redactArray, detectionsToRedactions, } from './filter.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/hooks/tool-result-persist/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kBAAkB;AAClB,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,GACtC,MAAM,cAAc,CAAC;AAGtB,iBAAiB;AACjB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,sBAAsB,GACvB,MAAM,aAAa,CAAC"}
|