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,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom RASP rule expressions (sdk/rasp/README.md "Custom rules").
|
|
3
|
+
*
|
|
4
|
+
* A small, sandboxed, CEL-style expression language: a fixed set of fields,
|
|
5
|
+
* string literals, comparison, `in`, a handful of string methods, a safe
|
|
6
|
+
* regular-expression subset matched in linear time, and CIDR matching,
|
|
7
|
+
* joined by `&&`, `||` and `!`. No loops, no function definitions, no I/O,
|
|
8
|
+
* nothing outside the fields. Expressions are parsed and type-checked once
|
|
9
|
+
* and evaluated as data; nothing downloaded is ever run as code.
|
|
10
|
+
*
|
|
11
|
+
* This file is shared: `sdk/typescript/src/rasp/rule-expr.ts` and
|
|
12
|
+
* `src/client/src/lib/security/rasp/rule-expr.ts` are byte-identical (a test
|
|
13
|
+
* in each tree says so), so the platform accepts exactly what the SDK runs.
|
|
14
|
+
* It imports nothing.
|
|
15
|
+
*/
|
|
16
|
+
/** Hard limits, identical on the platform and in every SDK. */
|
|
17
|
+
export declare const RULE_EXPR_LIMITS: Readonly<{
|
|
18
|
+
/** UTF-8 bytes of the whole expression. */
|
|
19
|
+
expressionBytes: 2048;
|
|
20
|
+
/** AST depth (a leaf is 1), and parenthesis nesting. */
|
|
21
|
+
depth: 12;
|
|
22
|
+
/** AST nodes. */
|
|
23
|
+
nodes: 128;
|
|
24
|
+
/** UTF-8 bytes of one string literal, after escapes. */
|
|
25
|
+
stringBytes: 1024;
|
|
26
|
+
/** Items in one `in [...]` list. */
|
|
27
|
+
listItems: 64;
|
|
28
|
+
/** `matches` calls in one expression. */
|
|
29
|
+
regexes: 8;
|
|
30
|
+
/** UTF-8 bytes of one pattern. */
|
|
31
|
+
regexBytes: 256;
|
|
32
|
+
/** Atoms of one pattern once counted repetitions are expanded. */
|
|
33
|
+
regexAtoms: 256;
|
|
34
|
+
/** The largest bound in `{n}`, `{n,}`, `{n,m}`. */
|
|
35
|
+
regexRepeat: 100;
|
|
36
|
+
/** `matches` reads at most this many code points of its subject. */
|
|
37
|
+
matchCodePoints: 4096;
|
|
38
|
+
}>;
|
|
39
|
+
export type RuleExprErrorCode = "empty" | "too_long" | "syntax" | "depth" | "nodes" | "string_too_long" | "list_too_long" | "unknown_field" | "unknown_method" | "type" | "regex" | "too_many_regexes" | "cidr"
|
|
40
|
+
/** A context this parser does not know (README "Collector contexts"). */
|
|
41
|
+
| "context";
|
|
42
|
+
export type RuleExprError = {
|
|
43
|
+
code: RuleExprErrorCode;
|
|
44
|
+
pos: number;
|
|
45
|
+
};
|
|
46
|
+
export type RuleFieldType = "string" | "map";
|
|
47
|
+
/** The fields an expression may read (README "Custom rules: fields"). */
|
|
48
|
+
export declare const RULE_FIELDS: Readonly<Record<string, RuleFieldType>>;
|
|
49
|
+
/**
|
|
50
|
+
* Where an expression runs, which decides the fields it may read (README
|
|
51
|
+
* "Collector contexts"): an app's RASP (`app`, the fields above), a coding
|
|
52
|
+
* agent's tool call (`agent_tool`) or a request through the AI proxy
|
|
53
|
+
* (`ai_proxy`). The grammar, types and limits are the same everywhere.
|
|
54
|
+
*/
|
|
55
|
+
export type RuleContext = "app" | "agent_tool" | "ai_proxy";
|
|
56
|
+
/** The fields of each collector context. None is a map. */
|
|
57
|
+
export declare const COLLECTOR_RULE_FIELDS: Readonly<Record<Exclude<RuleContext, "app">, Readonly<Record<string, RuleFieldType>>>>;
|
|
58
|
+
/** The fields an expression may read in a context, or null for one this parser does not know. */
|
|
59
|
+
export declare function ruleContextFields(context: RuleContext): Readonly<Record<string, RuleFieldType>> | null;
|
|
60
|
+
/** One untrusted input of the request (the SDK's input list). */
|
|
61
|
+
export type RuleInput = {
|
|
62
|
+
value: string;
|
|
63
|
+
key: string;
|
|
64
|
+
source: string;
|
|
65
|
+
};
|
|
66
|
+
/** What an expression is evaluated against. Missing parts read as null. */
|
|
67
|
+
export type RuleSubject = {
|
|
68
|
+
app?: string | null;
|
|
69
|
+
request?: {
|
|
70
|
+
method?: string | null;
|
|
71
|
+
path?: string | null;
|
|
72
|
+
route?: string | null;
|
|
73
|
+
ip?: string | null;
|
|
74
|
+
/** Lower-case header names. */
|
|
75
|
+
headers?: Record<string, string>;
|
|
76
|
+
/** Query parameter name -> first value. */
|
|
77
|
+
query?: Record<string, string>;
|
|
78
|
+
/** Flattened body path (`user.name`) -> string leaf. */
|
|
79
|
+
body?: Record<string, string>;
|
|
80
|
+
} | null;
|
|
81
|
+
inputs?: RuleInput[];
|
|
82
|
+
sink?: string | null;
|
|
83
|
+
attack?: {
|
|
84
|
+
type?: string | null;
|
|
85
|
+
rule?: string | null;
|
|
86
|
+
} | null;
|
|
87
|
+
/** The collector contexts' fields (README "Collector contexts"). */
|
|
88
|
+
collector?: {
|
|
89
|
+
tool?: {
|
|
90
|
+
name?: string | null;
|
|
91
|
+
command?: string | null;
|
|
92
|
+
path?: string | null;
|
|
93
|
+
} | null;
|
|
94
|
+
agent?: {
|
|
95
|
+
name?: string | null;
|
|
96
|
+
} | null;
|
|
97
|
+
ai?: {
|
|
98
|
+
provider?: string | null;
|
|
99
|
+
model?: string | null;
|
|
100
|
+
tokens?: string | null;
|
|
101
|
+
} | null;
|
|
102
|
+
user?: {
|
|
103
|
+
id?: string | null;
|
|
104
|
+
} | null;
|
|
105
|
+
device?: {
|
|
106
|
+
os?: string | null;
|
|
107
|
+
} | null;
|
|
108
|
+
} | null;
|
|
109
|
+
};
|
|
110
|
+
type CmpOp = "==" | "!=" | "<" | "<=" | ">" | ">=";
|
|
111
|
+
type StrMethod = "startsWith" | "endsWith" | "contains";
|
|
112
|
+
/** Regular-expression program (Pike VM). */
|
|
113
|
+
type Inst = {
|
|
114
|
+
op: "char";
|
|
115
|
+
c: number;
|
|
116
|
+
} | {
|
|
117
|
+
op: "any";
|
|
118
|
+
} | {
|
|
119
|
+
op: "class";
|
|
120
|
+
r: number[];
|
|
121
|
+
neg: boolean;
|
|
122
|
+
} | {
|
|
123
|
+
op: "split";
|
|
124
|
+
x: number;
|
|
125
|
+
y: number;
|
|
126
|
+
} | {
|
|
127
|
+
op: "jmp";
|
|
128
|
+
x: number;
|
|
129
|
+
} | {
|
|
130
|
+
op: "bol";
|
|
131
|
+
} | {
|
|
132
|
+
op: "eol";
|
|
133
|
+
} | {
|
|
134
|
+
op: "match";
|
|
135
|
+
};
|
|
136
|
+
type Net = {
|
|
137
|
+
bytes: number[];
|
|
138
|
+
prefix: number;
|
|
139
|
+
};
|
|
140
|
+
export type RuleNode = {
|
|
141
|
+
k: "str";
|
|
142
|
+
v: string;
|
|
143
|
+
} | {
|
|
144
|
+
k: "bool";
|
|
145
|
+
v: boolean;
|
|
146
|
+
} | {
|
|
147
|
+
k: "null";
|
|
148
|
+
} | {
|
|
149
|
+
k: "field";
|
|
150
|
+
name: string;
|
|
151
|
+
key?: string;
|
|
152
|
+
} | {
|
|
153
|
+
k: "not";
|
|
154
|
+
x: RuleNode;
|
|
155
|
+
} | {
|
|
156
|
+
k: "and" | "or";
|
|
157
|
+
xs: RuleNode[];
|
|
158
|
+
} | {
|
|
159
|
+
k: "cmp";
|
|
160
|
+
op: CmpOp;
|
|
161
|
+
l: RuleNode;
|
|
162
|
+
r: RuleNode;
|
|
163
|
+
} | {
|
|
164
|
+
k: "in";
|
|
165
|
+
l: RuleNode;
|
|
166
|
+
items: string[];
|
|
167
|
+
} | {
|
|
168
|
+
k: "str_method";
|
|
169
|
+
m: StrMethod;
|
|
170
|
+
t: RuleNode;
|
|
171
|
+
arg: string;
|
|
172
|
+
} | {
|
|
173
|
+
k: "lower";
|
|
174
|
+
t: RuleNode;
|
|
175
|
+
} | {
|
|
176
|
+
k: "matches";
|
|
177
|
+
t: RuleNode;
|
|
178
|
+
prog: Inst[];
|
|
179
|
+
} | {
|
|
180
|
+
k: "cidr";
|
|
181
|
+
t: RuleNode;
|
|
182
|
+
net: Net;
|
|
183
|
+
};
|
|
184
|
+
export type CompiledRuleExpr = {
|
|
185
|
+
ast: RuleNode;
|
|
186
|
+
/** Field names read (without map keys). */
|
|
187
|
+
fields: string[];
|
|
188
|
+
/** `finding` when the expression reads `sink.*` or `attack.*`, else `request`. */
|
|
189
|
+
phase: "request" | "finding";
|
|
190
|
+
/** Reads `input.*`: evaluated once per input, true when any input makes it true. */
|
|
191
|
+
usesInput: boolean;
|
|
192
|
+
/** Reads `request.body[...]`. */
|
|
193
|
+
usesBody: boolean;
|
|
194
|
+
/** The context it was compiled for. */
|
|
195
|
+
context: RuleContext;
|
|
196
|
+
};
|
|
197
|
+
export type RuleExprResult = {
|
|
198
|
+
ok: true;
|
|
199
|
+
expr: CompiledRuleExpr;
|
|
200
|
+
} | {
|
|
201
|
+
ok: false;
|
|
202
|
+
error: RuleExprError;
|
|
203
|
+
};
|
|
204
|
+
/** UTF-8 length of a JS string (a lone surrogate counts 3, as its U+FFFD replacement). */
|
|
205
|
+
export declare function utf8Length(s: string): number;
|
|
206
|
+
/**
|
|
207
|
+
* Parses and type-checks an expression. Every limit is checked here; an
|
|
208
|
+
* expression that compiles is safe to evaluate on any input.
|
|
209
|
+
*/
|
|
210
|
+
export declare function compileRuleExpr(src: unknown, context?: RuleContext): RuleExprResult;
|
|
211
|
+
/** Work left for one evaluation (regex steps); exhausting it ends the evaluation as no match. */
|
|
212
|
+
export type RuleBudget = {
|
|
213
|
+
steps: number;
|
|
214
|
+
};
|
|
215
|
+
export declare const DEFAULT_RULE_BUDGET = 4000000;
|
|
216
|
+
export type RuleEvalResult = {
|
|
217
|
+
matched: boolean;
|
|
218
|
+
input?: RuleInput;
|
|
219
|
+
exhausted?: boolean;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Evaluates a compiled expression. An expression that reads `input.*` is
|
|
223
|
+
* evaluated once per input, in order, and matches when any input makes it
|
|
224
|
+
* true (with no inputs, once with the input fields null). Never throws: an
|
|
225
|
+
* evaluation that runs out of budget, or fails in any way, is no match.
|
|
226
|
+
*/
|
|
227
|
+
export declare function evaluateRuleExpr(expr: CompiledRuleExpr, subject: RuleSubject, budget?: RuleBudget): RuleEvalResult;
|
|
228
|
+
/** Checks a pattern against the safe subset and compiles it; null when refused. */
|
|
229
|
+
export declare function compileRegex(pattern: string): Inst[] | null;
|
|
230
|
+
/** Whether a pattern is in the safe subset. */
|
|
231
|
+
export declare function isSafeRegex(pattern: string): boolean;
|
|
232
|
+
/** An IPv4 or IPv6 address as 16 bytes (IPv4 as `::ffff:a.b.c.d`); null when not an address. */
|
|
233
|
+
export declare function parseIpBytes(s: string): number[] | null;
|
|
234
|
+
/** `a.b.c.d/n`, `x:y::z/n`, or a bare address (all bits). Null when malformed. */
|
|
235
|
+
export declare function parseCidr(s: string): Net | null;
|
|
236
|
+
export {};
|