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,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL Pattern Detector
|
|
3
|
+
* Detects purchase-related URL paths and API endpoints
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Checkout and payment paths
|
|
7
|
+
*/
|
|
8
|
+
const CHECKOUT_PATHS = [
|
|
9
|
+
'/checkout',
|
|
10
|
+
'/checkout/',
|
|
11
|
+
'/checkout/*',
|
|
12
|
+
'/payment',
|
|
13
|
+
'/payment/',
|
|
14
|
+
'/payments',
|
|
15
|
+
'/payments/',
|
|
16
|
+
'/pay',
|
|
17
|
+
'/pay/',
|
|
18
|
+
'/cart/checkout',
|
|
19
|
+
'/cart/confirm',
|
|
20
|
+
'/cart/payment',
|
|
21
|
+
'/secure/checkout',
|
|
22
|
+
'/secure/payment',
|
|
23
|
+
'/gp/buy',
|
|
24
|
+
'/gp/checkout',
|
|
25
|
+
];
|
|
26
|
+
/**
|
|
27
|
+
* Purchase and order paths
|
|
28
|
+
*/
|
|
29
|
+
const PURCHASE_PATHS = [
|
|
30
|
+
'/buy',
|
|
31
|
+
'/buy/',
|
|
32
|
+
'/buy/*',
|
|
33
|
+
'/purchase',
|
|
34
|
+
'/purchase/',
|
|
35
|
+
'/order',
|
|
36
|
+
'/order/',
|
|
37
|
+
'/orders',
|
|
38
|
+
'/orders/',
|
|
39
|
+
'/orders/create',
|
|
40
|
+
'/orders/submit',
|
|
41
|
+
'/confirm-order',
|
|
42
|
+
'/place-order',
|
|
43
|
+
'/complete-purchase',
|
|
44
|
+
];
|
|
45
|
+
/**
|
|
46
|
+
* Subscription and billing paths
|
|
47
|
+
*/
|
|
48
|
+
const SUBSCRIPTION_PATHS = [
|
|
49
|
+
'/subscribe',
|
|
50
|
+
'/subscribe/',
|
|
51
|
+
'/subscription',
|
|
52
|
+
'/subscription/',
|
|
53
|
+
'/subscriptions',
|
|
54
|
+
'/billing',
|
|
55
|
+
'/billing/',
|
|
56
|
+
'/billing/payment',
|
|
57
|
+
'/billing/subscribe',
|
|
58
|
+
'/upgrade',
|
|
59
|
+
'/upgrade/',
|
|
60
|
+
'/premium',
|
|
61
|
+
'/pro',
|
|
62
|
+
];
|
|
63
|
+
/**
|
|
64
|
+
* API endpoints for orders and payments
|
|
65
|
+
*/
|
|
66
|
+
const API_ENDPOINTS = [
|
|
67
|
+
'/api/orders',
|
|
68
|
+
'/api/order',
|
|
69
|
+
'/api/checkout',
|
|
70
|
+
'/api/payment',
|
|
71
|
+
'/api/payments',
|
|
72
|
+
'/api/purchase',
|
|
73
|
+
'/api/subscribe',
|
|
74
|
+
'/api/subscription',
|
|
75
|
+
'/api/billing',
|
|
76
|
+
'/api/charge',
|
|
77
|
+
'/api/transaction',
|
|
78
|
+
'/api/transactions',
|
|
79
|
+
'/api/v1/orders',
|
|
80
|
+
'/api/v1/checkout',
|
|
81
|
+
'/api/v1/payment',
|
|
82
|
+
'/api/v1/payments',
|
|
83
|
+
'/api/v2/orders',
|
|
84
|
+
'/api/v2/checkout',
|
|
85
|
+
'/api/v2/payment',
|
|
86
|
+
'/api/v2/payments',
|
|
87
|
+
'/graphql', // Often used for mutations
|
|
88
|
+
];
|
|
89
|
+
/**
|
|
90
|
+
* URL path keywords (for partial matching)
|
|
91
|
+
*/
|
|
92
|
+
const URL_KEYWORDS = [
|
|
93
|
+
'checkout',
|
|
94
|
+
'payment',
|
|
95
|
+
'purchase',
|
|
96
|
+
'billing',
|
|
97
|
+
'subscribe',
|
|
98
|
+
'order',
|
|
99
|
+
'transaction',
|
|
100
|
+
'charge',
|
|
101
|
+
];
|
|
102
|
+
/**
|
|
103
|
+
* Convert glob pattern to regex for URL matching
|
|
104
|
+
*/
|
|
105
|
+
function pathPatternToRegex(pattern) {
|
|
106
|
+
// Normalize pattern - remove trailing slash for matching
|
|
107
|
+
const normalizedPattern = pattern.endsWith('/') && pattern.length > 1
|
|
108
|
+
? pattern.slice(0, -1)
|
|
109
|
+
: pattern;
|
|
110
|
+
// Escape special regex characters except *
|
|
111
|
+
const regex = normalizedPattern
|
|
112
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
113
|
+
.replace(/\*/g, '.*');
|
|
114
|
+
// Match the pattern at the start of the path (or exact match)
|
|
115
|
+
return new RegExp(`^${regex}(?:/.*)?$`, 'i');
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Extract path from URL
|
|
119
|
+
*/
|
|
120
|
+
export function extractPath(url) {
|
|
121
|
+
// If input is already a path (starts with /), return it directly
|
|
122
|
+
if (url.startsWith('/')) {
|
|
123
|
+
// Extract just the path without query string
|
|
124
|
+
const pathMatch = url.match(/^(\/[^?#]*)/);
|
|
125
|
+
return pathMatch ? pathMatch[1].toLowerCase() : url.toLowerCase();
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
let normalizedUrl = url;
|
|
129
|
+
if (!url.includes('://')) {
|
|
130
|
+
normalizedUrl = 'https://' + url;
|
|
131
|
+
}
|
|
132
|
+
const parsed = new URL(normalizedUrl);
|
|
133
|
+
return parsed.pathname.toLowerCase();
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// If URL parsing fails, try to extract path directly
|
|
137
|
+
const pathMatch = url.match(/^(?:https?:\/\/[^/]+)?(\/.*)$/i);
|
|
138
|
+
if (pathMatch) {
|
|
139
|
+
return pathMatch[1].toLowerCase();
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Check if path matches a pattern
|
|
146
|
+
*/
|
|
147
|
+
function matchesPathPattern(path, pattern) {
|
|
148
|
+
const regex = pathPatternToRegex(pattern);
|
|
149
|
+
return regex.test(path);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Check URL path against known payment paths
|
|
153
|
+
*/
|
|
154
|
+
export function matchUrlPath(url) {
|
|
155
|
+
const path = extractPath(url);
|
|
156
|
+
if (!path) {
|
|
157
|
+
return { matched: false, confidence: 0 };
|
|
158
|
+
}
|
|
159
|
+
// Normalize path for matching (remove trailing slash for comparison)
|
|
160
|
+
const normalizedPath = path.endsWith('/') && path.length > 1
|
|
161
|
+
? path.slice(0, -1)
|
|
162
|
+
: path;
|
|
163
|
+
// Check checkout paths (highest priority)
|
|
164
|
+
for (const pattern of CHECKOUT_PATHS) {
|
|
165
|
+
if (matchesPathPattern(normalizedPath, pattern)) {
|
|
166
|
+
return {
|
|
167
|
+
matched: true,
|
|
168
|
+
url: url,
|
|
169
|
+
pattern: pattern,
|
|
170
|
+
matchType: 'path',
|
|
171
|
+
confidence: 0.9,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Check purchase paths
|
|
176
|
+
for (const pattern of PURCHASE_PATHS) {
|
|
177
|
+
if (matchesPathPattern(normalizedPath, pattern)) {
|
|
178
|
+
return {
|
|
179
|
+
matched: true,
|
|
180
|
+
url: url,
|
|
181
|
+
pattern: pattern,
|
|
182
|
+
matchType: 'path',
|
|
183
|
+
confidence: 0.85,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// Check subscription paths
|
|
188
|
+
for (const pattern of SUBSCRIPTION_PATHS) {
|
|
189
|
+
if (matchesPathPattern(normalizedPath, pattern)) {
|
|
190
|
+
return {
|
|
191
|
+
matched: true,
|
|
192
|
+
url: url,
|
|
193
|
+
pattern: pattern,
|
|
194
|
+
matchType: 'path',
|
|
195
|
+
confidence: 0.85,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Check API endpoints
|
|
200
|
+
for (const pattern of API_ENDPOINTS) {
|
|
201
|
+
if (matchesPathPattern(normalizedPath, pattern)) {
|
|
202
|
+
return {
|
|
203
|
+
matched: true,
|
|
204
|
+
url: url,
|
|
205
|
+
pattern: pattern,
|
|
206
|
+
matchType: 'api',
|
|
207
|
+
confidence: 0.8,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Check for keywords in path (lower confidence)
|
|
212
|
+
for (const keyword of URL_KEYWORDS) {
|
|
213
|
+
if (normalizedPath.includes(keyword)) {
|
|
214
|
+
return {
|
|
215
|
+
matched: true,
|
|
216
|
+
url: url,
|
|
217
|
+
pattern: keyword,
|
|
218
|
+
matchType: 'path',
|
|
219
|
+
confidence: 0.6,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return { matched: false, confidence: 0 };
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* URL pattern detector class
|
|
227
|
+
*/
|
|
228
|
+
export class UrlDetector {
|
|
229
|
+
severity;
|
|
230
|
+
constructor(severity = 'critical') {
|
|
231
|
+
this.severity = severity;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Extract URL from tool context
|
|
235
|
+
*/
|
|
236
|
+
extractUrl(context) {
|
|
237
|
+
// Direct URL in context
|
|
238
|
+
if (context.url) {
|
|
239
|
+
return context.url;
|
|
240
|
+
}
|
|
241
|
+
// Check common tool input patterns
|
|
242
|
+
const input = context.toolInput;
|
|
243
|
+
if (typeof input.url === 'string') {
|
|
244
|
+
return input.url;
|
|
245
|
+
}
|
|
246
|
+
if (typeof input.href === 'string') {
|
|
247
|
+
return input.href;
|
|
248
|
+
}
|
|
249
|
+
if (typeof input.link === 'string') {
|
|
250
|
+
return input.link;
|
|
251
|
+
}
|
|
252
|
+
if (typeof input.target === 'string' && input.target.includes('/')) {
|
|
253
|
+
return input.target;
|
|
254
|
+
}
|
|
255
|
+
// Check for path-only inputs
|
|
256
|
+
if (typeof input.path === 'string') {
|
|
257
|
+
return input.path;
|
|
258
|
+
}
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
detect(context) {
|
|
262
|
+
const url = this.extractUrl(context);
|
|
263
|
+
if (!url) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
const result = matchUrlPath(url);
|
|
267
|
+
if (!result.matched) {
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
const matchTypeDescription = result.matchType === 'api'
|
|
271
|
+
? 'API endpoint for payments/orders'
|
|
272
|
+
: 'checkout/payment URL path';
|
|
273
|
+
return {
|
|
274
|
+
detected: true,
|
|
275
|
+
category: 'purchase',
|
|
276
|
+
severity: this.severity,
|
|
277
|
+
confidence: result.confidence,
|
|
278
|
+
reason: `Detected ${matchTypeDescription}: ${result.pattern}`,
|
|
279
|
+
metadata: {
|
|
280
|
+
url: result.url,
|
|
281
|
+
matchedPattern: result.pattern,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Create a URL detector with the given configuration
|
|
288
|
+
*/
|
|
289
|
+
export function createUrlDetector(severity = 'critical') {
|
|
290
|
+
return new UrlDetector(severity);
|
|
291
|
+
}
|
|
292
|
+
//# sourceMappingURL=url-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-detector.js","sourceRoot":"","sources":["../../../../src/detectors/purchase/url-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,cAAc,GAAG;IACrB,WAAW;IACX,YAAY;IACZ,aAAa;IACb,UAAU;IACV,WAAW;IACX,WAAW;IACX,YAAY;IACZ,MAAM;IACN,O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,EAAE;YAC7D,QAAQ,EAAE;gBACR,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,cAAc,EAAE,MAAM,CAAC,OAAO;aAC/B;SACF,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAqB,UAAU;IAC/D,OAAO,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Detector
|
|
3
|
+
* Detects API keys from various providers
|
|
4
|
+
*/
|
|
5
|
+
import type { SecretsDetectionResult, SecretSubDetector, ApiKeyMatch } from './types.js';
|
|
6
|
+
import type { Severity } from '../../config/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Redact a value showing first and last few characters
|
|
9
|
+
*/
|
|
10
|
+
export declare function redactValue(value: string, showStart?: number, showEnd?: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* Match API keys in text
|
|
13
|
+
*/
|
|
14
|
+
export declare function matchApiKeys(text: string): ApiKeyMatch[];
|
|
15
|
+
/**
|
|
16
|
+
* API Key Detector class
|
|
17
|
+
*/
|
|
18
|
+
export declare class ApiKeyDetector implements SecretSubDetector {
|
|
19
|
+
private severity;
|
|
20
|
+
constructor(severity: Severity);
|
|
21
|
+
/**
|
|
22
|
+
* Scan text for API keys
|
|
23
|
+
*/
|
|
24
|
+
scan(text: string, location: string): SecretsDetectionResult[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create an API key detector
|
|
28
|
+
*/
|
|
29
|
+
export declare function createApiKeyDetector(severity: Severity): ApiKeyDetector;
|
|
30
|
+
//# sourceMappingURL=api-key-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key-detector.d.ts","sourceRoot":"","sources":["../../../../src/detectors/secrets/api-key-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AA0MtD;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,SAAI,EAAE,OAAO,SAAI,GAAG,MAAM,CAM7E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CAgExD;AAED;;GAEG;AACH,qBAAa,cAAe,YAAW,iBAAiB;IACtD,OAAO,CAAC,QAAQ,CAAW;gBAEf,QAAQ,EAAE,QAAQ;IAI9B;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,sBAAsB,EAAE;CAiB/D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAEvE"}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Detector
|
|
3
|
+
* Detects API keys from various providers
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* API key patterns for various providers
|
|
7
|
+
*/
|
|
8
|
+
const API_KEY_PATTERNS = [
|
|
9
|
+
// OpenAI - sk-... format (51+ chars)
|
|
10
|
+
{
|
|
11
|
+
provider: 'openai',
|
|
12
|
+
pattern: /\bsk-[A-Za-z0-9]{48,}\b/g,
|
|
13
|
+
minLength: 51,
|
|
14
|
+
confidence: 0.95,
|
|
15
|
+
description: 'OpenAI API key',
|
|
16
|
+
},
|
|
17
|
+
// Anthropic - sk-ant-... format
|
|
18
|
+
{
|
|
19
|
+
provider: 'anthropic',
|
|
20
|
+
pattern: /\bsk-ant-[A-Za-z0-9_-]{32,}\b/g,
|
|
21
|
+
confidence: 0.95,
|
|
22
|
+
description: 'Anthropic API key',
|
|
23
|
+
},
|
|
24
|
+
// AWS Access Key ID - AKIA... (20 chars)
|
|
25
|
+
{
|
|
26
|
+
provider: 'aws',
|
|
27
|
+
pattern: /\bAKIA[0-9A-Z]{16}\b/g,
|
|
28
|
+
minLength: 20,
|
|
29
|
+
maxLength: 20,
|
|
30
|
+
confidence: 0.95,
|
|
31
|
+
description: 'AWS Access Key ID',
|
|
32
|
+
},
|
|
33
|
+
// AWS Secret Access Key (40 chars base64-like)
|
|
34
|
+
{
|
|
35
|
+
provider: 'aws',
|
|
36
|
+
pattern: /\b[A-Za-z0-9/+=]{40}\b/g,
|
|
37
|
+
minLength: 40,
|
|
38
|
+
maxLength: 40,
|
|
39
|
+
confidence: 0.5, // Lower confidence without context
|
|
40
|
+
description: 'Potential AWS Secret Access Key',
|
|
41
|
+
},
|
|
42
|
+
// GitHub tokens - ghp_, gho_, ghs_, ghr_ prefixes
|
|
43
|
+
{
|
|
44
|
+
provider: 'github',
|
|
45
|
+
pattern: /\bghp_[A-Za-z0-9]{36,}\b/g,
|
|
46
|
+
confidence: 0.95,
|
|
47
|
+
description: 'GitHub Personal Access Token',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
provider: 'github',
|
|
51
|
+
pattern: /\bgho_[A-Za-z0-9]{36,}\b/g,
|
|
52
|
+
confidence: 0.95,
|
|
53
|
+
description: 'GitHub OAuth Token',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
provider: 'github',
|
|
57
|
+
pattern: /\bghs_[A-Za-z0-9]{36,}\b/g,
|
|
58
|
+
confidence: 0.95,
|
|
59
|
+
description: 'GitHub App Installation Token',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
provider: 'github',
|
|
63
|
+
pattern: /\bghr_[A-Za-z0-9]{36,}\b/g,
|
|
64
|
+
confidence: 0.95,
|
|
65
|
+
description: 'GitHub Refresh Token',
|
|
66
|
+
},
|
|
67
|
+
// Stripe keys - sk_live_, sk_test_, pk_live_, pk_test_
|
|
68
|
+
{
|
|
69
|
+
provider: 'stripe',
|
|
70
|
+
pattern: /\bsk_live_[A-Za-z0-9]{24,}\b/g,
|
|
71
|
+
confidence: 0.95,
|
|
72
|
+
description: 'Stripe Live Secret Key',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
provider: 'stripe',
|
|
76
|
+
pattern: /\bsk_test_[A-Za-z0-9]{24,}\b/g,
|
|
77
|
+
confidence: 0.90,
|
|
78
|
+
description: 'Stripe Test Secret Key',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
provider: 'stripe',
|
|
82
|
+
pattern: /\bpk_live_[A-Za-z0-9]{24,}\b/g,
|
|
83
|
+
confidence: 0.90,
|
|
84
|
+
description: 'Stripe Live Publishable Key',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
provider: 'stripe',
|
|
88
|
+
pattern: /\bpk_test_[A-Za-z0-9]{24,}\b/g,
|
|
89
|
+
confidence: 0.85,
|
|
90
|
+
description: 'Stripe Test Publishable Key',
|
|
91
|
+
},
|
|
92
|
+
// Slack tokens - xoxb-, xoxp-, xoxa-, xoxr-, xoxs-
|
|
93
|
+
{
|
|
94
|
+
provider: 'slack',
|
|
95
|
+
pattern: /\bxoxb-[0-9]{10,13}-[0-9]{10,13}-[A-Za-z0-9]{24}\b/g,
|
|
96
|
+
confidence: 0.95,
|
|
97
|
+
description: 'Slack Bot Token',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
provider: 'slack',
|
|
101
|
+
pattern: /\bxoxp-[0-9]{10,13}-[0-9]{10,13}-[0-9]{10,13}-[A-Za-z0-9]{32}\b/g,
|
|
102
|
+
confidence: 0.95,
|
|
103
|
+
description: 'Slack User Token',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
provider: 'slack',
|
|
107
|
+
pattern: /\bxoxa-[0-9]+-[A-Za-z0-9]{24,}\b/g,
|
|
108
|
+
confidence: 0.95,
|
|
109
|
+
description: 'Slack App Token',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
provider: 'slack',
|
|
113
|
+
pattern: /\bxoxr-[0-9]+-[A-Za-z0-9]{24,}\b/g,
|
|
114
|
+
confidence: 0.95,
|
|
115
|
+
description: 'Slack Refresh Token',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
provider: 'slack',
|
|
119
|
+
pattern: /\bxoxs-[0-9]+-[A-Za-z0-9]{24,}\b/g,
|
|
120
|
+
confidence: 0.95,
|
|
121
|
+
description: 'Slack Session Token',
|
|
122
|
+
},
|
|
123
|
+
// Google API key - AIza... (39 total chars)
|
|
124
|
+
{
|
|
125
|
+
provider: 'google',
|
|
126
|
+
pattern: /\bAIza[A-Za-z0-9_-]{35,}\b/g,
|
|
127
|
+
confidence: 0.90,
|
|
128
|
+
description: 'Google API Key',
|
|
129
|
+
},
|
|
130
|
+
// Generic patterns (lower confidence)
|
|
131
|
+
{
|
|
132
|
+
provider: 'generic',
|
|
133
|
+
pattern: /\bapi[_-]?key[_-]?[=:]["']?([A-Za-z0-9_-]{20,})["']?/gi,
|
|
134
|
+
confidence: 0.70,
|
|
135
|
+
description: 'Generic API Key pattern',
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
/**
|
|
139
|
+
* Cloud credential patterns (environment variables)
|
|
140
|
+
*/
|
|
141
|
+
const CLOUD_CREDENTIAL_PATTERNS = [
|
|
142
|
+
{
|
|
143
|
+
provider: 'aws',
|
|
144
|
+
pattern: /AWS_SECRET_ACCESS_KEY\s*[=:]\s*["']?([A-Za-z0-9/+=]{40})["']?/g,
|
|
145
|
+
confidence: 0.95,
|
|
146
|
+
description: 'AWS Secret Access Key in env var',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
provider: 'aws',
|
|
150
|
+
pattern: /AWS_ACCESS_KEY_ID\s*[=:]\s*["']?(AKIA[0-9A-Z]{16})["']?/g,
|
|
151
|
+
confidence: 0.95,
|
|
152
|
+
description: 'AWS Access Key ID in env var',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
provider: 'google',
|
|
156
|
+
pattern: /GOOGLE_APPLICATION_CREDENTIALS\s*[=:]\s*["']?([^"'\s]+)["']?/g,
|
|
157
|
+
confidence: 0.85,
|
|
158
|
+
description: 'Google Application Credentials path',
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
/**
|
|
162
|
+
* Private key patterns
|
|
163
|
+
*/
|
|
164
|
+
const PRIVATE_KEY_PATTERNS = [
|
|
165
|
+
{
|
|
166
|
+
provider: 'generic',
|
|
167
|
+
pattern: /-----BEGIN\s+(?:RSA\s+)?PRIVATE\s+KEY-----/g,
|
|
168
|
+
confidence: 0.99,
|
|
169
|
+
description: 'Private key (RSA)',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
provider: 'generic',
|
|
173
|
+
pattern: /-----BEGIN\s+EC\s+PRIVATE\s+KEY-----/g,
|
|
174
|
+
confidence: 0.99,
|
|
175
|
+
description: 'Private key (EC)',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
provider: 'generic',
|
|
179
|
+
pattern: /-----BEGIN\s+OPENSSH\s+PRIVATE\s+KEY-----/g,
|
|
180
|
+
confidence: 0.99,
|
|
181
|
+
description: 'Private key (OpenSSH)',
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
provider: 'generic',
|
|
185
|
+
pattern: /-----BEGIN\s+PGP\s+PRIVATE\s+KEY\s+BLOCK-----/g,
|
|
186
|
+
confidence: 0.99,
|
|
187
|
+
description: 'Private key (PGP)',
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
/**
|
|
191
|
+
* Redact a value showing first and last few characters
|
|
192
|
+
*/
|
|
193
|
+
export function redactValue(value, showStart = 4, showEnd = 4) {
|
|
194
|
+
if (value.length <= showStart + showEnd + 3) {
|
|
195
|
+
// Too short to redact meaningfully
|
|
196
|
+
return value.slice(0, showStart) + '***';
|
|
197
|
+
}
|
|
198
|
+
return value.slice(0, showStart) + '***' + value.slice(-showEnd);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Match API keys in text
|
|
202
|
+
*/
|
|
203
|
+
export function matchApiKeys(text) {
|
|
204
|
+
const matches = [];
|
|
205
|
+
const seen = new Set();
|
|
206
|
+
// Check standard API key patterns
|
|
207
|
+
for (const pattern of API_KEY_PATTERNS) {
|
|
208
|
+
const regex = new RegExp(pattern.pattern.source, pattern.pattern.flags);
|
|
209
|
+
let match;
|
|
210
|
+
while ((match = regex.exec(text)) !== null) {
|
|
211
|
+
const value = match[1] || match[0];
|
|
212
|
+
// Skip if we've already seen this value
|
|
213
|
+
if (seen.has(value))
|
|
214
|
+
continue;
|
|
215
|
+
seen.add(value);
|
|
216
|
+
// Validate length if specified
|
|
217
|
+
if (pattern.minLength && value.length < pattern.minLength)
|
|
218
|
+
continue;
|
|
219
|
+
if (pattern.maxLength && value.length > pattern.maxLength)
|
|
220
|
+
continue;
|
|
221
|
+
matches.push({
|
|
222
|
+
matched: true,
|
|
223
|
+
provider: pattern.provider,
|
|
224
|
+
value,
|
|
225
|
+
redactedValue: redactValue(value),
|
|
226
|
+
confidence: pattern.confidence,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// Check cloud credential patterns
|
|
231
|
+
for (const pattern of CLOUD_CREDENTIAL_PATTERNS) {
|
|
232
|
+
const regex = new RegExp(pattern.pattern.source, pattern.pattern.flags);
|
|
233
|
+
let match;
|
|
234
|
+
while ((match = regex.exec(text)) !== null) {
|
|
235
|
+
const value = match[1] || match[0];
|
|
236
|
+
if (seen.has(value))
|
|
237
|
+
continue;
|
|
238
|
+
seen.add(value);
|
|
239
|
+
matches.push({
|
|
240
|
+
matched: true,
|
|
241
|
+
provider: pattern.provider,
|
|
242
|
+
value,
|
|
243
|
+
redactedValue: redactValue(value),
|
|
244
|
+
confidence: pattern.confidence,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// Check private key patterns
|
|
249
|
+
for (const pattern of PRIVATE_KEY_PATTERNS) {
|
|
250
|
+
const regex = new RegExp(pattern.pattern.source, pattern.pattern.flags);
|
|
251
|
+
if (regex.test(text)) {
|
|
252
|
+
matches.push({
|
|
253
|
+
matched: true,
|
|
254
|
+
provider: pattern.provider,
|
|
255
|
+
value: pattern.description,
|
|
256
|
+
redactedValue: '[PRIVATE KEY]',
|
|
257
|
+
confidence: pattern.confidence,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return matches;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* API Key Detector class
|
|
265
|
+
*/
|
|
266
|
+
export class ApiKeyDetector {
|
|
267
|
+
severity;
|
|
268
|
+
constructor(severity) {
|
|
269
|
+
this.severity = severity;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Scan text for API keys
|
|
273
|
+
*/
|
|
274
|
+
scan(text, location) {
|
|
275
|
+
const matches = matchApiKeys(text);
|
|
276
|
+
return matches.map((match) => ({
|
|
277
|
+
detected: true,
|
|
278
|
+
category: 'secrets',
|
|
279
|
+
severity: this.severity,
|
|
280
|
+
confidence: match.confidence,
|
|
281
|
+
reason: `Detected ${match.provider} API key/credential`,
|
|
282
|
+
metadata: {
|
|
283
|
+
type: 'api-key',
|
|
284
|
+
provider: match.provider,
|
|
285
|
+
redactedValue: match.redactedValue,
|
|
286
|
+
location,
|
|
287
|
+
},
|
|
288
|
+
}));
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Create an API key detector
|
|
293
|
+
*/
|
|
294
|
+
export function createApiKeyDetector(severity) {
|
|
295
|
+
return new ApiKeyDetector(severity);
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=api-key-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-key-detector.js","sourceRoot":"","sources":["../../../../src/detectors/secrets/api-key-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsBH;;GAEG;AACH,MAAM,gBAAgB,GAAoB;IACxC,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AAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,IAAY,EAAE,QAAgB;QACjC,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAEnC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7B,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,SAAkB;YAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,MAAM,EAAE,YAAY,KAAK,CAAC,QAAQ,qBAAqB;YACvD,QAAQ,EAAE;gBACR,IAAI,EAAE,SAAkB;gBACxB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,QAAQ;aACT;SACF,CAAC,CAAC,CAAC;IACN,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAkB;IACrD,OAAO,IAAI,cAAc,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secrets Detector
|
|
3
|
+
* Main detector that combines API key, token, credential, and PII detection
|
|
4
|
+
*/
|
|
5
|
+
import type { SecretsDetectionContext, SecretsDetectionResult, SecretsDetector as ISecretsDetector, SecretsDetectorConfig } from './types.js';
|
|
6
|
+
import type { SecretsRule } from '../../config/index.js';
|
|
7
|
+
export * from './types.js';
|
|
8
|
+
export { ApiKeyDetector, createApiKeyDetector, matchApiKeys, redactValue } from './api-key-detector.js';
|
|
9
|
+
export { TokenDetector, createTokenDetector, matchTokens, matchJwt, matchBearerToken, matchSessionToken, matchRefreshToken, matchAccessToken, isValidJwtStructure, } from './token-detector.js';
|
|
10
|
+
export { PiiDetector, createPiiDetector, matchPii, matchSsn, matchCreditCard, matchEmail, luhnCheck, isValidSsn, redactPii, } from './pii-detector.js';
|
|
11
|
+
/**
|
|
12
|
+
* Main secrets detector implementation
|
|
13
|
+
*/
|
|
14
|
+
export declare class SecretsDetectorImpl implements ISecretsDetector {
|
|
15
|
+
private config;
|
|
16
|
+
private apiKeyDetector;
|
|
17
|
+
private tokenDetector;
|
|
18
|
+
private piiDetector;
|
|
19
|
+
constructor(config: SecretsDetectorConfig);
|
|
20
|
+
detect(context: SecretsDetectionContext): Promise<SecretsDetectionResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Get all individual detection results (for detailed reporting)
|
|
23
|
+
*/
|
|
24
|
+
detectAll(context: SecretsDetectionContext): Promise<SecretsDetectionResult[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get the configured action for detected secrets
|
|
27
|
+
*/
|
|
28
|
+
getAction(): "block" | "confirm" | "agent-confirm" | "warn" | "log";
|
|
29
|
+
/**
|
|
30
|
+
* Check if the detector is enabled
|
|
31
|
+
*/
|
|
32
|
+
isEnabled(): boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Create a secrets detector from SecretsRule configuration
|
|
36
|
+
*/
|
|
37
|
+
export declare function createSecretsDetector(rule: SecretsRule): SecretsDetectorImpl;
|
|
38
|
+
/**
|
|
39
|
+
* Create a secrets detector with default configuration
|
|
40
|
+
*/
|
|
41
|
+
export declare function createDefaultSecretsDetector(): SecretsDetectorImpl;
|
|
42
|
+
export default SecretsDetectorImpl;
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|