shield360 1.1.0 → 1.2.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 +330 -3
- package/dist/__tests__/build-info.test.js +8 -1
- package/dist/__tests__/build-info.test.js.map +1 -1
- package/dist/__tests__/code-location.test.js +1 -1
- package/dist/__tests__/destination.test.js +15 -0
- package/dist/__tests__/destination.test.js.map +1 -1
- package/dist/__tests__/masking.test.d.ts +1 -0
- package/dist/__tests__/masking.test.js +66 -0
- package/dist/__tests__/masking.test.js.map +1 -0
- package/dist/__tests__/register.e2e.test.d.ts +1 -0
- package/dist/__tests__/register.e2e.test.js +279 -0
- package/dist/__tests__/register.e2e.test.js.map +1 -0
- package/dist/__tests__/register.test.js +60 -0
- package/dist/__tests__/register.test.js.map +1 -1
- package/dist/agents/__tests__/agents.test.d.ts +1 -0
- package/dist/agents/__tests__/agents.test.js +529 -0
- package/dist/agents/__tests__/agents.test.js.map +1 -0
- package/dist/agents/index.d.ts +15 -0
- package/dist/agents/index.js +25 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/passport.d.ts +92 -0
- package/dist/agents/passport.js +301 -0
- package/dist/agents/passport.js.map +1 -0
- package/dist/agents/policy.d.ts +24 -0
- package/dist/agents/policy.js +93 -0
- package/dist/agents/policy.js.map +1 -0
- package/dist/agents/replay.d.ts +20 -0
- package/dist/agents/replay.js +47 -0
- package/dist/agents/replay.js.map +1 -0
- package/dist/agents/report.d.ts +30 -0
- package/dist/agents/report.js +93 -0
- package/dist/agents/report.js.map +1 -0
- package/dist/agents/types.d.ts +148 -0
- package/dist/agents/types.js +37 -0
- package/dist/agents/types.js.map +1 -0
- package/dist/agents/verifier.d.ts +33 -0
- package/dist/agents/verifier.js +276 -0
- package/dist/agents/verifier.js.map +1 -0
- package/dist/ai-security/__tests__/bench.test.d.ts +1 -0
- package/dist/ai-security/__tests__/bench.test.js +50 -0
- package/dist/ai-security/__tests__/bench.test.js.map +1 -0
- package/dist/ai-security/__tests__/checks.test.d.ts +1 -0
- package/dist/ai-security/__tests__/checks.test.js +248 -0
- package/dist/ai-security/__tests__/checks.test.js.map +1 -0
- package/dist/ai-security/__tests__/config.test.d.ts +1 -0
- package/dist/ai-security/__tests__/config.test.js +164 -0
- package/dist/ai-security/__tests__/config.test.js.map +1 -0
- package/dist/ai-security/__tests__/detection.test.d.ts +1 -0
- package/dist/ai-security/__tests__/detection.test.js +114 -0
- package/dist/ai-security/__tests__/detection.test.js.map +1 -0
- package/dist/ai-security/__tests__/fixtures.d.ts +8 -0
- package/dist/ai-security/__tests__/fixtures.js +30 -0
- package/dist/ai-security/__tests__/fixtures.js.map +1 -0
- package/dist/ai-security/__tests__/hooks.test.d.ts +1 -0
- package/dist/ai-security/__tests__/hooks.test.js +174 -0
- package/dist/ai-security/__tests__/hooks.test.js.map +1 -0
- package/dist/ai-security/__tests__/stream.test.d.ts +1 -0
- package/dist/ai-security/__tests__/stream.test.js +85 -0
- package/dist/ai-security/__tests__/stream.test.js.map +1 -0
- package/dist/ai-security/config.d.ts +94 -0
- package/dist/ai-security/config.js +241 -0
- package/dist/ai-security/config.js.map +1 -0
- package/dist/ai-security/context.d.ts +45 -0
- package/dist/ai-security/context.js +108 -0
- package/dist/ai-security/context.js.map +1 -0
- package/dist/ai-security/custom-kinds.d.ts +23 -0
- package/dist/ai-security/custom-kinds.js +97 -0
- package/dist/ai-security/custom-kinds.js.map +1 -0
- package/dist/ai-security/events.d.ts +77 -0
- package/dist/ai-security/events.js +153 -0
- package/dist/ai-security/events.js.map +1 -0
- package/dist/ai-security/hooks.d.ts +48 -0
- package/dist/ai-security/hooks.js +461 -0
- package/dist/ai-security/hooks.js.map +1 -0
- package/dist/ai-security/index.d.ts +209 -0
- package/dist/ai-security/index.js +587 -0
- package/dist/ai-security/index.js.map +1 -0
- package/dist/ai-security/injection-rules.json +1024 -0
- package/dist/ai-security/injection.d.ts +46 -0
- package/dist/ai-security/injection.js +635 -0
- package/dist/ai-security/injection.js.map +1 -0
- package/dist/ai-security/jailbreak.d.ts +38 -0
- package/dist/ai-security/jailbreak.js +73 -0
- package/dist/ai-security/jailbreak.js.map +1 -0
- package/dist/ai-security/limits.d.ts +84 -0
- package/dist/ai-security/limits.js +195 -0
- package/dist/ai-security/limits.js.map +1 -0
- package/dist/ai-security/mcp.d.ts +82 -0
- package/dist/ai-security/mcp.js +150 -0
- package/dist/ai-security/mcp.js.map +1 -0
- package/dist/ai-security/output.d.ts +107 -0
- package/dist/ai-security/output.js +390 -0
- package/dist/ai-security/output.js.map +1 -0
- package/dist/ai-security/policy.d.ts +125 -0
- package/dist/ai-security/policy.js +196 -0
- package/dist/ai-security/policy.js.map +1 -0
- package/dist/ai-security/rag.d.ts +70 -0
- package/dist/ai-security/rag.js +174 -0
- package/dist/ai-security/rag.js.map +1 -0
- package/dist/ai-security/tool-rules.json +203 -0
- package/dist/ai-security/tools.d.ts +46 -0
- package/dist/ai-security/tools.js +62 -0
- package/dist/ai-security/tools.js.map +1 -0
- package/dist/budgets/__tests__/budgets.test.d.ts +1 -0
- package/dist/budgets/__tests__/budgets.test.js +134 -0
- package/dist/budgets/__tests__/budgets.test.js.map +1 -0
- package/dist/budgets/auto.d.ts +25 -0
- package/dist/budgets/auto.js +63 -0
- package/dist/budgets/auto.js.map +1 -0
- package/dist/budgets/index.d.ts +110 -0
- package/dist/budgets/index.js +239 -0
- package/dist/budgets/index.js.map +1 -0
- package/dist/customer/__tests__/customer.test.d.ts +1 -0
- package/dist/customer/__tests__/customer.test.js +155 -0
- package/dist/customer/__tests__/customer.test.js.map +1 -0
- package/dist/customer/index.d.ts +48 -0
- package/dist/customer/index.js +132 -0
- package/dist/customer/index.js.map +1 -0
- package/dist/destination.d.ts +14 -0
- package/dist/destination.js +16 -0
- package/dist/destination.js.map +1 -1
- package/dist/feedback/__tests__/feedback.test.d.ts +1 -0
- package/dist/feedback/__tests__/feedback.test.js +80 -0
- package/dist/feedback/__tests__/feedback.test.js.map +1 -0
- package/dist/feedback/index.d.ts +48 -0
- package/dist/feedback/index.js +97 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/flags/__tests__/flags.test.d.ts +1 -0
- package/dist/flags/__tests__/flags.test.js +301 -0
- package/dist/flags/__tests__/flags.test.js.map +1 -0
- package/dist/flags/client.d.ts +131 -0
- package/dist/flags/client.js +301 -0
- package/dist/flags/client.js.map +1 -0
- package/dist/flags/engine.d.ts +200 -0
- package/dist/flags/engine.js +677 -0
- package/dist/flags/engine.js.map +1 -0
- package/dist/flags/index.d.ts +4 -0
- package/dist/flags/index.js +16 -0
- package/dist/flags/index.js.map +1 -0
- package/dist/guard/__tests__/findings.test.js +1 -1
- package/dist/guard/__tests__/report.test.js +67 -0
- package/dist/guard/__tests__/report.test.js.map +1 -1
- package/dist/guard/heartbeat.d.ts +34 -0
- package/dist/guard/heartbeat.js +83 -0
- package/dist/guard/heartbeat.js.map +1 -0
- package/dist/guard/integration.d.ts +9 -0
- package/dist/guard/integration.js +4 -2
- package/dist/guard/integration.js.map +1 -1
- package/dist/guard/report.d.ts +24 -1
- package/dist/guard/report.js +67 -18
- package/dist/guard/report.js.map +1 -1
- package/dist/index.d.ts +88 -0
- package/dist/index.js +203 -2
- package/dist/index.js.map +1 -1
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js +1 -1
- package/dist/instrumentation/__tests__/langchain-wrapper.test.js.map +1 -1
- package/dist/instrumentation/anthropic/wrapper.js +4 -0
- package/dist/instrumentation/anthropic/wrapper.js.map +1 -1
- package/dist/instrumentation/openai/wrapper.js +6 -0
- package/dist/instrumentation/openai/wrapper.js.map +1 -1
- package/dist/masking.d.ts +42 -0
- package/dist/masking.js +197 -0
- package/dist/masking.js.map +1 -0
- package/dist/otel/__tests__/app-logs-safety.test.d.ts +1 -0
- package/dist/otel/__tests__/app-logs-safety.test.js +129 -0
- package/dist/otel/__tests__/app-logs-safety.test.js.map +1 -0
- package/dist/otel/__tests__/app-logs.test.d.ts +1 -0
- package/dist/otel/__tests__/app-logs.test.js +269 -0
- package/dist/otel/__tests__/app-logs.test.js.map +1 -0
- package/dist/otel/__tests__/log-auto.test.d.ts +1 -0
- package/dist/otel/__tests__/log-auto.test.js +125 -0
- package/dist/otel/__tests__/log-auto.test.js.map +1 -0
- package/dist/otel/__tests__/log-bridges.test.d.ts +1 -0
- package/dist/otel/__tests__/log-bridges.test.js +170 -0
- package/dist/otel/__tests__/log-bridges.test.js.map +1 -0
- package/dist/otel/__tests__/system-metrics.test.d.ts +1 -0
- package/dist/otel/__tests__/system-metrics.test.js +79 -0
- package/dist/otel/__tests__/system-metrics.test.js.map +1 -0
- package/dist/otel/app-logs.d.ts +80 -0
- package/dist/otel/app-logs.js +195 -0
- package/dist/otel/app-logs.js.map +1 -0
- package/dist/otel/build-info.d.ts +2 -1
- package/dist/otel/build-info.js +3 -2
- package/dist/otel/build-info.js.map +1 -1
- package/dist/otel/events.d.ts +1 -0
- package/dist/otel/events.js +22 -13
- package/dist/otel/events.js.map +1 -1
- package/dist/otel/log-auto.d.ts +44 -0
- package/dist/otel/log-auto.js +200 -0
- package/dist/otel/log-auto.js.map +1 -0
- package/dist/otel/log-bridges.d.ts +54 -0
- package/dist/otel/log-bridges.js +307 -0
- package/dist/otel/log-bridges.js.map +1 -0
- package/dist/otel/metrics.js +1 -1
- package/dist/otel/metrics.js.map +1 -1
- package/dist/otel/system-metrics.d.ts +39 -0
- package/dist/otel/system-metrics.js +166 -0
- package/dist/otel/system-metrics.js.map +1 -0
- package/dist/otel/tracing.js +6 -2
- package/dist/otel/tracing.js.map +1 -1
- package/dist/protect/__tests__/protect.test.js +4 -0
- package/dist/protect/__tests__/protect.test.js.map +1 -1
- package/dist/protect/index.js +9 -4
- package/dist/protect/index.js.map +1 -1
- package/dist/rasp/__tests__/auto-http.test.d.ts +1 -0
- package/dist/rasp/__tests__/auto-http.test.js +136 -0
- package/dist/rasp/__tests__/auto-http.test.js.map +1 -0
- package/dist/rasp/__tests__/baseline.test.d.ts +1 -0
- package/dist/rasp/__tests__/baseline.test.js +86 -0
- package/dist/rasp/__tests__/baseline.test.js.map +1 -0
- package/dist/rasp/__tests__/benign-corpus.test.d.ts +1 -0
- package/dist/rasp/__tests__/benign-corpus.test.js +68 -0
- package/dist/rasp/__tests__/benign-corpus.test.js.map +1 -0
- package/dist/rasp/__tests__/capture-context.test.d.ts +1 -0
- package/dist/rasp/__tests__/capture-context.test.js +135 -0
- package/dist/rasp/__tests__/capture-context.test.js.map +1 -0
- package/dist/rasp/__tests__/code-hook.test.d.ts +1 -0
- package/dist/rasp/__tests__/code-hook.test.js +218 -0
- package/dist/rasp/__tests__/code-hook.test.js.map +1 -0
- package/dist/rasp/__tests__/config-client.test.d.ts +1 -0
- package/dist/rasp/__tests__/config-client.test.js +283 -0
- package/dist/rasp/__tests__/config-client.test.js.map +1 -0
- package/dist/rasp/__tests__/corpus.d.ts +13 -0
- package/dist/rasp/__tests__/corpus.js +111 -0
- package/dist/rasp/__tests__/corpus.js.map +1 -0
- package/dist/rasp/__tests__/custom-rules.test.d.ts +1 -0
- package/dist/rasp/__tests__/custom-rules.test.js +276 -0
- package/dist/rasp/__tests__/custom-rules.test.js.map +1 -0
- package/dist/rasp/__tests__/db-hook.test.d.ts +1 -0
- package/dist/rasp/__tests__/db-hook.test.js +438 -0
- package/dist/rasp/__tests__/db-hook.test.js.map +1 -0
- package/dist/rasp/__tests__/deception.test.d.ts +1 -0
- package/dist/rasp/__tests__/deception.test.js +567 -0
- package/dist/rasp/__tests__/deception.test.js.map +1 -0
- package/dist/rasp/__tests__/detect.test.d.ts +1 -0
- package/dist/rasp/__tests__/detect.test.js +276 -0
- package/dist/rasp/__tests__/detect.test.js.map +1 -0
- package/dist/rasp/__tests__/esm-exports.test.d.ts +1 -0
- package/dist/rasp/__tests__/esm-exports.test.js +20 -0
- package/dist/rasp/__tests__/esm-exports.test.js.map +1 -0
- package/dist/rasp/__tests__/fs-hook.test.d.ts +1 -0
- package/dist/rasp/__tests__/fs-hook.test.js +241 -0
- package/dist/rasp/__tests__/fs-hook.test.js.map +1 -0
- package/dist/rasp/__tests__/hook-contracts.test.d.ts +1 -0
- package/dist/rasp/__tests__/hook-contracts.test.js +201 -0
- package/dist/rasp/__tests__/hook-contracts.test.js.map +1 -0
- package/dist/rasp/__tests__/hook-kit.d.ts +42 -0
- package/dist/rasp/__tests__/hook-kit.js +139 -0
- package/dist/rasp/__tests__/hook-kit.js.map +1 -0
- package/dist/rasp/__tests__/http-hook.test.d.ts +1 -0
- package/dist/rasp/__tests__/http-hook.test.js +250 -0
- package/dist/rasp/__tests__/http-hook.test.js.map +1 -0
- package/dist/rasp/__tests__/iast.test.d.ts +1 -0
- package/dist/rasp/__tests__/iast.test.js +361 -0
- package/dist/rasp/__tests__/iast.test.js.map +1 -0
- package/dist/rasp/__tests__/include-hook.test.d.ts +1 -0
- package/dist/rasp/__tests__/include-hook.test.js +122 -0
- package/dist/rasp/__tests__/include-hook.test.js.map +1 -0
- package/dist/rasp/__tests__/middleware.test.d.ts +1 -0
- package/dist/rasp/__tests__/middleware.test.js +302 -0
- package/dist/rasp/__tests__/middleware.test.js.map +1 -0
- package/dist/rasp/__tests__/process-hook.test.d.ts +1 -0
- package/dist/rasp/__tests__/process-hook.test.js +238 -0
- package/dist/rasp/__tests__/process-hook.test.js.map +1 -0
- package/dist/rasp/__tests__/reporter.test.d.ts +1 -0
- package/dist/rasp/__tests__/reporter.test.js +114 -0
- package/dist/rasp/__tests__/reporter.test.js.map +1 -0
- package/dist/rasp/__tests__/route.test.d.ts +1 -0
- package/dist/rasp/__tests__/route.test.js +46 -0
- package/dist/rasp/__tests__/route.test.js.map +1 -0
- package/dist/rasp/__tests__/rule-expr.test.d.ts +1 -0
- package/dist/rasp/__tests__/rule-expr.test.js +151 -0
- package/dist/rasp/__tests__/rule-expr.test.js.map +1 -0
- package/dist/rasp/__tests__/rule-phases.test.d.ts +1 -0
- package/dist/rasp/__tests__/rule-phases.test.js +271 -0
- package/dist/rasp/__tests__/rule-phases.test.js.map +1 -0
- package/dist/rasp/__tests__/sinks-hook.test.d.ts +1 -0
- package/dist/rasp/__tests__/sinks-hook.test.js +177 -0
- package/dist/rasp/__tests__/sinks-hook.test.js.map +1 -0
- package/dist/rasp/__tests__/targets.test.d.ts +1 -0
- package/dist/rasp/__tests__/targets.test.js +82 -0
- package/dist/rasp/__tests__/targets.test.js.map +1 -0
- package/dist/rasp/__tests__/template-hook.test.d.ts +1 -0
- package/dist/rasp/__tests__/template-hook.test.js +254 -0
- package/dist/rasp/__tests__/template-hook.test.js.map +1 -0
- package/dist/rasp/__tests__/upload.test.d.ts +1 -0
- package/dist/rasp/__tests__/upload.test.js +81 -0
- package/dist/rasp/__tests__/upload.test.js.map +1 -0
- package/dist/rasp/__tests__/vpatch-engine.test.d.ts +1 -0
- package/dist/rasp/__tests__/vpatch-engine.test.js +177 -0
- package/dist/rasp/__tests__/vpatch-engine.test.js.map +1 -0
- package/dist/rasp/auto-http.d.ts +6 -0
- package/dist/rasp/auto-http.js +194 -0
- package/dist/rasp/auto-http.js.map +1 -0
- package/dist/rasp/baseline.d.ts +35 -0
- package/dist/rasp/baseline.js +91 -0
- package/dist/rasp/baseline.js.map +1 -0
- package/dist/rasp/capture.d.ts +76 -0
- package/dist/rasp/capture.js +304 -0
- package/dist/rasp/capture.js.map +1 -0
- package/dist/rasp/config-client.d.ts +122 -0
- package/dist/rasp/config-client.js +337 -0
- package/dist/rasp/config-client.js.map +1 -0
- package/dist/rasp/context.d.ts +65 -0
- package/dist/rasp/context.js +68 -0
- package/dist/rasp/context.js.map +1 -0
- package/dist/rasp/custom-rules.d.ts +68 -0
- package/dist/rasp/custom-rules.js +222 -0
- package/dist/rasp/custom-rules.js.map +1 -0
- package/dist/rasp/data/default-rules.json +199 -0
- package/dist/rasp/data/default-sinks.json +4 -0
- package/dist/rasp/data/dnslog-domains.json +11 -0
- package/dist/rasp/deception.d.ts +70 -0
- package/dist/rasp/deception.js +220 -0
- package/dist/rasp/deception.js.map +1 -0
- package/dist/rasp/detect.d.ts +68 -0
- package/dist/rasp/detect.js +671 -0
- package/dist/rasp/detect.js.map +1 -0
- package/dist/rasp/engine.d.ts +107 -0
- package/dist/rasp/engine.js +330 -0
- package/dist/rasp/engine.js.map +1 -0
- package/dist/rasp/hooks/code.d.ts +20 -0
- package/dist/rasp/hooks/code.js +334 -0
- package/dist/rasp/hooks/code.js.map +1 -0
- package/dist/rasp/hooks/db.d.ts +48 -0
- package/dist/rasp/hooks/db.js +322 -0
- package/dist/rasp/hooks/db.js.map +1 -0
- package/dist/rasp/hooks/esm.d.ts +7 -0
- package/dist/rasp/hooks/esm.js +18 -0
- package/dist/rasp/hooks/esm.js.map +1 -0
- package/dist/rasp/hooks/fs.d.ts +3 -0
- package/dist/rasp/hooks/fs.js +206 -0
- package/dist/rasp/hooks/fs.js.map +1 -0
- package/dist/rasp/hooks/http.d.ts +4 -0
- package/dist/rasp/hooks/http.js +213 -0
- package/dist/rasp/hooks/http.js.map +1 -0
- package/dist/rasp/hooks/include.d.ts +9 -0
- package/dist/rasp/hooks/include.js +79 -0
- package/dist/rasp/hooks/include.js.map +1 -0
- package/dist/rasp/hooks/marks.d.ts +2 -0
- package/dist/rasp/hooks/marks.js +16 -0
- package/dist/rasp/hooks/marks.js.map +1 -0
- package/dist/rasp/hooks/process.d.ts +22 -0
- package/dist/rasp/hooks/process.js +191 -0
- package/dist/rasp/hooks/process.js.map +1 -0
- package/dist/rasp/hooks/sinks.d.ts +54 -0
- package/dist/rasp/hooks/sinks.js +329 -0
- package/dist/rasp/hooks/sinks.js.map +1 -0
- package/dist/rasp/hooks/template.d.ts +21 -0
- package/dist/rasp/hooks/template.js +152 -0
- package/dist/rasp/hooks/template.js.map +1 -0
- package/dist/rasp/iast-rules.d.ts +82 -0
- package/dist/rasp/iast-rules.js +240 -0
- package/dist/rasp/iast-rules.js.map +1 -0
- package/dist/rasp/iast-scope.d.ts +29 -0
- package/dist/rasp/iast-scope.js +54 -0
- package/dist/rasp/iast-scope.js.map +1 -0
- package/dist/rasp/iast.d.ts +81 -0
- package/dist/rasp/iast.js +272 -0
- package/dist/rasp/iast.js.map +1 -0
- package/dist/rasp/index.d.ts +52 -0
- package/dist/rasp/index.js +280 -0
- package/dist/rasp/index.js.map +1 -0
- package/dist/rasp/lexers.d.ts +32 -0
- package/dist/rasp/lexers.js +444 -0
- package/dist/rasp/lexers.js.map +1 -0
- package/dist/rasp/middleware.d.ts +155 -0
- package/dist/rasp/middleware.js +568 -0
- package/dist/rasp/middleware.js.map +1 -0
- package/dist/rasp/model-output.d.ts +14 -0
- package/dist/rasp/model-output.js +107 -0
- package/dist/rasp/model-output.js.map +1 -0
- package/dist/rasp/normalize.d.ts +23 -0
- package/dist/rasp/normalize.js +140 -0
- package/dist/rasp/normalize.js.map +1 -0
- package/dist/rasp/reporter.d.ts +60 -0
- package/dist/rasp/reporter.js +230 -0
- package/dist/rasp/reporter.js.map +1 -0
- package/dist/rasp/rule-expr.d.ts +236 -0
- package/dist/rasp/rule-expr.js +1253 -0
- package/dist/rasp/rule-expr.js.map +1 -0
- package/dist/rasp/template.d.ts +53 -0
- package/dist/rasp/template.js +336 -0
- package/dist/rasp/template.js.map +1 -0
- package/dist/rasp/types.d.ts +110 -0
- package/dist/rasp/types.js +51 -0
- package/dist/rasp/types.js.map +1 -0
- package/dist/rasp/vpatch.d.ts +55 -0
- package/dist/rasp/vpatch.js +120 -0
- package/dist/rasp/vpatch.js.map +1 -0
- package/dist/register.js +52 -11
- package/dist/register.js.map +1 -1
- package/dist/semantic-convention.d.ts +2 -0
- package/dist/semantic-convention.js +5 -0
- package/dist/semantic-convention.js.map +1 -1
- package/dist/types.d.ts +77 -1
- package/dist/zero-code.d.ts +8 -0
- package/dist/zero-code.js +38 -0
- package/dist/zero-code.js.map +1 -0
- package/package.json +18 -2
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IAST_MIN_NUMBER_LENGTH = exports.IAST_MIN_WORD_LENGTH = exports.IAST_MIN_LENGTH = exports.VULN_RULES = void 0;
|
|
4
|
+
exports.qualifies = qualifies;
|
|
5
|
+
exports.vulnSql = vulnSql;
|
|
6
|
+
exports.vulnShell = vulnShell;
|
|
7
|
+
exports.vulnArgv = vulnArgv;
|
|
8
|
+
exports.vulnPath = vulnPath;
|
|
9
|
+
exports.vulnSsrf = vulnSsrf;
|
|
10
|
+
exports.vulnCode = vulnCode;
|
|
11
|
+
exports.vulnInclude = vulnInclude;
|
|
12
|
+
exports.vulnData = vulnData;
|
|
13
|
+
/**
|
|
14
|
+
* Passive IAST rules (README "Passive IAST"). Pure: each takes what a
|
|
15
|
+
* detector already computed (the sink text, its tokens, the inputs) and says
|
|
16
|
+
* whether a request input reaches the sink verbatim in a place the app did
|
|
17
|
+
* not parameterize, even though the value is harmless and the attack check
|
|
18
|
+
* found nothing. The detectors call these through iast-scope.ts only when
|
|
19
|
+
* passive IAST is armed for the current check, so the rules never run, and
|
|
20
|
+
* never lex, when it is off.
|
|
21
|
+
*/
|
|
22
|
+
const lexers_1 = require("./lexers");
|
|
23
|
+
exports.VULN_RULES = [
|
|
24
|
+
'vuln.sql_concat',
|
|
25
|
+
'vuln.cmd_shell',
|
|
26
|
+
'vuln.cmd_arg',
|
|
27
|
+
'vuln.path_from_input',
|
|
28
|
+
'vuln.ssrf_host',
|
|
29
|
+
'vuln.code_eval',
|
|
30
|
+
'vuln.include_from_input',
|
|
31
|
+
'vuln.deser_input',
|
|
32
|
+
'vuln.xml_external',
|
|
33
|
+
];
|
|
34
|
+
/** Shortest input considered. */
|
|
35
|
+
exports.IAST_MIN_LENGTH = 3;
|
|
36
|
+
/** Letters-only inputs shorter than this are common words that also appear hard-coded ('active', 'name'). */
|
|
37
|
+
exports.IAST_MIN_WORD_LENGTH = 8;
|
|
38
|
+
/** Digits-only inputs shorter than this are small numbers that also appear hard-coded (`LIMIT 100`). */
|
|
39
|
+
exports.IAST_MIN_NUMBER_LENGTH = 4;
|
|
40
|
+
const BORING_WORDS = new Set('true false null none nil undefined yes no on off asc desc'.split(' '));
|
|
41
|
+
/**
|
|
42
|
+
* Whether an input value is specific enough that finding it verbatim in a
|
|
43
|
+
* sink means it came from the request, not a coincidence with a literal the
|
|
44
|
+
* app wrote itself. Conservative on purpose (README "Thresholds").
|
|
45
|
+
*/
|
|
46
|
+
function qualifies(value) {
|
|
47
|
+
const v = value;
|
|
48
|
+
if (v.length < exports.IAST_MIN_LENGTH)
|
|
49
|
+
return false;
|
|
50
|
+
if (BORING_WORDS.has(v.toLowerCase()))
|
|
51
|
+
return false;
|
|
52
|
+
if (/^[A-Za-z]+$/.test(v) && v.length < exports.IAST_MIN_WORD_LENGTH)
|
|
53
|
+
return false;
|
|
54
|
+
if (/^[0-9.+-]+$/.test(v) && v.length < exports.IAST_MIN_NUMBER_LENGTH)
|
|
55
|
+
return false;
|
|
56
|
+
if (v.split('').every((c) => c === v[0]))
|
|
57
|
+
return false;
|
|
58
|
+
// Only spaces and punctuation.
|
|
59
|
+
if (!/[\p{L}\p{N}]/u.test(v))
|
|
60
|
+
return false;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
const candidates = (inputs) => inputs.filter((i) => i.source === 'request' && qualifies(i.value));
|
|
64
|
+
const isComment = (t) => t.kind === 'comment' || t.kind === 'version_comment';
|
|
65
|
+
// ---- SQL ----------------------------------------------------------------
|
|
66
|
+
/**
|
|
67
|
+
* vuln.sql_concat: an input sits in the query text inside a string literal,
|
|
68
|
+
* as a whole number literal, as a whole identifier (not a keyword), or as a
|
|
69
|
+
* run of whole tokens the attack check let through (a sort list such as
|
|
70
|
+
* `created_at desc`). Never inside a comment (sqlcommenter tags), never when
|
|
71
|
+
* the input is the whole query (a SQL console).
|
|
72
|
+
*/
|
|
73
|
+
function vulnSql(query, inputs, tokens) {
|
|
74
|
+
const trimmed = query.trim();
|
|
75
|
+
for (const inp of candidates(inputs)) {
|
|
76
|
+
const v = inp.value;
|
|
77
|
+
if (v === query || v.trim() === trimmed)
|
|
78
|
+
continue;
|
|
79
|
+
for (const idx of (0, lexers_1.occurrences)(query, v)) {
|
|
80
|
+
const over = (0, lexers_1.overlapping)(tokens(), idx, v.length);
|
|
81
|
+
if (!over.length || over.some(isComment))
|
|
82
|
+
continue;
|
|
83
|
+
const end = idx + v.length;
|
|
84
|
+
if (over.length === 1) {
|
|
85
|
+
const t = over[0];
|
|
86
|
+
if (t.kind === 'string' && idx > t.s && end <= t.e)
|
|
87
|
+
return { rule: 'vuln.sql_concat', input: inp, position: 'string' };
|
|
88
|
+
const whole = t.s === idx && t.e === end;
|
|
89
|
+
if (whole && t.kind === 'number')
|
|
90
|
+
return { rule: 'vuln.sql_concat', input: inp, position: 'number' };
|
|
91
|
+
if (whole && t.kind === 'name')
|
|
92
|
+
return { rule: 'vuln.sql_concat', input: inp, position: 'identifier' };
|
|
93
|
+
if (whole && t.kind === 'word' && !lexers_1.SQL_KEYWORDS.has(t.text.toLowerCase()))
|
|
94
|
+
return { rule: 'vuln.sql_concat', input: inp, position: 'identifier' };
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (over[0].s === idx && over[over.length - 1].e === end)
|
|
98
|
+
return { rule: 'vuln.sql_concat', input: inp, position: 'tokens' };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
// ---- Command ----------------------------------------------------------------
|
|
104
|
+
/**
|
|
105
|
+
* vuln.cmd_shell: an input sits inside one word of a shell-interpreted
|
|
106
|
+
* command (the attack check fires when it spans two or more tokens).
|
|
107
|
+
*/
|
|
108
|
+
function vulnShell(command, inputs, tokens) {
|
|
109
|
+
const trimmed = command.trim();
|
|
110
|
+
for (const inp of candidates(inputs)) {
|
|
111
|
+
const v = inp.value;
|
|
112
|
+
if (v.trim() === trimmed)
|
|
113
|
+
continue;
|
|
114
|
+
for (const idx of (0, lexers_1.occurrences)(command, v)) {
|
|
115
|
+
const over = (0, lexers_1.overlapping)(tokens, idx, v.length);
|
|
116
|
+
if (over.length === 1 && over[0].kind === 'word')
|
|
117
|
+
return { rule: 'vuln.cmd_shell', input: inp, position: 'word' };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* vuln.cmd_arg: an argument (not the executable) of an argv spawn without a
|
|
124
|
+
* shell equals or contains an input. The caller skips `sh -c <script>`
|
|
125
|
+
* spawns, whose script is checked as shell text.
|
|
126
|
+
*/
|
|
127
|
+
function vulnArgv(argv, inputs) {
|
|
128
|
+
for (const inp of candidates(inputs)) {
|
|
129
|
+
for (let k = 1; k < argv.length; k++) {
|
|
130
|
+
const a = argv[k];
|
|
131
|
+
if (typeof a === 'string' && a.includes(inp.value))
|
|
132
|
+
return { rule: 'vuln.cmd_arg', input: inp, position: 'argument' };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
// ---- Path ----------------------------------------------------------------
|
|
138
|
+
/**
|
|
139
|
+
* vuln.path_from_input: an input (normalized like the path) forms whole path
|
|
140
|
+
* segments: it starts at the start of a segment and ends at the end of one,
|
|
141
|
+
* or right before a `.` in it (`/data/<input>.json`).
|
|
142
|
+
*/
|
|
143
|
+
function vulnPath(normalizedPath, inputs, norm) {
|
|
144
|
+
const np = normalizedPath;
|
|
145
|
+
for (const inp of candidates(inputs)) {
|
|
146
|
+
const ni = norm(inp.value);
|
|
147
|
+
if (!ni || ni === '/')
|
|
148
|
+
continue;
|
|
149
|
+
for (const idx of (0, lexers_1.occurrences)(np, ni)) {
|
|
150
|
+
const end = idx + ni.length;
|
|
151
|
+
const startOk = idx === 0 || np[idx - 1] === '/' || ni.startsWith('/');
|
|
152
|
+
const endOk = end === np.length || np[end] === '/' || np[end] === '.' || ni.endsWith('/');
|
|
153
|
+
if (startOk && endOk)
|
|
154
|
+
return { rule: 'vuln.path_from_input', input: inp, position: 'segment' };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
// ---- SSRF ----------------------------------------------------------------
|
|
160
|
+
/**
|
|
161
|
+
* The `host[:port]` of a URL as written (lower-cased), and the offset just
|
|
162
|
+
* past the host itself (after any userinfo), or null without an authority.
|
|
163
|
+
*/
|
|
164
|
+
function authorityOf(url, host) {
|
|
165
|
+
const m = /^[A-Za-z][A-Za-z0-9+.-]*:\/\//.exec(url);
|
|
166
|
+
if (!m)
|
|
167
|
+
return null;
|
|
168
|
+
const rest = url.slice(m[0].length);
|
|
169
|
+
const end = rest.search(/[/?#\\]/);
|
|
170
|
+
const auth = end < 0 ? rest : rest.slice(0, end);
|
|
171
|
+
const hostStart = m[0].length + auth.lastIndexOf('@') + 1;
|
|
172
|
+
const bracket = url[hostStart] === '[' ? 2 : 0;
|
|
173
|
+
return { authority: auth.slice(auth.lastIndexOf('@') + 1).toLowerCase(), hostEnd: hostStart + host.length + bracket };
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* vuln.ssrf_host: the URL's host is an input (equal to the host or to
|
|
177
|
+
* `host:port`), or an input is a prefix of the URL that covers its scheme
|
|
178
|
+
* and host (a base URL or whole URL from the request). An input that merely
|
|
179
|
+
* mentions the host somewhere in longer text does not count.
|
|
180
|
+
*/
|
|
181
|
+
function vulnSsrf(url, raw, inputs) {
|
|
182
|
+
const host = raw.host;
|
|
183
|
+
const auth = host ? authorityOf(url, host) : null;
|
|
184
|
+
const authority = auth?.authority ?? '';
|
|
185
|
+
// The prefix must reach past the destination host itself, not a copy of it in the userinfo.
|
|
186
|
+
const hostEnd = host ? (auth ? auth.hostEnd : url.length + 1) : url.indexOf(':') + 1;
|
|
187
|
+
for (const inp of candidates(inputs)) {
|
|
188
|
+
const v = inp.value.toLowerCase();
|
|
189
|
+
if (host && (v === host || v === authority || v === `[${host}]`))
|
|
190
|
+
return { rule: 'vuln.ssrf_host', input: inp, position: 'host' };
|
|
191
|
+
if (url.startsWith(inp.value) && inp.value.length >= hostEnd && (host || inp.value.length > hostEnd))
|
|
192
|
+
return { rule: 'vuln.ssrf_host', input: inp, position: 'url' };
|
|
193
|
+
}
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
// ---- Code, include, deserialization, XML ------------------------------------
|
|
197
|
+
/**
|
|
198
|
+
* vuln.code_eval: an input sits inside a string literal of evaluated code,
|
|
199
|
+
* or is a whole identifier or number in it (the attack check fires when it
|
|
200
|
+
* spans two or more tokens or is the whole code). Never inside a comment.
|
|
201
|
+
*/
|
|
202
|
+
function vulnCode(code, inputs, tokens) {
|
|
203
|
+
for (const inp of candidates(inputs)) {
|
|
204
|
+
const v = inp.value;
|
|
205
|
+
if (v === code)
|
|
206
|
+
continue;
|
|
207
|
+
for (const idx of (0, lexers_1.occurrences)(code, v)) {
|
|
208
|
+
const over = (0, lexers_1.overlapping)(tokens(), idx, v.length);
|
|
209
|
+
if (over.length !== 1)
|
|
210
|
+
continue;
|
|
211
|
+
const t = over[0];
|
|
212
|
+
const end = idx + v.length;
|
|
213
|
+
if (t.kind === 'string' && idx > t.s && end <= t.e)
|
|
214
|
+
return { rule: 'vuln.code_eval', input: inp, position: 'string' };
|
|
215
|
+
if (t.s === idx && t.e === end && (t.kind === 'word' || t.kind === 'number'))
|
|
216
|
+
return { rule: 'vuln.code_eval', input: inp, position: t.kind === 'word' ? 'identifier' : 'number' };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
/** vuln.include_from_input: a module specifier contains an input (the attack check covers equal and path-like inputs). */
|
|
222
|
+
function vulnInclude(specifier, inputs) {
|
|
223
|
+
for (const inp of candidates(inputs)) {
|
|
224
|
+
if (inp.value !== specifier && specifier.includes(inp.value))
|
|
225
|
+
return { rule: 'vuln.include_from_input', input: inp, position: 'specifier' };
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* vuln.deser_input / vuln.xml_external: the data handed to an unsafe
|
|
231
|
+
* deserializer, or to an XML parser that resolves external entities, is
|
|
232
|
+
* tainted (the caller decides with the contract's taintedData), at least
|
|
233
|
+
* 3 characters long, by an input that qualifies.
|
|
234
|
+
*/
|
|
235
|
+
function vulnData(rule, data, inp) {
|
|
236
|
+
if (!inp || inp.source !== 'request' || data.length < exports.IAST_MIN_LENGTH || !qualifies(inp.value))
|
|
237
|
+
return null;
|
|
238
|
+
return { rule, input: inp, position: 'data' };
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=iast-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iast-rules.js","sourceRoot":"","sources":["../../src/rasp/iast-rules.ts"],"names":[],"mappings":";;;AA4CA,8BAUC;AAeD,0BAsBC;AAQD,8BAWC;AAOD,4BAQC;AASD,4BAaC;AAyBD,4BAYC;AASD,4BAcC;AAGD,kCAKC;AAQD,4BAGC;AAlOD;;;;;;;;GAQG;AACH,qCAA8E;AAGjE,QAAA,UAAU,GAAG;IACxB,iBAAiB;IACjB,gBAAgB;IAChB,cAAc;IACd,sBAAsB;IACtB,gBAAgB;IAChB,gBAAgB;IAChB,yBAAyB;IACzB,kBAAkB;IAClB,mBAAmB;CACX,CAAC;AAQX,iCAAiC;AACpB,QAAA,eAAe,GAAG,CAAC,CAAC;AACjC,6GAA6G;AAChG,QAAA,oBAAoB,GAAG,CAAC,CAAC;AACtC,wGAAwG;AAC3F,QAAA,sBAAsB,GAAG,CAAC,CAAC;AAExC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,2DAA2D,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAErG;;;;GAIG;AACH,SAAgB,SAAS,CAAC,KAAa;IACrC,MAAM,CAAC,GAAG,KAAK,CAAC;IAChB,IAAI,CAAC,CAAC,MAAM,GAAG,uBAAe;QAAE,OAAO,KAAK,CAAC;IAC7C,IAAI,YAAY,CAA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,CAAC,MAAM,CAAC,EAAE,CAAC;QACrC,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;YAAE,OAAO,EAAE,IAAI,EAAE,yBAAyB,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IAC9I,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAgB,QAAQ,CAAC,IAA8C,EAAE,IAAY,EAAE,GAA0B;IAC/G,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,GAAG,uBAAe,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5G,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passive IAST: the slot a check's detectors write a vulnerability into
|
|
3
|
+
* (README "Passive IAST"). engine.ts arms a slot for one check when passive
|
|
4
|
+
* IAST is on and the check is sampled; the detectors in detect.ts call
|
|
5
|
+
* `noteVulnerability` with a rule from iast-rules.ts, which runs only while a
|
|
6
|
+
* slot is armed. Unarmed, the cost is one comparison per detector call.
|
|
7
|
+
*/
|
|
8
|
+
import type { Vuln } from './iast-rules';
|
|
9
|
+
export type IastSlot = {
|
|
10
|
+
prev: IastSlot | null;
|
|
11
|
+
vuln: Vuln | null;
|
|
12
|
+
closed: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Arms a slot for the check about to run (nested checks keep their own). */
|
|
15
|
+
export declare function armIastSlot(): IastSlot;
|
|
16
|
+
/** Disarms a slot; returns the vulnerability noted in it, once. Idempotent. */
|
|
17
|
+
export declare function closeIastSlot(slot: IastSlot): Vuln | null;
|
|
18
|
+
/** Whether a slot is armed for the running check. */
|
|
19
|
+
export declare function iastArmed(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Runs a vulnerability rule when a slot is armed and keeps its first result.
|
|
22
|
+
* Never throws: a rule that fails is ignored.
|
|
23
|
+
*/
|
|
24
|
+
export declare function noteVulnerability(rule: () => Vuln | null): void;
|
|
25
|
+
/** Runs fn with a slot armed and returns what it returned and the vulnerability noted (tests, conformance). */
|
|
26
|
+
export declare function captureVulnerability<T>(fn: () => T): {
|
|
27
|
+
result: T;
|
|
28
|
+
vuln: Vuln | null;
|
|
29
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.armIastSlot = armIastSlot;
|
|
4
|
+
exports.closeIastSlot = closeIastSlot;
|
|
5
|
+
exports.iastArmed = iastArmed;
|
|
6
|
+
exports.noteVulnerability = noteVulnerability;
|
|
7
|
+
exports.captureVulnerability = captureVulnerability;
|
|
8
|
+
let current = null;
|
|
9
|
+
/** Arms a slot for the check about to run (nested checks keep their own). */
|
|
10
|
+
function armIastSlot() {
|
|
11
|
+
const slot = { prev: current, vuln: null, closed: false };
|
|
12
|
+
current = slot;
|
|
13
|
+
return slot;
|
|
14
|
+
}
|
|
15
|
+
/** Disarms a slot; returns the vulnerability noted in it, once. Idempotent. */
|
|
16
|
+
function closeIastSlot(slot) {
|
|
17
|
+
if (slot.closed)
|
|
18
|
+
return null;
|
|
19
|
+
slot.closed = true;
|
|
20
|
+
if (current === slot)
|
|
21
|
+
current = slot.prev;
|
|
22
|
+
return slot.vuln;
|
|
23
|
+
}
|
|
24
|
+
/** Whether a slot is armed for the running check. */
|
|
25
|
+
function iastArmed() {
|
|
26
|
+
return current !== null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Runs a vulnerability rule when a slot is armed and keeps its first result.
|
|
30
|
+
* Never throws: a rule that fails is ignored.
|
|
31
|
+
*/
|
|
32
|
+
function noteVulnerability(rule) {
|
|
33
|
+
const slot = current;
|
|
34
|
+
if (!slot || slot.vuln)
|
|
35
|
+
return;
|
|
36
|
+
try {
|
|
37
|
+
slot.vuln = rule();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// passive IAST never breaks a check
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Runs fn with a slot armed and returns what it returned and the vulnerability noted (tests, conformance). */
|
|
44
|
+
function captureVulnerability(fn) {
|
|
45
|
+
const slot = armIastSlot();
|
|
46
|
+
try {
|
|
47
|
+
const result = fn();
|
|
48
|
+
return { result, vuln: closeIastSlot(slot) };
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
closeIastSlot(slot);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=iast-scope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iast-scope.js","sourceRoot":"","sources":["../../src/rasp/iast-scope.ts"],"names":[],"mappings":";;AAcA,kCAIC;AAGD,sCAKC;AAGD,8BAEC;AAMD,8CAQC;AAGD,oDAQC;AA7CD,IAAI,OAAO,GAAoB,IAAI,CAAC;AAEpC,6EAA6E;AAC7E,SAAgB,WAAW;IACzB,MAAM,IAAI,GAAa,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IACpE,OAAO,GAAG,IAAI,CAAC;IACf,OAAO,IAAI,CAAC;AACd,CAAC;AAED,+EAA+E;AAC/E,SAAgB,aAAa,CAAC,IAAc;IAC1C,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACnB,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC;IAC1C,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAED,qDAAqD;AACrD,SAAgB,SAAS;IACvB,OAAO,OAAO,KAAK,IAAI,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,IAAuB;IACvD,MAAM,IAAI,GAAG,OAAO,CAAC;IACrB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI;QAAE,OAAO;IAC/B,IAAI,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,oCAAoC;IACtC,CAAC;AACH,CAAC;AAED,+GAA+G;AAC/G,SAAgB,oBAAoB,CAAI,EAAW;IACjD,MAAM,IAAI,GAAG,WAAW,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,EAAE,CAAC;QACpB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/C,CAAC;YAAS,CAAC;QACT,aAAa,CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { eventRouteOf } from './context';
|
|
2
|
+
/** Where reports go: the RASP reporter. `add` returning false means it refused the event (rate limit, full queue). */
|
|
3
|
+
export type IastEventSink = {
|
|
4
|
+
add(event: {
|
|
5
|
+
name: string;
|
|
6
|
+
time: string;
|
|
7
|
+
attrs: Record<string, string>;
|
|
8
|
+
}, foldKey: string): boolean | void;
|
|
9
|
+
};
|
|
10
|
+
import { type IastSlot } from './iast-scope';
|
|
11
|
+
export declare const RASP_VULNERABILITY = "shield360.rasp.vulnerability";
|
|
12
|
+
/** A fingerprint is reported at most once per this period per process. */
|
|
13
|
+
export declare const IAST_REPORT_EVERY_MS: number;
|
|
14
|
+
/** Fingerprints remembered per process; the oldest is forgotten past this. */
|
|
15
|
+
export declare const IAST_MAX_FINGERPRINTS = 10000;
|
|
16
|
+
export declare const IAST_DEFAULT_RATE = 1;
|
|
17
|
+
export declare const IAST_DEFAULT_RATE_PRODUCTION = 0.1;
|
|
18
|
+
export type IastSetting = 'on' | 'off';
|
|
19
|
+
/** `init({ rasp: { iast } })`: true / false, or options. */
|
|
20
|
+
export type IastOptions = boolean | {
|
|
21
|
+
enabled?: boolean;
|
|
22
|
+
sampleRate?: number;
|
|
23
|
+
};
|
|
24
|
+
export type IastSettings = {
|
|
25
|
+
option?: IastOptions;
|
|
26
|
+
applicationName: string;
|
|
27
|
+
environment?: string;
|
|
28
|
+
env?: NodeJS.ProcessEnv;
|
|
29
|
+
/** Tests: a clock and a sampler. */
|
|
30
|
+
now?: () => number;
|
|
31
|
+
random?: () => number;
|
|
32
|
+
};
|
|
33
|
+
/** Reads the local option and the environment (`SHIELD360_IAST`, `SHIELD360_IAST_SAMPLE_RATE`). Forgets what was seen. */
|
|
34
|
+
export declare function configureIast(s: IastSettings): void;
|
|
35
|
+
/** The verified signed config's switch and rate (undefined drops them). */
|
|
36
|
+
export declare function setIastRemote(c: {
|
|
37
|
+
iast?: unknown;
|
|
38
|
+
iastSampleRate?: unknown;
|
|
39
|
+
version?: string;
|
|
40
|
+
} | undefined): void;
|
|
41
|
+
export declare function setIastSink(sink: IastEventSink | undefined): void;
|
|
42
|
+
/**
|
|
43
|
+
* Whether passive IAST is on. Order: `SHIELD360_IAST=off` wins; then the
|
|
44
|
+
* signed config's `iast`; then the local option or `SHIELD360_IAST=on`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function iastEnabled(): boolean;
|
|
47
|
+
/** The share of checks that run the IAST rules: env, then the signed config, then the option, then 1.0 (0.1 in production). */
|
|
48
|
+
export declare function iastSampleRate(): number;
|
|
49
|
+
/**
|
|
50
|
+
* Arms the IAST slot for one check, or returns null: off, not sampled, or
|
|
51
|
+
* no request input in scope. engine.check calls it only while RASP is active.
|
|
52
|
+
*/
|
|
53
|
+
export declare function beginIast(): IastSlot | null;
|
|
54
|
+
export type IastExtra = {
|
|
55
|
+
framework?: string;
|
|
56
|
+
route?: string;
|
|
57
|
+
method?: string;
|
|
58
|
+
path?: string;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Disarms the slot. With a sink (the check found no attack), reports the
|
|
62
|
+
* vulnerability its detectors noted, if any. Never throws.
|
|
63
|
+
*/
|
|
64
|
+
export declare function endIast(slot: IastSlot, report?: {
|
|
65
|
+
sink: string;
|
|
66
|
+
extra?: IastExtra;
|
|
67
|
+
}): void;
|
|
68
|
+
/** The fingerprint: SHA-256 of route, sink, input key and rule (NUL-separated), first 32 hex. */
|
|
69
|
+
export declare function vulnFingerprint(route: string, sink: string, inputKey: string, rule: string): string;
|
|
70
|
+
/** The route of a finding whose framework gave no template: the event route (README "Event route"). */
|
|
71
|
+
export declare const iastRouteOf: typeof eventRouteOf;
|
|
72
|
+
/** Whether a stack frame's file is the app's own code. */
|
|
73
|
+
export declare function isAppFrame(file: string): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The top stack frame in the app's own code (outside node_modules, Node's
|
|
76
|
+
* internals and the SDK), as `path:line` relative to the working directory
|
|
77
|
+
* (only the last three segments when outside it), or '' when there is none.
|
|
78
|
+
*/
|
|
79
|
+
export declare function codeLocation(stack?: string): string;
|
|
80
|
+
/** Forgets every fingerprint seen and the configuration (tests, re-init). */
|
|
81
|
+
export declare function resetIast(): void;
|