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,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirm Action Handler
|
|
3
|
+
* Handles requesting approval for potentially risky tool calls
|
|
4
|
+
*/
|
|
5
|
+
import type { ActionContext, ActionHandler, ActionResult, ActionLogger, ApprovalMethod, PendingApproval } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate a UUID v4
|
|
8
|
+
* Uses crypto.randomUUID if available, falls back to manual implementation
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateApprovalId(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Determine which approval methods are enabled based on config
|
|
13
|
+
*/
|
|
14
|
+
export declare function getEnabledApprovalMethods(context: ActionContext): ApprovalMethod[];
|
|
15
|
+
/**
|
|
16
|
+
* Get the timeout for approval requests (in seconds)
|
|
17
|
+
*/
|
|
18
|
+
export declare function getApprovalTimeout(context: ActionContext): number;
|
|
19
|
+
/**
|
|
20
|
+
* Generate a message explaining the confirmation requirement
|
|
21
|
+
*/
|
|
22
|
+
export declare function generateConfirmMessage(context: ActionContext, approval: PendingApproval): string;
|
|
23
|
+
/**
|
|
24
|
+
* Confirm action handler implementation
|
|
25
|
+
*/
|
|
26
|
+
export declare class ConfirmHandler implements ActionHandler {
|
|
27
|
+
private logger;
|
|
28
|
+
constructor(logger?: ActionLogger);
|
|
29
|
+
execute(context: ActionContext): Promise<ActionResult>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a confirm action handler with the given logger
|
|
33
|
+
*/
|
|
34
|
+
export declare function createConfirmHandler(logger?: ActionLogger): ConfirmHandler;
|
|
35
|
+
//# sourceMappingURL=confirm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm.d.ts","sourceRoot":"","sources":["../../../src/actions/confirm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG5H;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAY3C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,EAAE,CAoBlF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAKjE;AA6CD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,GAAG,MAAM,CAuBhG;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,aAAa;IAClD,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,GAAE,YAAyB;IAIvC,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CAsC7D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,cAAc,CAE1E"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Confirm Action Handler
|
|
3
|
+
* Handles requesting approval for potentially risky tool calls
|
|
4
|
+
*/
|
|
5
|
+
import { noOpLogger } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Generate a UUID v4
|
|
8
|
+
* Uses crypto.randomUUID if available, falls back to manual implementation
|
|
9
|
+
*/
|
|
10
|
+
export function generateApprovalId() {
|
|
11
|
+
// Use native crypto if available (Node.js 16+, modern browsers)
|
|
12
|
+
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
13
|
+
return crypto.randomUUID();
|
|
14
|
+
}
|
|
15
|
+
// Fallback implementation
|
|
16
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
17
|
+
const r = (Math.random() * 16) | 0;
|
|
18
|
+
const v = c === 'x' ? r : (r & 0x3) | 0x8;
|
|
19
|
+
return v.toString(16);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Determine which approval methods are enabled based on config
|
|
24
|
+
*/
|
|
25
|
+
export function getEnabledApprovalMethods(context) {
|
|
26
|
+
const { config } = context;
|
|
27
|
+
const methods = [];
|
|
28
|
+
// Check native approval
|
|
29
|
+
if (config.approval?.native?.enabled !== false) {
|
|
30
|
+
methods.push('native');
|
|
31
|
+
}
|
|
32
|
+
// Check agent-confirm
|
|
33
|
+
if (config.approval?.agentConfirm?.enabled !== false) {
|
|
34
|
+
methods.push('agent-confirm');
|
|
35
|
+
}
|
|
36
|
+
// Check webhook (only if URL is configured)
|
|
37
|
+
if (config.approval?.webhook?.enabled && config.approval.webhook.url) {
|
|
38
|
+
methods.push('webhook');
|
|
39
|
+
}
|
|
40
|
+
return methods;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the timeout for approval requests (in seconds)
|
|
44
|
+
*/
|
|
45
|
+
export function getApprovalTimeout(context) {
|
|
46
|
+
const { config } = context;
|
|
47
|
+
// Use native timeout as the primary timeout
|
|
48
|
+
return config.approval?.native?.timeout ?? 300;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Format a severity level for display
|
|
52
|
+
*/
|
|
53
|
+
function formatSeverity(severity) {
|
|
54
|
+
return severity.toUpperCase();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Format a threat category for display
|
|
58
|
+
*/
|
|
59
|
+
function formatCategory(category) {
|
|
60
|
+
const categoryNames = {
|
|
61
|
+
purchase: 'Purchase/Payment',
|
|
62
|
+
website: 'Website Access',
|
|
63
|
+
destructive: 'Destructive Command',
|
|
64
|
+
secrets: 'Secrets/PII',
|
|
65
|
+
exfiltration: 'Data Transfer',
|
|
66
|
+
};
|
|
67
|
+
return categoryNames[category] || category;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generate approval instructions based on enabled methods
|
|
71
|
+
*/
|
|
72
|
+
function generateApprovalInstructions(methods, approvalId, context) {
|
|
73
|
+
const instructions = [];
|
|
74
|
+
if (methods.includes('native')) {
|
|
75
|
+
instructions.push(` - Type: /approve ${approvalId}`);
|
|
76
|
+
}
|
|
77
|
+
if (methods.includes('agent-confirm')) {
|
|
78
|
+
const paramName = context.config.approval?.agentConfirm?.parameterName ?? '_clawsec_confirm';
|
|
79
|
+
instructions.push(` - Retry with parameter: ${paramName}="${approvalId}"`);
|
|
80
|
+
}
|
|
81
|
+
if (methods.includes('webhook')) {
|
|
82
|
+
instructions.push(` - Webhook approval is enabled (external system will be notified)`);
|
|
83
|
+
}
|
|
84
|
+
return instructions.join('\n');
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Generate a message explaining the confirmation requirement
|
|
88
|
+
*/
|
|
89
|
+
export function generateConfirmMessage(context, approval) {
|
|
90
|
+
const { analysis, toolCall } = context;
|
|
91
|
+
const { primaryDetection } = analysis;
|
|
92
|
+
let message = '';
|
|
93
|
+
if (primaryDetection) {
|
|
94
|
+
const category = formatCategory(primaryDetection.category);
|
|
95
|
+
const severity = formatSeverity(primaryDetection.severity);
|
|
96
|
+
message = `[${severity}] ${category} requires approval\n`;
|
|
97
|
+
message += `Tool: ${toolCall.toolName}\n`;
|
|
98
|
+
message += `Reason: ${primaryDetection.reason}\n\n`;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
message = `Action requires approval\n`;
|
|
102
|
+
message += `Tool: ${toolCall.toolName}\n\n`;
|
|
103
|
+
}
|
|
104
|
+
message += `Approval ID: ${approval.id}\n`;
|
|
105
|
+
message += `Timeout: ${approval.timeout} seconds\n\n`;
|
|
106
|
+
message += `To approve, use one of the following methods:\n`;
|
|
107
|
+
message += generateApprovalInstructions(approval.methods, approval.id, context);
|
|
108
|
+
return message;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Confirm action handler implementation
|
|
112
|
+
*/
|
|
113
|
+
export class ConfirmHandler {
|
|
114
|
+
logger;
|
|
115
|
+
constructor(logger = noOpLogger) {
|
|
116
|
+
this.logger = logger;
|
|
117
|
+
}
|
|
118
|
+
async execute(context) {
|
|
119
|
+
const { analysis, toolCall } = context;
|
|
120
|
+
// Generate unique approval ID
|
|
121
|
+
const approvalId = generateApprovalId();
|
|
122
|
+
// Determine enabled approval methods
|
|
123
|
+
const methods = getEnabledApprovalMethods(context);
|
|
124
|
+
// Get timeout
|
|
125
|
+
const timeout = getApprovalTimeout(context);
|
|
126
|
+
const pendingApproval = {
|
|
127
|
+
id: approvalId,
|
|
128
|
+
timeout,
|
|
129
|
+
methods,
|
|
130
|
+
};
|
|
131
|
+
const message = generateConfirmMessage(context, pendingApproval);
|
|
132
|
+
// Log the confirmation request
|
|
133
|
+
this.logger.info('Action requires approval', {
|
|
134
|
+
toolName: toolCall.toolName,
|
|
135
|
+
approvalId,
|
|
136
|
+
category: analysis.primaryDetection?.category,
|
|
137
|
+
severity: analysis.primaryDetection?.severity,
|
|
138
|
+
reason: analysis.primaryDetection?.reason,
|
|
139
|
+
methods,
|
|
140
|
+
timeout,
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
allowed: false,
|
|
144
|
+
message,
|
|
145
|
+
pendingApproval,
|
|
146
|
+
logged: true,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Create a confirm action handler with the given logger
|
|
152
|
+
*/
|
|
153
|
+
export function createConfirmHandler(logger) {
|
|
154
|
+
return new ConfirmHandler(logger);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=confirm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirm.js","sourceRoot":"","sources":["../../../src/actions/confirm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;;GAGG;AACH,MAAM,UAAU,kBAAkB;IAChC,gEAAgE;IAChE,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACvD,OAAO,MAAM,CAAC,UAAU,EAAE,CAAC;IAC7B,CAAC;IAED,0BAA0B;IAC1B,OAAO,sCAAsC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QACnE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;QAC1C,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAsB;IAC9D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,OAAO,GAAqB,EAAE,CAAC;IAErC,wBAAwB;IACxB,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,KAAK,KAAK,EAAE,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC;IAED,sBAAsB;IACtB,IAAI,MAAM,CAAC,Q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CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Executor
|
|
3
|
+
* Main executor that routes to appropriate action handlers based on analysis results
|
|
4
|
+
*/
|
|
5
|
+
import type { ActionContext, ActionExecutor, ActionResult, ActionLogger, ActionHandler } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Configuration for the action executor
|
|
8
|
+
*/
|
|
9
|
+
export interface ExecutorConfig {
|
|
10
|
+
/** Logger to use for action logging */
|
|
11
|
+
logger?: ActionLogger;
|
|
12
|
+
/** Custom block handler */
|
|
13
|
+
blockHandler?: ActionHandler;
|
|
14
|
+
/** Custom confirm handler */
|
|
15
|
+
confirmHandler?: ActionHandler;
|
|
16
|
+
/** Custom warn handler */
|
|
17
|
+
warnHandler?: ActionHandler;
|
|
18
|
+
/** Custom log handler */
|
|
19
|
+
logHandler?: ActionHandler;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Default action executor implementation
|
|
23
|
+
*/
|
|
24
|
+
export declare class DefaultActionExecutor implements ActionExecutor {
|
|
25
|
+
private logger;
|
|
26
|
+
private blockHandler;
|
|
27
|
+
private confirmHandler;
|
|
28
|
+
private warnHandler;
|
|
29
|
+
private logHandler;
|
|
30
|
+
constructor(config?: ExecutorConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Execute the appropriate action based on analysis result
|
|
33
|
+
*/
|
|
34
|
+
execute(context: ActionContext): Promise<ActionResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Handle allow action - no detection, pass through
|
|
37
|
+
*/
|
|
38
|
+
private handleAllow;
|
|
39
|
+
/**
|
|
40
|
+
* Handle block action
|
|
41
|
+
*/
|
|
42
|
+
private handleBlock;
|
|
43
|
+
/**
|
|
44
|
+
* Handle confirm action
|
|
45
|
+
*/
|
|
46
|
+
private handleConfirm;
|
|
47
|
+
/**
|
|
48
|
+
* Handle warn action
|
|
49
|
+
*/
|
|
50
|
+
private handleWarn;
|
|
51
|
+
/**
|
|
52
|
+
* Handle log action
|
|
53
|
+
*/
|
|
54
|
+
private handleLog;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create an action executor with the given configuration
|
|
58
|
+
*/
|
|
59
|
+
export declare function createActionExecutor(config?: ExecutorConfig): ActionExecutor;
|
|
60
|
+
/**
|
|
61
|
+
* Create an action executor with default logger based on config log level
|
|
62
|
+
*/
|
|
63
|
+
export declare function createDefaultActionExecutor(logLevel?: 'debug' | 'info' | 'warn' | 'error'): ActionExecutor;
|
|
64
|
+
//# sourceMappingURL=executor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../../../src/actions/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAO3G;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,uCAAuC;IACvC,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,2BAA2B;IAC3B,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B,6BAA6B;IAC7B,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,0BAA0B;IAC1B,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,yBAAyB;IACzB,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,qBAAsB,YAAW,cAAc;IAC1D,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,UAAU,CAAgB;gBAEtB,MAAM,GAAE,cAAmB;IAQvC;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAsC5D;;OAEG;YACW,WAAW;IAWzB;;OAEG;YACW,WAAW;IAIzB;;OAEG;YACW,aAAa;IAI3B;;OAEG;YACW,UAAU;IAIxB;;OAEG;YACW,SAAS;CAGxB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,cAAc,GAAG,cAAc,CAE5E;AAED;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,GAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAgB,GAAG,cAAc,CAGlH"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Executor
|
|
3
|
+
* Main executor that routes to appropriate action handlers based on analysis results
|
|
4
|
+
*/
|
|
5
|
+
import { noOpLogger, createLogger } from './types.js';
|
|
6
|
+
import { createBlockHandler } from './block.js';
|
|
7
|
+
import { createConfirmHandler } from './confirm.js';
|
|
8
|
+
import { createWarnHandler } from './warn.js';
|
|
9
|
+
import { createLogHandler } from './log.js';
|
|
10
|
+
/**
|
|
11
|
+
* Default action executor implementation
|
|
12
|
+
*/
|
|
13
|
+
export class DefaultActionExecutor {
|
|
14
|
+
logger;
|
|
15
|
+
blockHandler;
|
|
16
|
+
confirmHandler;
|
|
17
|
+
warnHandler;
|
|
18
|
+
logHandler;
|
|
19
|
+
constructor(config = {}) {
|
|
20
|
+
this.logger = config.logger ?? noOpLogger;
|
|
21
|
+
this.blockHandler = config.blockHandler ?? createBlockHandler(this.logger);
|
|
22
|
+
this.confirmHandler = config.confirmHandler ?? createConfirmHandler(this.logger);
|
|
23
|
+
this.warnHandler = config.warnHandler ?? createWarnHandler(this.logger);
|
|
24
|
+
this.logHandler = config.logHandler ?? createLogHandler(this.logger);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Execute the appropriate action based on analysis result
|
|
28
|
+
*/
|
|
29
|
+
async execute(context) {
|
|
30
|
+
const { analysis, config } = context;
|
|
31
|
+
const action = analysis.action;
|
|
32
|
+
// Check if the plugin is disabled
|
|
33
|
+
if (config.global?.enabled === false) {
|
|
34
|
+
this.logger.debug('Plugin disabled, allowing action');
|
|
35
|
+
return {
|
|
36
|
+
allowed: true,
|
|
37
|
+
logged: false,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Route to appropriate handler based on action
|
|
41
|
+
switch (action) {
|
|
42
|
+
case 'allow':
|
|
43
|
+
return this.handleAllow(context);
|
|
44
|
+
case 'block':
|
|
45
|
+
return this.handleBlock(context);
|
|
46
|
+
case 'confirm':
|
|
47
|
+
return this.handleConfirm(context);
|
|
48
|
+
case 'warn':
|
|
49
|
+
return this.handleWarn(context);
|
|
50
|
+
case 'log':
|
|
51
|
+
return this.handleLog(context);
|
|
52
|
+
default:
|
|
53
|
+
// Unknown action, log and allow as a safety measure
|
|
54
|
+
this.logger.warn('Unknown action type, defaulting to allow', {
|
|
55
|
+
action: action,
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
allowed: true,
|
|
59
|
+
message: `Unknown action type: ${action}`,
|
|
60
|
+
logged: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Handle allow action - no detection, pass through
|
|
66
|
+
*/
|
|
67
|
+
async handleAllow(context) {
|
|
68
|
+
this.logger.debug('Action allowed', {
|
|
69
|
+
toolName: context.toolCall.toolName,
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
allowed: true,
|
|
73
|
+
logged: false,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Handle block action
|
|
78
|
+
*/
|
|
79
|
+
async handleBlock(context) {
|
|
80
|
+
return this.blockHandler.execute(context);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Handle confirm action
|
|
84
|
+
*/
|
|
85
|
+
async handleConfirm(context) {
|
|
86
|
+
return this.confirmHandler.execute(context);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Handle warn action
|
|
90
|
+
*/
|
|
91
|
+
async handleWarn(context) {
|
|
92
|
+
return this.warnHandler.execute(context);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Handle log action
|
|
96
|
+
*/
|
|
97
|
+
async handleLog(context) {
|
|
98
|
+
return this.logHandler.execute(context);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Create an action executor with the given configuration
|
|
103
|
+
*/
|
|
104
|
+
export function createActionExecutor(config) {
|
|
105
|
+
return new DefaultActionExecutor(config);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Create an action executor with default logger based on config log level
|
|
109
|
+
*/
|
|
110
|
+
export function createDefaultActionExecutor(logLevel = 'info') {
|
|
111
|
+
const logger = createLogger(logLevel);
|
|
112
|
+
return new DefaultActionExecutor({ logger });
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../src/actions/executor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAkB5C;;GAEG;AACH,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAAe;IACrB,YAAY,CAAgB;IAC5B,cAAc,CAAgB;IAC9B,WAAW,CAAgB;IAC3B,UAAU,CAAgB;IAElC,YAAY,SAAyB,EAAE;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,UAAU,CAAC;QAC1C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,kBAAkB,CAA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,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Executor Module
|
|
3
|
+
* Re-exports for the action execution system
|
|
4
|
+
*/
|
|
5
|
+
export type { ActionContext, ActionResult, ActionHandler, ActionExecutor, ActionLogger, ApprovalMethod, PendingApproval, } from './types.js';
|
|
6
|
+
export { consoleLogger, noOpLogger, createLogger, } from './types.js';
|
|
7
|
+
export { BlockHandler, createBlockHandler, generateBlockMessage, } from './block.js';
|
|
8
|
+
export { ConfirmHandler, createConfirmHandler, generateConfirmMessage, generateApprovalId, getEnabledApprovalMethods, getApprovalTimeout, } from './confirm.js';
|
|
9
|
+
export { WarnHandler, createWarnHandler, generateWarnMessage, } from './warn.js';
|
|
10
|
+
export { LogHandler, createLogHandler, } from './log.js';
|
|
11
|
+
export type { ExecutorConfig } from './executor.js';
|
|
12
|
+
export { DefaultActionExecutor, createActionExecutor, createDefaultActionExecutor, } from './executor.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/actions/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,UAAU,EACV,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAGlB,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Executor Module
|
|
3
|
+
* Re-exports for the action execution system
|
|
4
|
+
*/
|
|
5
|
+
export { consoleLogger, noOpLogger, createLogger, } from './types.js';
|
|
6
|
+
// Block handler
|
|
7
|
+
export { BlockHandler, createBlockHandler, generateBlockMessage, } from './block.js';
|
|
8
|
+
// Confirm handler
|
|
9
|
+
export { ConfirmHandler, createConfirmHandler, generateConfirmMessage, generateApprovalId, getEnabledApprovalMethods, getApprovalTimeout, } from './confirm.js';
|
|
10
|
+
// Warn handler
|
|
11
|
+
export { WarnHandler, createWarnHandler, generateWarnMessage, } from './warn.js';
|
|
12
|
+
// Log handler
|
|
13
|
+
export { LogHandler, createLogHandler, } from './log.js';
|
|
14
|
+
export { DefaultActionExecutor, createActionExecutor, createDefaultActionExecutor, } from './executor.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/actions/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EACL,aAAa,EACb,UAAU,EACV,YAAY,GACb,MAAM,YAAY,CAAC;AAEpB,gBAAgB;AAChB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,kBAAkB;AAClB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAEtB,eAAe;AACf,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,WAAW,CAAC;AAEnB,cAAc;AACd,OAAO,EACL,UAAU,EACV,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAIlB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log Action Handler
|
|
3
|
+
* Handles silent audit logging for tool calls that should be allowed but tracked
|
|
4
|
+
*/
|
|
5
|
+
import type { ActionContext, ActionHandler, ActionResult, ActionLogger } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Log action handler implementation
|
|
8
|
+
* Allows the action but logs it silently for audit purposes
|
|
9
|
+
*/
|
|
10
|
+
export declare class LogHandler implements ActionHandler {
|
|
11
|
+
private logger;
|
|
12
|
+
constructor(logger?: ActionLogger);
|
|
13
|
+
execute(context: ActionContext): Promise<ActionResult>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create a log action handler with the given logger
|
|
17
|
+
*/
|
|
18
|
+
export declare function createLogHandler(logger?: ActionLogger): LogHandler;
|
|
19
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../../src/actions/log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAiB3F;;;GAGG;AACH,qBAAa,UAAW,YAAW,aAAa;IAC9C,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,GAAE,YAAyB;IAIvC,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CA6B7D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,UAAU,CAElE"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log Action Handler
|
|
3
|
+
* Handles silent audit logging for tool calls that should be allowed but tracked
|
|
4
|
+
*/
|
|
5
|
+
import { noOpLogger } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Format a threat category for display
|
|
8
|
+
*/
|
|
9
|
+
function formatCategory(category) {
|
|
10
|
+
const categoryNames = {
|
|
11
|
+
purchase: 'Purchase/Payment',
|
|
12
|
+
website: 'Website Access',
|
|
13
|
+
destructive: 'Destructive Command',
|
|
14
|
+
secrets: 'Secrets/PII',
|
|
15
|
+
exfiltration: 'Data Transfer',
|
|
16
|
+
};
|
|
17
|
+
return categoryNames[category] || category;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Log action handler implementation
|
|
21
|
+
* Allows the action but logs it silently for audit purposes
|
|
22
|
+
*/
|
|
23
|
+
export class LogHandler {
|
|
24
|
+
logger;
|
|
25
|
+
constructor(logger = noOpLogger) {
|
|
26
|
+
this.logger = logger;
|
|
27
|
+
}
|
|
28
|
+
async execute(context) {
|
|
29
|
+
const { analysis, toolCall } = context;
|
|
30
|
+
// Log the action for audit (silent - no user-visible message)
|
|
31
|
+
if (analysis.primaryDetection) {
|
|
32
|
+
this.logger.info('Action logged for audit', {
|
|
33
|
+
toolName: toolCall.toolName,
|
|
34
|
+
category: analysis.primaryDetection.category,
|
|
35
|
+
severity: analysis.primaryDetection.severity,
|
|
36
|
+
reason: analysis.primaryDetection.reason,
|
|
37
|
+
detectionCount: analysis.detections.length,
|
|
38
|
+
detections: analysis.detections.map((d) => ({
|
|
39
|
+
category: formatCategory(d.category),
|
|
40
|
+
severity: d.severity,
|
|
41
|
+
reason: d.reason,
|
|
42
|
+
})),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
this.logger.debug('Action logged for audit (no detections)', {
|
|
47
|
+
toolName: toolCall.toolName,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
// No user-visible message for log action
|
|
51
|
+
return {
|
|
52
|
+
allowed: true,
|
|
53
|
+
logged: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a log action handler with the given logger
|
|
59
|
+
*/
|
|
60
|
+
export function createLogHandler(logger) {
|
|
61
|
+
return new LogHandler(logger);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/actions/log.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC;;GAEG;AACH,SAAS,cAAc,CAAC,QAAgB;IACtC,MAAM,aAAa,GAA2B;QAC5C,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE,gBAAgB;QACzB,WAAW,EAAE,qBAAqB;QAClC,OAAO,EAAE,aAAa;QACtB,YAAY,EAAE,eAAe;KAC9B,CAAC;IACF,OAAO,aAAa,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,UAAU;IACb,MAAM,CAAe;IAE7B,YAAY,SAAuB,UAAU;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAsB;QAClC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAEvC,8DAA8D;QAC9D,IAAI,QAAQ,CAAC,gBAAgB,EAAE,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,EAAE;gBAC1C,QAAQ,EAAE,QAAQ,CAAC,QAAQ;gBAC3B,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,QAAQ;gBAC5C,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,QAAQ;gBAC5C,MAAM,EAAE,QAAQ,CAAC,gBAAgB,CAAC,MAAM;gBACxC,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,MAAM;gBAC1C,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;oBAC1C,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC;oBACpC,QAAQ,EAAE,CAAC,CAAC,QAAQ;oBACpB,MAAM,EAAE,CAAC,CAAC,MAAM;iBACjB,CAAC,CAAC;aACJ,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE;gBAC3D,QAAQ,EAAE,QAAQ,CAAC,QAAQ;aAC5B,CAAC,CAAC;QACL,CAAC;QAED,yCAAyC;QACzC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAqB;IACpD,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Action Executor Types
|
|
3
|
+
* Type definitions for the action execution system
|
|
4
|
+
*/
|
|
5
|
+
import type { ClawsecConfig } from '../config/index.js';
|
|
6
|
+
import type { AnalysisResult, ToolCallContext } from '../engine/types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Approval methods available for confirmation flow
|
|
9
|
+
*/
|
|
10
|
+
export type ApprovalMethod = 'native' | 'agent-confirm' | 'webhook';
|
|
11
|
+
/**
|
|
12
|
+
* Context provided to action handlers
|
|
13
|
+
*/
|
|
14
|
+
export interface ActionContext {
|
|
15
|
+
/** Result from the hybrid analyzer */
|
|
16
|
+
analysis: AnalysisResult;
|
|
17
|
+
/** Original tool call context */
|
|
18
|
+
toolCall: ToolCallContext;
|
|
19
|
+
/** Plugin configuration */
|
|
20
|
+
config: ClawsecConfig;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Pending approval details returned when action requires confirmation
|
|
24
|
+
*/
|
|
25
|
+
export interface PendingApproval {
|
|
26
|
+
/** Unique identifier for this approval request */
|
|
27
|
+
id: string;
|
|
28
|
+
/** Timeout in seconds for the approval */
|
|
29
|
+
timeout: number;
|
|
30
|
+
/** Approval methods available for this request */
|
|
31
|
+
methods: ApprovalMethod[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Result of executing an action
|
|
35
|
+
*/
|
|
36
|
+
export interface ActionResult {
|
|
37
|
+
/** Whether the tool call is allowed to proceed */
|
|
38
|
+
allowed: boolean;
|
|
39
|
+
/** Human-readable message about the action taken */
|
|
40
|
+
message?: string;
|
|
41
|
+
/** Pending approval details (only for confirm action) */
|
|
42
|
+
pendingApproval?: PendingApproval;
|
|
43
|
+
/** Whether the action was logged for audit */
|
|
44
|
+
logged: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Interface for individual action handlers
|
|
48
|
+
*/
|
|
49
|
+
export interface ActionHandler {
|
|
50
|
+
/** Execute the action and return the result */
|
|
51
|
+
execute(context: ActionContext): Promise<ActionResult>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Main executor interface
|
|
55
|
+
*/
|
|
56
|
+
export interface ActionExecutor {
|
|
57
|
+
/** Execute the appropriate action based on analysis result */
|
|
58
|
+
execute(context: ActionContext): Promise<ActionResult>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Logger interface for action logging
|
|
62
|
+
*/
|
|
63
|
+
export interface ActionLogger {
|
|
64
|
+
/** Log a debug message */
|
|
65
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
66
|
+
/** Log an info message */
|
|
67
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
68
|
+
/** Log a warning message */
|
|
69
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
70
|
+
/** Log an error message */
|
|
71
|
+
error(message: string, data?: Record<string, unknown>): void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Default console logger implementation
|
|
75
|
+
*/
|
|
76
|
+
export declare const consoleLogger: ActionLogger;
|
|
77
|
+
/**
|
|
78
|
+
* No-op logger for testing or silent mode
|
|
79
|
+
*/
|
|
80
|
+
export declare const noOpLogger: ActionLogger;
|
|
81
|
+
/**
|
|
82
|
+
* Create a logger based on log level
|
|
83
|
+
*/
|
|
84
|
+
export declare function createLogger(logLevel: 'debug' | 'info' | 'warn' | 'error'): ActionLogger;
|
|
85
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/actions/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1E;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,eAAe,GAAG,SAAS,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,QAAQ,EAAE,cAAc,CAAC;IACzB,iCAAiC;IACjC,QAAQ,EAAE,eAAe,CAAC;IAC1B,2BAA2B;IAC3B,MAAM,EAAE,aAAa,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,0CAA0C;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,OAAO,EAAE,OAAO,CAAC;IACjB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,eAA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