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
package/dist/guard/report.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* When `init` is given a Shield360 URL and API key (or SHIELD360_URL /
|
|
6
6
|
* SHIELD360_API_KEY), every guard decision other than allow is sent to
|
|
7
7
|
* `/api/guard/events`: which guard, what it did, the kind of data found, in
|
|
8
|
-
* which app,
|
|
8
|
+
* which app (its service name, as its telemetry reports it), on which host.
|
|
9
|
+
* Never the text that was checked.
|
|
9
10
|
*
|
|
10
11
|
* With each report go the values found, masked, and fingerprinted with the
|
|
11
12
|
* organisation's key (fetched from `/api/guard/config`), so a reviewer can see
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
*/
|
|
20
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
22
|
exports.EVENT_NAME = void 0;
|
|
23
|
+
exports.postGuardEvents = postGuardEvents;
|
|
22
24
|
exports.configureGuardReports = configureGuardReports;
|
|
23
25
|
exports.reportGuardDecision = reportGuardDecision;
|
|
24
26
|
exports.flushGuardReports = flushGuardReports;
|
|
@@ -26,6 +28,7 @@ exports.resetGuardReports = resetGuardReports;
|
|
|
26
28
|
const crypto_1 = require("crypto");
|
|
27
29
|
const os_1 = require("os");
|
|
28
30
|
const findings_1 = require("./findings");
|
|
31
|
+
const heartbeat_1 = require("./heartbeat");
|
|
29
32
|
exports.EVENT_NAME = 'shield360.guard.decision';
|
|
30
33
|
const BATCH = 100;
|
|
31
34
|
const FLUSH_MS = 2000;
|
|
@@ -41,6 +44,7 @@ class Reporter {
|
|
|
41
44
|
this.sending = Promise.resolve();
|
|
42
45
|
/** Settles once the fingerprint key has been fetched (or could not be). */
|
|
43
46
|
this.keyReady = Promise.resolve();
|
|
47
|
+
this.beat = null;
|
|
44
48
|
this.timer = setInterval(() => void this.flush(), FLUSH_MS);
|
|
45
49
|
// Never keep a process alive just to report.
|
|
46
50
|
this.timer.unref?.();
|
|
@@ -62,33 +66,73 @@ class Reporter {
|
|
|
62
66
|
return this.sending;
|
|
63
67
|
}
|
|
64
68
|
async post(batch) {
|
|
65
|
-
|
|
66
|
-
|
|
69
|
+
await postGuardEvents(this.endpoint, this.apiKey, { resource: this.resource, events: batch }, { label: 'guard report' });
|
|
70
|
+
}
|
|
71
|
+
/** Sends a heartbeat now and then about every five minutes (heartbeat.ts). Never throws. */
|
|
72
|
+
startHeartbeat(guards, sdkVersion) {
|
|
73
|
+
const send = () => {
|
|
67
74
|
try {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${this.apiKey}` },
|
|
71
|
-
body,
|
|
72
|
-
});
|
|
73
|
-
if (res.ok)
|
|
74
|
-
return;
|
|
75
|
-
if ([400, 401, 403, 413].includes(res.status)) {
|
|
76
|
-
console.warn(`Shield360 rejected guard reports: HTTP ${res.status}`);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
75
|
+
this.add({ name: heartbeat_1.HEARTBEAT_EVENT_NAME, time: new Date().toISOString(), attrs: (0, heartbeat_1.heartbeatAttrs)(guards, this.applicationName, sdkVersion) });
|
|
76
|
+
void this.flush().catch(() => undefined);
|
|
79
77
|
}
|
|
80
78
|
catch {
|
|
81
|
-
//
|
|
79
|
+
// a heartbeat is never worth an error in the app
|
|
82
80
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
this.beat = setTimeout(send, (0, heartbeat_1.nextDelay)());
|
|
82
|
+
this.beat.unref?.();
|
|
83
|
+
};
|
|
84
|
+
send();
|
|
86
85
|
}
|
|
87
86
|
close() {
|
|
88
87
|
clearInterval(this.timer);
|
|
88
|
+
if (this.beat)
|
|
89
|
+
clearTimeout(this.beat);
|
|
90
|
+
this.beat = null;
|
|
89
91
|
return this.flush();
|
|
90
92
|
}
|
|
91
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* Posts one batch to `/api/guard/events`: the transport guard reports, the
|
|
96
|
+
* heartbeat and runtime-protection (RASP) events share. Retries a few times,
|
|
97
|
+
* gives up on a refusal, and never throws. Resolves to whether it was accepted.
|
|
98
|
+
*/
|
|
99
|
+
async function postGuardEvents(endpoint, apiKey, payload, options = {}) {
|
|
100
|
+
const label = options.label ?? 'guard report';
|
|
101
|
+
const attempts = options.attempts ?? ATTEMPTS;
|
|
102
|
+
const delay = options.retryDelayMs ?? 500;
|
|
103
|
+
const send = options.fetchImpl ?? globalThis.fetch;
|
|
104
|
+
if (typeof send !== 'function')
|
|
105
|
+
return false;
|
|
106
|
+
let body;
|
|
107
|
+
try {
|
|
108
|
+
body = JSON.stringify(payload);
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
114
|
+
try {
|
|
115
|
+
const res = await send(endpoint, {
|
|
116
|
+
method: 'POST',
|
|
117
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${apiKey}` },
|
|
118
|
+
body,
|
|
119
|
+
});
|
|
120
|
+
if (res.ok)
|
|
121
|
+
return true;
|
|
122
|
+
if ([400, 401, 403, 413].includes(res.status)) {
|
|
123
|
+
console.warn(`Shield360 rejected ${label}s: HTTP ${res.status}`);
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// retried below
|
|
129
|
+
}
|
|
130
|
+
if (attempt + 1 < attempts)
|
|
131
|
+
await new Promise((r) => setTimeout(r, delay * (attempt + 1)));
|
|
132
|
+
}
|
|
133
|
+
console.warn(`Could not deliver ${payload.events.length} ${label}(s) to Shield360`);
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
92
136
|
/** Findings go out fingerprinted if the key has arrived since they were made. */
|
|
93
137
|
function serialise(event) {
|
|
94
138
|
const { findings, ...rest } = event;
|
|
@@ -122,6 +166,8 @@ function configureGuardReports(opts) {
|
|
|
122
166
|
'user.name': user,
|
|
123
167
|
'deployment.environment': opts.environment,
|
|
124
168
|
'service.version': opts.sdkVersion || '',
|
|
169
|
+
// The app, by the service name its telemetry uses (security per app).
|
|
170
|
+
'service.name': opts.applicationName,
|
|
125
171
|
})) {
|
|
126
172
|
if (v)
|
|
127
173
|
resource[k] = v;
|
|
@@ -130,6 +176,8 @@ function configureGuardReports(opts) {
|
|
|
130
176
|
const base = opts.url.replace(/\/+$/, '');
|
|
131
177
|
reporter = new Reporter(`${base}/api/guard/events`, opts.apiKey, resource, opts.applicationName);
|
|
132
178
|
reporter.keyReady = fetchFingerprintKey(base, opts.apiKey);
|
|
179
|
+
if (opts.guards?.length && (0, heartbeat_1.heartbeatEnabled)(opts.heartbeat))
|
|
180
|
+
reporter.startHeartbeat(opts.guards, opts.sdkVersion || '');
|
|
133
181
|
return true;
|
|
134
182
|
}
|
|
135
183
|
/** The organisation's fingerprint key; without it findings are masked only. */
|
|
@@ -162,6 +210,7 @@ function reportGuardDecision(guardName, action, classification, phase, findings
|
|
|
162
210
|
attrs: {
|
|
163
211
|
'shield360.guard.event_id': (0, crypto_1.randomUUID)().replace(/-/g, ''),
|
|
164
212
|
'shield360.guard.client': reporter.applicationName,
|
|
213
|
+
'shield360.guard.app': reporter.applicationName,
|
|
165
214
|
'shield360.guard.action': action,
|
|
166
215
|
'shield360.guard.target': phase,
|
|
167
216
|
'shield360.guard.kinds': kinds,
|
package/dist/guard/report.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/guard/report.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/guard/report.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AA8FH,0CAoCC;AAoBD,sDAmCC;AAeD,kDA4BC;AAGD,8CAEC;AAGD,8CAGC;AA7OD,mCAAoC;AACpC,2BAAwC;AAExC,yCAAyE;AACzE,2CAAgG;AAEnF,QAAA,UAAU,GAAG,0BAA0B,CAAC;AACrD,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,QAAQ,GAAG,CAAC,CAA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CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;AACzD,CAAC;AAED,kCAAkC;AAC3B,KAAK,UAAU,iBAAiB;IACrC,MAAM,QAAQ,EAAE,KAAK,EAAE,CAAC;IACxB,QAAQ,GAAG,IAAI,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { usingAttributes, injectAdditionalAttributes, setAgentVersion, resetAgen
|
|
|
5
5
|
import { runEval, runEvalBatch, fetchEvalTypes } from './evals';
|
|
6
6
|
import { logScore } from './score';
|
|
7
7
|
import { TracedSpan, startTrace, trace as traceManual } from './manual-trace';
|
|
8
|
+
import { captureConsole, captureStdio, pinoStream, releaseConsole, releaseStdio, winstonTransport } from './otel/log-bridges';
|
|
8
9
|
import { PII } from './guard/pii';
|
|
9
10
|
import { PromptInjection } from './guard/prompt-injection';
|
|
10
11
|
import { Moderation } from './guard/moderation';
|
|
@@ -13,6 +14,12 @@ import { TopicRestriction } from './guard/topic-restriction';
|
|
|
13
14
|
import { Schema } from './guard/schema';
|
|
14
15
|
import { Custom } from './guard/custom';
|
|
15
16
|
import { Pipeline } from './guard/pipeline';
|
|
17
|
+
import { budgets, configureBudgets, BudgetClient, BudgetExceededError } from './budgets';
|
|
18
|
+
import { setCustomer, withCustomer, getCustomer, CustomerSpanProcessor } from './customer';
|
|
19
|
+
import { aiSecurity, configureAiSecurity, AiSecurityBlockedError } from './ai-security';
|
|
20
|
+
import { feedback, getCurrentSpanId, getCurrentTraceId } from './feedback';
|
|
21
|
+
import { disableRasp, enableRasp } from './rasp';
|
|
22
|
+
import { createLogger } from './otel/app-logs';
|
|
16
23
|
import { Guard, GuardAction, GuardPhase, GuardError, GuardDeniedError, GuardTimeoutError, GuardConfigError, PipelineResult } from './guard/base';
|
|
17
24
|
declare class Shield360 extends BaseShield360 {
|
|
18
25
|
static resource: ReturnType<typeof resourceFromAttributes>;
|
|
@@ -54,8 +61,72 @@ declare class Shield360 extends BaseShield360 {
|
|
|
54
61
|
static resetAgentVersion: typeof resetAgentVersion;
|
|
55
62
|
static withAgentVersion: typeof runWithAgentVersion;
|
|
56
63
|
static getAgentVersion: typeof getCurrentAgentVersion;
|
|
64
|
+
/**
|
|
65
|
+
* Send what one of your users thought of an AI response (thumbs 1/-1 or
|
|
66
|
+
* stars 1-5) against its trace. Server side, with the environment's API
|
|
67
|
+
* key. Resolves to whether it was accepted; never throws.
|
|
68
|
+
*/
|
|
69
|
+
static feedback: typeof feedback;
|
|
70
|
+
/** The active span's trace id, to keep with a response so a later rating can name it. */
|
|
71
|
+
static getCurrentTraceId: typeof getCurrentTraceId;
|
|
72
|
+
static getCurrentSpanId: typeof getCurrentSpanId;
|
|
57
73
|
static startTrace: typeof startTrace;
|
|
58
74
|
static trace: typeof traceManual;
|
|
75
|
+
/** SHIELD: a logger for application logs; a no-op unless captureLogs is on. */
|
|
76
|
+
static logger: typeof createLogger;
|
|
77
|
+
/** SHIELD: bridges from pino, winston and console to application logs (no-ops unless captureLogs is on). */
|
|
78
|
+
static pinoStream: typeof pinoStream;
|
|
79
|
+
static winstonTransport: typeof winstonTransport;
|
|
80
|
+
static captureConsole: typeof captureConsole;
|
|
81
|
+
static releaseConsole: typeof releaseConsole;
|
|
82
|
+
static captureStdio: typeof captureStdio;
|
|
83
|
+
static releaseStdio: typeof releaseStdio;
|
|
84
|
+
/** Feature flags: `Shield360.flags.getFlag(key, context, default)` and `isEnabled(key, context)`. */
|
|
85
|
+
static flags: import("./flags").FlagsClient;
|
|
86
|
+
/** Budget check: Shield360.budgets.check({ model, estimatedCostUsd }) never throws; see ./budgets. */
|
|
87
|
+
static budgets: {
|
|
88
|
+
check: (options?: import("./budgets").BudgetCheckOptions) => Promise<import("./budgets").BudgetCheckResult>;
|
|
89
|
+
configure: typeof configureBudgets;
|
|
90
|
+
reset: () => void;
|
|
91
|
+
};
|
|
92
|
+
static BudgetExceededError: typeof BudgetExceededError;
|
|
93
|
+
/**
|
|
94
|
+
* Cost per end customer. setCustomer({ tenantId, userId? }) sets a process-wide
|
|
95
|
+
* default (null clears it); withCustomer(customer, fn) scopes one to fn and its
|
|
96
|
+
* async work, winning over the default; getCustomer() returns the one in effect.
|
|
97
|
+
* Invalid ids are dropped silently. The SDK never hashes: Shield360 stores user
|
|
98
|
+
* ids only as a keyed hash, and tenant ids as given unless the organisation opts
|
|
99
|
+
* to hash them. See ./customer.
|
|
100
|
+
*/
|
|
101
|
+
static setCustomer: typeof setCustomer;
|
|
102
|
+
/** SHIELD: the runtime kill switch for RASP (env SHIELD360_RASP=off and the signed config's killSwitch win over it). */
|
|
103
|
+
static disableRasp: typeof disableRasp;
|
|
104
|
+
static enableRasp: typeof enableRasp;
|
|
105
|
+
static withCustomer: typeof withCustomer;
|
|
106
|
+
static getCustomer: typeof getCustomer;
|
|
107
|
+
/** AI security pack: Shield360.aiSecurity.scanContext(), scanOutput(), defineTool(), ... See ./ai-security. */
|
|
108
|
+
static aiSecurity: {
|
|
109
|
+
configure: typeof configureAiSecurity;
|
|
110
|
+
policy: typeof import("./ai-security").currentPolicy;
|
|
111
|
+
scanContext: typeof import("./ai-security").scanContext;
|
|
112
|
+
checkPrompt: typeof import("./ai-security").checkPrompt;
|
|
113
|
+
scanOutput: typeof import("./ai-security").scanOutput;
|
|
114
|
+
streamScanner: typeof import("./ai-security").streamScanner;
|
|
115
|
+
withCanary: typeof import("./ai-security").withCanary;
|
|
116
|
+
tagContext: typeof import("./ai-security").tagContext;
|
|
117
|
+
defineTool: typeof import("./ai-security").defineTool;
|
|
118
|
+
authorizeTool: typeof import("./ai-security").authorizeTool;
|
|
119
|
+
checkLimits: typeof import("./ai-security").checkLimits;
|
|
120
|
+
recordUsage: typeof import("./ai-security").recordUsage;
|
|
121
|
+
syncLimitsNow: typeof import("./ai-security").syncLimitsNow;
|
|
122
|
+
checkMcpTools: typeof import("./ai-security").checkMcpTools;
|
|
123
|
+
checkRetrieval: typeof import("./ai-security").checkRetrieval;
|
|
124
|
+
withEndUser: <T>(user: import("./ai-security").EndUserInput | null, fn: () => T) => T;
|
|
125
|
+
setEndUser: typeof import("./ai-security").setEndUser;
|
|
126
|
+
flush: typeof import("./ai-security").flushAiSecurity;
|
|
127
|
+
BlockedError: typeof AiSecurityBlockedError;
|
|
128
|
+
};
|
|
129
|
+
static AiSecurityBlockedError: typeof AiSecurityBlockedError;
|
|
59
130
|
static init(options?: Shield360Options): void;
|
|
60
131
|
}
|
|
61
132
|
declare const shield360: typeof Shield360 & {
|
|
@@ -65,9 +136,26 @@ declare const shield360: typeof Shield360 & {
|
|
|
65
136
|
export default shield360;
|
|
66
137
|
export { Shield360, usingAttributes, injectAdditionalAttributes, logScore };
|
|
67
138
|
export { TracedSpan, startTrace, traceManual as trace };
|
|
139
|
+
export { budgets, BudgetClient, BudgetExceededError };
|
|
140
|
+
export type { BudgetCheckOptions, BudgetCheckResult, BudgetAction, BudgetClientOptions } from './budgets';
|
|
141
|
+
export { createLogger } from './otel/app-logs';
|
|
142
|
+
export type { Shield360Logger, LogLevel } from './otel/app-logs';
|
|
143
|
+
export { FlagsClient, flags } from './flags';
|
|
144
|
+
export type { FlagsOptions, FlagDetail, FlagDefinition, EvaluationContext, Evaluation, FlagValue, PromptRef, PromptFlagOptions, PromptFlagResult, Segment } from './flags';
|
|
145
|
+
export { setCustomer, withCustomer, getCustomer, CustomerSpanProcessor };
|
|
146
|
+
export type { Customer, CustomerInput } from './customer';
|
|
147
|
+
export { aiSecurity, AiSecurityBlockedError };
|
|
148
|
+
export type { AiSecurityPolicy, AiSecurityPolicyInput, AiSecurityEvent, EndUserInput } from './ai-security';
|
|
149
|
+
export type { AiSecurityInitOptions } from './types';
|
|
68
150
|
export type { Shield360Options } from './types';
|
|
69
151
|
export type { LogScoreOptions } from './score';
|
|
152
|
+
export { feedback, getCurrentTraceId, getCurrentSpanId } from './feedback';
|
|
153
|
+
export type { FeedbackOptions, FeedbackScale } from './feedback';
|
|
70
154
|
export { protectTool, authorizeWithShield360, protectReadiness, ProtectDeniedError, ProtectReadinessError, ProtectError } from './protect';
|
|
71
155
|
export type { ProtectMode, ProtectConfig, ProtectReadiness, ProtectToolOptions, AuthorizeTarget, AuthorizeAnswer } from './protect';
|
|
156
|
+
export { agentVerifier, AGENT_HEADER, MemoryReplayStore } from './agents';
|
|
157
|
+
export type { AgentVerifier, AgentVerifierOptions, AgentCheck, AgentCheckOptions, AgentCheckInput, AgentPolicy, ReplayStore } from './agents';
|
|
158
|
+
export { raspExpress, raspExpressErrorHandler, raspFastify, raspKoa, raspHttp, withRasp, recordRequestBody, recordModelOutput, recordToolArguments, runInRaspScope, disableRasp, enableRasp, raspActive, isRaspBlocked, RaspBlockedError, Shield360RaspBlocked, } from './rasp';
|
|
159
|
+
export type { RaspOptions, RaspMode, AttackType as RaspAttackType, ConfigPublicKey } from './rasp';
|
|
72
160
|
export { PII, PromptInjection, Moderation, SensitiveTopic, TopicRestriction, Schema, Custom, Pipeline, Guard, GuardAction, GuardPhase, GuardError, GuardDeniedError, GuardTimeoutError, GuardConfigError, PipelineResult, };
|
|
73
161
|
export type { GuardResult } from './guard/base';
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Moderation = exports.PromptInjection = exports.PII = exports.Shield360RaspBlocked = exports.RaspBlockedError = exports.isRaspBlocked = exports.raspActive = exports.enableRasp = exports.disableRasp = exports.runInRaspScope = exports.recordToolArguments = exports.recordModelOutput = exports.recordRequestBody = exports.withRasp = exports.raspHttp = exports.raspKoa = exports.raspFastify = exports.raspExpressErrorHandler = exports.raspExpress = exports.MemoryReplayStore = exports.AGENT_HEADER = exports.agentVerifier = exports.ProtectError = exports.ProtectReadinessError = exports.ProtectDeniedError = exports.protectReadiness = exports.authorizeWithShield360 = exports.protectTool = exports.getCurrentSpanId = exports.getCurrentTraceId = exports.feedback = exports.AiSecurityBlockedError = exports.aiSecurity = exports.CustomerSpanProcessor = exports.getCustomer = exports.withCustomer = exports.setCustomer = exports.flags = exports.FlagsClient = exports.createLogger = exports.BudgetExceededError = exports.BudgetClient = exports.budgets = exports.trace = exports.startTrace = exports.TracedSpan = exports.logScore = exports.injectAdditionalAttributes = exports.usingAttributes = exports.Shield360 = void 0;
|
|
7
|
+
exports.PipelineResult = exports.GuardConfigError = exports.GuardTimeoutError = exports.GuardDeniedError = exports.GuardError = exports.GuardPhase = exports.GuardAction = exports.Guard = exports.Pipeline = exports.Custom = exports.Schema = exports.TopicRestriction = exports.SensitiveTopic = void 0;
|
|
7
8
|
const resources_1 = require("@opentelemetry/resources");
|
|
8
9
|
const semantic_conventions_1 = require("@opentelemetry/semantic-conventions");
|
|
9
10
|
const api_1 = require("@opentelemetry/api");
|
|
@@ -24,6 +25,12 @@ Object.defineProperty(exports, "TracedSpan", { enumerable: true, get: function (
|
|
|
24
25
|
Object.defineProperty(exports, "startTrace", { enumerable: true, get: function () { return manual_trace_1.startTrace; } });
|
|
25
26
|
Object.defineProperty(exports, "trace", { enumerable: true, get: function () { return manual_trace_1.trace; } });
|
|
26
27
|
const metrics_1 = __importDefault(require("./otel/metrics"));
|
|
28
|
+
// SHIELD: host and process metrics (opt-in).
|
|
29
|
+
const system_metrics_1 = require("./otel/system-metrics");
|
|
30
|
+
// SHIELD: logger bridges (pino, winston, console) to application logs.
|
|
31
|
+
const log_bridges_1 = require("./otel/log-bridges");
|
|
32
|
+
// SHIELD: winston and pino bridged without code changes when application logs are on.
|
|
33
|
+
const log_auto_1 = require("./otel/log-auto");
|
|
27
34
|
const gpu_1 = __importDefault(require("./instrumentation/gpu"));
|
|
28
35
|
const semantic_convention_1 = __importDefault(require("./semantic-convention"));
|
|
29
36
|
const utils_1 = require("./otel/utils");
|
|
@@ -48,8 +55,33 @@ Object.defineProperty(exports, "Custom", { enumerable: true, get: function () {
|
|
|
48
55
|
const pipeline_1 = require("./guard/pipeline");
|
|
49
56
|
Object.defineProperty(exports, "Pipeline", { enumerable: true, get: function () { return pipeline_1.Pipeline; } });
|
|
50
57
|
const destination_1 = require("./destination");
|
|
58
|
+
// Budget check: app budgets enforced through the SDK.
|
|
59
|
+
const budgets_1 = require("./budgets");
|
|
60
|
+
Object.defineProperty(exports, "budgets", { enumerable: true, get: function () { return budgets_1.budgets; } });
|
|
61
|
+
Object.defineProperty(exports, "BudgetClient", { enumerable: true, get: function () { return budgets_1.BudgetClient; } });
|
|
62
|
+
Object.defineProperty(exports, "BudgetExceededError", { enumerable: true, get: function () { return budgets_1.BudgetExceededError; } });
|
|
63
|
+
const auto_1 = require("./budgets/auto");
|
|
64
|
+
// Feature flags: fetched rules, evaluated locally.
|
|
65
|
+
const client_1 = require("./flags/client");
|
|
66
|
+
// Cost per end customer: tag AI calls with the builder's own customer.
|
|
67
|
+
const customer_1 = require("./customer");
|
|
68
|
+
Object.defineProperty(exports, "setCustomer", { enumerable: true, get: function () { return customer_1.setCustomer; } });
|
|
69
|
+
Object.defineProperty(exports, "withCustomer", { enumerable: true, get: function () { return customer_1.withCustomer; } });
|
|
70
|
+
Object.defineProperty(exports, "getCustomer", { enumerable: true, get: function () { return customer_1.getCustomer; } });
|
|
71
|
+
Object.defineProperty(exports, "CustomerSpanProcessor", { enumerable: true, get: function () { return customer_1.CustomerSpanProcessor; } });
|
|
72
|
+
// AI security pack: checks on the app's own AI traffic, kept apart from tracing.
|
|
73
|
+
const ai_security_1 = require("./ai-security");
|
|
74
|
+
Object.defineProperty(exports, "aiSecurity", { enumerable: true, get: function () { return ai_security_1.aiSecurity; } });
|
|
75
|
+
Object.defineProperty(exports, "AiSecurityBlockedError", { enumerable: true, get: function () { return ai_security_1.AiSecurityBlockedError; } });
|
|
76
|
+
const hooks_1 = require("./ai-security/hooks");
|
|
51
77
|
const code_location_1 = require("./otel/code-location");
|
|
52
78
|
const build_info_1 = require("./otel/build-info");
|
|
79
|
+
const feedback_1 = require("./feedback");
|
|
80
|
+
// SHIELD: runtime protection (RASP), opt-in.
|
|
81
|
+
const rasp_1 = require("./rasp");
|
|
82
|
+
const zero_code_1 = require("./zero-code");
|
|
83
|
+
// SHIELD: application logs, opt-in.
|
|
84
|
+
const app_logs_1 = require("./otel/app-logs");
|
|
53
85
|
const base_2 = require("./guard/base");
|
|
54
86
|
Object.defineProperty(exports, "Guard", { enumerable: true, get: function () { return base_2.Guard; } });
|
|
55
87
|
Object.defineProperty(exports, "GuardAction", { enumerable: true, get: function () { return base_2.GuardAction; } });
|
|
@@ -117,6 +149,12 @@ function resolveOptions(options) {
|
|
|
117
149
|
tracer: o.tracer,
|
|
118
150
|
otlpEndpoint,
|
|
119
151
|
otlpHeaders,
|
|
152
|
+
consoleFallback: (0, destination_1.consoleFallbackAllowed)({
|
|
153
|
+
otlpEndpoint,
|
|
154
|
+
shield360Url,
|
|
155
|
+
shield360ApiKey,
|
|
156
|
+
captureStdio: (0, app_logs_1.resolveCaptureLogs)(o.captureLogs) && (o.captureStdio ?? (0, utils_1.parseBoolEnv)('SHIELD360_CAPTURE_STDIO') ?? false),
|
|
157
|
+
}),
|
|
120
158
|
disableBatch,
|
|
121
159
|
captureMessageContent,
|
|
122
160
|
disabledInstrumentors: o.disabledInstrumentors,
|
|
@@ -130,21 +168,36 @@ function resolveOptions(options) {
|
|
|
130
168
|
shield360Url,
|
|
131
169
|
guards: o.guards,
|
|
132
170
|
guardFailOpen: o.guardFailOpen ?? true,
|
|
171
|
+
guardHeartbeat: o.guardHeartbeat,
|
|
133
172
|
protect: (0, mode_1.resolveProtect)(o.protect),
|
|
134
173
|
collectGpuStats,
|
|
135
174
|
captureCodeLocation: (0, code_location_1.resolveCaptureCodeLocation)(o.captureCodeLocation),
|
|
136
175
|
codeRoot: o.codeRoot,
|
|
137
176
|
serviceVersion: o.serviceVersion,
|
|
177
|
+
captureLogs: (0, app_logs_1.resolveCaptureLogs)(o.captureLogs),
|
|
178
|
+
captureStdio: o.captureStdio ?? (0, utils_1.parseBoolEnv)('SHIELD360_CAPTURE_STDIO') ?? false,
|
|
179
|
+
logLevel: (0, app_logs_1.resolveLogLevel)(o.logLevel),
|
|
180
|
+
collectSystemMetrics: (0, system_metrics_1.resolveCollectSystemMetrics)(o.collectSystemMetrics),
|
|
138
181
|
};
|
|
139
182
|
}
|
|
140
183
|
class Shield360 extends base_1.default {
|
|
141
184
|
static init(options) {
|
|
185
|
+
// SHIELD: shield360/register already started Shield360 from the environment: a second init() is a no-op.
|
|
186
|
+
if ((0, zero_code_1.zeroCodeStarted)())
|
|
187
|
+
return (0, zero_code_1.noteSkippedInit)();
|
|
142
188
|
try {
|
|
143
189
|
api_1.diag.setLogger(new api_1.DiagConsoleLogger(), api_1.DiagLogLevel.WARN);
|
|
144
190
|
const resolved = resolveOptions(options);
|
|
145
191
|
this.options = resolved;
|
|
192
|
+
// SHIELD: half a Shield360 destination sends nothing; say so once rather than print every record.
|
|
193
|
+
if (!resolved.otlpEndpoint && Boolean(resolved.shield360Url?.trim()) !== Boolean(resolved.shield360ApiKey?.trim())) {
|
|
194
|
+
console.warn(`Shield360: ${resolved.shield360Url?.trim() ? 'SHIELD360_API_KEY' : 'SHIELD360_URL'} is not set, so telemetry and application logs are not sent.`);
|
|
195
|
+
}
|
|
196
|
+
const buildAttributes = (0, build_info_1.resolveBuildAttributes)({ serviceVersion: resolved.serviceVersion });
|
|
197
|
+
// User feedback names the application and release it was given for.
|
|
198
|
+
(0, feedback_1.configureFeedback)({ app: resolved.applicationName, release: buildAttributes[build_info_1.ATTR_SERVICE_VERSION] });
|
|
146
199
|
this.resource = (0, resources_1.resourceFromAttributes)({
|
|
147
|
-
...
|
|
200
|
+
...buildAttributes,
|
|
148
201
|
[semantic_conventions_1.ATTR_SERVICE_NAME]: resolved.applicationName,
|
|
149
202
|
[semantic_convention_1.default.ATTR_DEPLOYMENT_ENVIRONMENT]: resolved.environment,
|
|
150
203
|
[semantic_conventions_1.ATTR_TELEMETRY_SDK_NAME]: constant_1.SDK_NAME,
|
|
@@ -157,12 +210,45 @@ class Shield360 extends base_1.default {
|
|
|
157
210
|
if (!resolved.disableEvents) {
|
|
158
211
|
events_1.default.setup(setupBase);
|
|
159
212
|
}
|
|
213
|
+
// SHIELD: application logs share the events LoggerProvider, so they go
|
|
214
|
+
// to the same destination as traces. Nothing is sent unless asked for.
|
|
215
|
+
// With them on, console output, winston and pino are bridged too, as
|
|
216
|
+
// the Python SDK attaches its handler to the root logger.
|
|
217
|
+
if (resolved.captureLogs) {
|
|
218
|
+
(0, app_logs_1.enableAppLogs)(events_1.default.ensureProvider(setupBase), resolved.logLevel, {
|
|
219
|
+
captureCodeLocation: resolved.captureCodeLocation,
|
|
220
|
+
codeRoot: resolved.codeRoot,
|
|
221
|
+
});
|
|
222
|
+
if (resolved.captureStdio) {
|
|
223
|
+
// console, pino and winston write to stdout and stderr too: one record per line, not two.
|
|
224
|
+
(0, log_bridges_1.releaseConsole)();
|
|
225
|
+
(0, log_bridges_1.captureStdio)();
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
(0, log_bridges_1.captureConsole)();
|
|
229
|
+
(0, log_auto_1.enableLogBridges)();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
(0, app_logs_1.disableAppLogs)();
|
|
234
|
+
(0, log_bridges_1.releaseConsole)();
|
|
235
|
+
(0, log_bridges_1.releaseStdio)();
|
|
236
|
+
}
|
|
160
237
|
if (!resolved.disableMetrics) {
|
|
161
238
|
const exportIntervalMillis = Number(process.env.OTEL_EXPORTER_OTLP_METRICS_EXPORT_INTERVAL ?? 60000) || 60000;
|
|
162
239
|
const meter = metrics_1.default.setup({
|
|
163
240
|
...setupBase,
|
|
164
241
|
exportIntervalMillis,
|
|
165
242
|
});
|
|
243
|
+
// SHIELD: host and process metrics for the Infrastructure view, when asked for.
|
|
244
|
+
if (resolved.collectSystemMetrics && meter) {
|
|
245
|
+
try {
|
|
246
|
+
(0, system_metrics_1.setupSystemMetrics)(meter);
|
|
247
|
+
}
|
|
248
|
+
catch (e) {
|
|
249
|
+
api_1.diag.error(`Shield360 system metrics setup failed: ${e}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
166
252
|
// GPU metrics: only register gauges when a supported GPU is detected
|
|
167
253
|
// (mirrors Python shield360.init collect_gpu_stats path).
|
|
168
254
|
if (resolved.collectGpuStats && meter) {
|
|
@@ -179,7 +265,46 @@ class Shield360 extends base_1.default {
|
|
|
179
265
|
}
|
|
180
266
|
config_1.default.shield360ApiKey = resolved.shield360ApiKey;
|
|
181
267
|
config_1.default.shield360Url = resolved.shield360Url;
|
|
268
|
+
// Budget check: the automatic pre-call check, when asked for.
|
|
269
|
+
const budgetCheck = options?.budgetCheck ?? ((0, utils_1.parseBoolEnv)('SHIELD360_BUDGET_CHECK') || false);
|
|
270
|
+
if (budgetCheck) {
|
|
271
|
+
const client = (0, budgets_1.configureBudgets)({
|
|
272
|
+
app: resolved.applicationName,
|
|
273
|
+
...(typeof budgetCheck === 'object' && budgetCheck.failClosed !== undefined ? { failClosed: budgetCheck.failClosed } : {}),
|
|
274
|
+
});
|
|
275
|
+
(0, auto_1.setupAutoBudgetCheck)({ client, onWarn: (r) => console.warn(`[shield360] ${r.reason}`) });
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
(0, budgets_1.configureBudgets)({ app: resolved.applicationName });
|
|
279
|
+
}
|
|
280
|
+
// AI security pack: on when asked for; monitors by default.
|
|
281
|
+
const ai = options?.aiSecurity ?? ((0, utils_1.parseBoolEnv)('SHIELD360_AI_SECURITY') || false);
|
|
282
|
+
if (ai) {
|
|
283
|
+
const o = typeof ai === 'object' ? ai : {};
|
|
284
|
+
(0, ai_security_1.configureAiSecurity)({
|
|
285
|
+
url: resolved.shield360Url,
|
|
286
|
+
apiKey: resolved.shield360ApiKey,
|
|
287
|
+
app: resolved.applicationName,
|
|
288
|
+
environment: resolved.environment,
|
|
289
|
+
policy: o.policy,
|
|
290
|
+
configPublicKey: o.configPublicKey,
|
|
291
|
+
allowUnpinnedConfig: o.allowUnpinnedConfig,
|
|
292
|
+
configCacheFile: o.configCacheFile,
|
|
293
|
+
recordAllowed: o.recordAllowed,
|
|
294
|
+
});
|
|
295
|
+
if (o.autoInstrument !== false)
|
|
296
|
+
(0, hooks_1.setupAiSecurity)();
|
|
297
|
+
}
|
|
182
298
|
helpers_1.default.fetchPricingInfo(resolved.pricingJson).then((info) => { config_1.default.pricingInfo = info; }, () => { config_1.default.pricingInfo = {}; });
|
|
299
|
+
// SHIELD: runtime protection (RASP): off unless options.rasp or SHIELD360_RASP turns it on.
|
|
300
|
+
(0, rasp_1.initRasp)(options?.rasp, {
|
|
301
|
+
applicationName: resolved.applicationName,
|
|
302
|
+
environment: resolved.environment,
|
|
303
|
+
url: resolved.shield360Url,
|
|
304
|
+
apiKey: resolved.shield360ApiKey,
|
|
305
|
+
sdkVersion: constant_1.SDK_VERSION,
|
|
306
|
+
otlpEndpoint: resolved.otlpEndpoint,
|
|
307
|
+
});
|
|
183
308
|
if (resolved.guards && resolved.guards.length > 0) {
|
|
184
309
|
(0, integration_1.setupAutoGuards)(resolved.guards, resolved.guardFailOpen, resolved.protect);
|
|
185
310
|
// With a Shield360 URL and API key, what the guards stop is also
|
|
@@ -189,6 +314,9 @@ class Shield360 extends base_1.default {
|
|
|
189
314
|
apiKey: resolved.shield360ApiKey,
|
|
190
315
|
applicationName: resolved.applicationName,
|
|
191
316
|
environment: resolved.environment,
|
|
317
|
+
sdkVersion: constant_1.SDK_VERSION,
|
|
318
|
+
guards: resolved.guards,
|
|
319
|
+
heartbeat: resolved.guardHeartbeat,
|
|
192
320
|
});
|
|
193
321
|
}
|
|
194
322
|
else if (resolved.protect.mode === 'enforced' && resolved.protect.required.length) {
|
|
@@ -247,12 +375,62 @@ Shield360.setAgentVersion = helpers_2.setAgentVersion;
|
|
|
247
375
|
Shield360.resetAgentVersion = helpers_2.resetAgentVersion;
|
|
248
376
|
Shield360.withAgentVersion = helpers_2.runWithAgentVersion;
|
|
249
377
|
Shield360.getAgentVersion = helpers_2.getCurrentAgentVersion;
|
|
378
|
+
/**
|
|
379
|
+
* Send what one of your users thought of an AI response (thumbs 1/-1 or
|
|
380
|
+
* stars 1-5) against its trace. Server side, with the environment's API
|
|
381
|
+
* key. Resolves to whether it was accepted; never throws.
|
|
382
|
+
*/
|
|
383
|
+
Shield360.feedback = feedback_1.feedback;
|
|
384
|
+
/** The active span's trace id, to keep with a response so a later rating can name it. */
|
|
385
|
+
Shield360.getCurrentTraceId = feedback_1.getCurrentTraceId;
|
|
386
|
+
Shield360.getCurrentSpanId = feedback_1.getCurrentSpanId;
|
|
250
387
|
Shield360.startTrace = manual_trace_1.startTrace;
|
|
251
388
|
Shield360.trace = manual_trace_1.trace;
|
|
389
|
+
/** SHIELD: a logger for application logs; a no-op unless captureLogs is on. */
|
|
390
|
+
Shield360.logger = app_logs_1.createLogger;
|
|
391
|
+
/** SHIELD: bridges from pino, winston and console to application logs (no-ops unless captureLogs is on). */
|
|
392
|
+
Shield360.pinoStream = log_bridges_1.pinoStream;
|
|
393
|
+
Shield360.winstonTransport = log_bridges_1.winstonTransport;
|
|
394
|
+
Shield360.captureConsole = log_bridges_1.captureConsole;
|
|
395
|
+
Shield360.releaseConsole = log_bridges_1.releaseConsole;
|
|
396
|
+
Shield360.captureStdio = log_bridges_1.captureStdio;
|
|
397
|
+
Shield360.releaseStdio = log_bridges_1.releaseStdio;
|
|
398
|
+
/** Feature flags: `Shield360.flags.getFlag(key, context, default)` and `isEnabled(key, context)`. */
|
|
399
|
+
Shield360.flags = client_1.flags;
|
|
400
|
+
/** Budget check: Shield360.budgets.check({ model, estimatedCostUsd }) never throws; see ./budgets. */
|
|
401
|
+
Shield360.budgets = budgets_1.budgets;
|
|
402
|
+
Shield360.BudgetExceededError = budgets_1.BudgetExceededError;
|
|
403
|
+
/**
|
|
404
|
+
* Cost per end customer. setCustomer({ tenantId, userId? }) sets a process-wide
|
|
405
|
+
* default (null clears it); withCustomer(customer, fn) scopes one to fn and its
|
|
406
|
+
* async work, winning over the default; getCustomer() returns the one in effect.
|
|
407
|
+
* Invalid ids are dropped silently. The SDK never hashes: Shield360 stores user
|
|
408
|
+
* ids only as a keyed hash, and tenant ids as given unless the organisation opts
|
|
409
|
+
* to hash them. See ./customer.
|
|
410
|
+
*/
|
|
411
|
+
Shield360.setCustomer = customer_1.setCustomer;
|
|
412
|
+
/** SHIELD: the runtime kill switch for RASP (env SHIELD360_RASP=off and the signed config's killSwitch win over it). */
|
|
413
|
+
Shield360.disableRasp = rasp_1.disableRasp;
|
|
414
|
+
Shield360.enableRasp = rasp_1.enableRasp;
|
|
415
|
+
Shield360.withCustomer = customer_1.withCustomer;
|
|
416
|
+
Shield360.getCustomer = customer_1.getCustomer;
|
|
417
|
+
/** AI security pack: Shield360.aiSecurity.scanContext(), scanOutput(), defineTool(), ... See ./ai-security. */
|
|
418
|
+
Shield360.aiSecurity = ai_security_1.aiSecurity;
|
|
419
|
+
Shield360.AiSecurityBlockedError = ai_security_1.AiSecurityBlockedError;
|
|
252
420
|
const shield360 = Shield360;
|
|
253
421
|
shield360.usingAttributes = helpers_2.usingAttributes;
|
|
254
422
|
shield360.injectAdditionalAttributes = helpers_2.injectAdditionalAttributes;
|
|
255
423
|
exports.default = shield360;
|
|
424
|
+
var app_logs_2 = require("./otel/app-logs");
|
|
425
|
+
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return app_logs_2.createLogger; } });
|
|
426
|
+
// Feature flags.
|
|
427
|
+
var flags_1 = require("./flags");
|
|
428
|
+
Object.defineProperty(exports, "FlagsClient", { enumerable: true, get: function () { return flags_1.FlagsClient; } });
|
|
429
|
+
Object.defineProperty(exports, "flags", { enumerable: true, get: function () { return flags_1.flags; } });
|
|
430
|
+
var feedback_2 = require("./feedback");
|
|
431
|
+
Object.defineProperty(exports, "feedback", { enumerable: true, get: function () { return feedback_2.feedback; } });
|
|
432
|
+
Object.defineProperty(exports, "getCurrentTraceId", { enumerable: true, get: function () { return feedback_2.getCurrentTraceId; } });
|
|
433
|
+
Object.defineProperty(exports, "getCurrentSpanId", { enumerable: true, get: function () { return feedback_2.getCurrentSpanId; } });
|
|
256
434
|
// Shield Protect re-exports: enforcement APIs, apart from the tracing ones above.
|
|
257
435
|
var protect_1 = require("./protect");
|
|
258
436
|
Object.defineProperty(exports, "protectTool", { enumerable: true, get: function () { return protect_1.protectTool; } });
|
|
@@ -261,4 +439,27 @@ Object.defineProperty(exports, "protectReadiness", { enumerable: true, get: func
|
|
|
261
439
|
Object.defineProperty(exports, "ProtectDeniedError", { enumerable: true, get: function () { return protect_1.ProtectDeniedError; } });
|
|
262
440
|
Object.defineProperty(exports, "ProtectReadinessError", { enumerable: true, get: function () { return protect_1.ProtectReadinessError; } });
|
|
263
441
|
Object.defineProperty(exports, "ProtectError", { enumerable: true, get: function () { return protect_1.ProtectError; } });
|
|
442
|
+
// Agent passports: verify the agents that call this service (also at 'shield360/agents').
|
|
443
|
+
var agents_1 = require("./agents");
|
|
444
|
+
Object.defineProperty(exports, "agentVerifier", { enumerable: true, get: function () { return agents_1.agentVerifier; } });
|
|
445
|
+
Object.defineProperty(exports, "AGENT_HEADER", { enumerable: true, get: function () { return agents_1.AGENT_HEADER; } });
|
|
446
|
+
Object.defineProperty(exports, "MemoryReplayStore", { enumerable: true, get: function () { return agents_1.MemoryReplayStore; } });
|
|
447
|
+
// SHIELD: runtime protection (RASP): middleware, the block error, the model-output hook point.
|
|
448
|
+
var rasp_2 = require("./rasp");
|
|
449
|
+
Object.defineProperty(exports, "raspExpress", { enumerable: true, get: function () { return rasp_2.raspExpress; } });
|
|
450
|
+
Object.defineProperty(exports, "raspExpressErrorHandler", { enumerable: true, get: function () { return rasp_2.raspExpressErrorHandler; } });
|
|
451
|
+
Object.defineProperty(exports, "raspFastify", { enumerable: true, get: function () { return rasp_2.raspFastify; } });
|
|
452
|
+
Object.defineProperty(exports, "raspKoa", { enumerable: true, get: function () { return rasp_2.raspKoa; } });
|
|
453
|
+
Object.defineProperty(exports, "raspHttp", { enumerable: true, get: function () { return rasp_2.raspHttp; } });
|
|
454
|
+
Object.defineProperty(exports, "withRasp", { enumerable: true, get: function () { return rasp_2.withRasp; } });
|
|
455
|
+
Object.defineProperty(exports, "recordRequestBody", { enumerable: true, get: function () { return rasp_2.recordRequestBody; } });
|
|
456
|
+
Object.defineProperty(exports, "recordModelOutput", { enumerable: true, get: function () { return rasp_2.recordModelOutput; } });
|
|
457
|
+
Object.defineProperty(exports, "recordToolArguments", { enumerable: true, get: function () { return rasp_2.recordToolArguments; } });
|
|
458
|
+
Object.defineProperty(exports, "runInRaspScope", { enumerable: true, get: function () { return rasp_2.runInRaspScope; } });
|
|
459
|
+
Object.defineProperty(exports, "disableRasp", { enumerable: true, get: function () { return rasp_2.disableRasp; } });
|
|
460
|
+
Object.defineProperty(exports, "enableRasp", { enumerable: true, get: function () { return rasp_2.enableRasp; } });
|
|
461
|
+
Object.defineProperty(exports, "raspActive", { enumerable: true, get: function () { return rasp_2.raspActive; } });
|
|
462
|
+
Object.defineProperty(exports, "isRaspBlocked", { enumerable: true, get: function () { return rasp_2.isRaspBlocked; } });
|
|
463
|
+
Object.defineProperty(exports, "RaspBlockedError", { enumerable: true, get: function () { return rasp_2.RaspBlockedError; } });
|
|
464
|
+
Object.defineProperty(exports, "Shield360RaspBlocked", { enumerable: true, get: function () { return rasp_2.Shield360RaspBlocked; } });
|
|
264
465
|
//# sourceMappingURL=index.js.map
|