palaryn 0.1.0
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/LICENSE +21 -0
- package/README.md +716 -0
- package/dist/sdk/typescript/src/client.d.ts +71 -0
- package/dist/sdk/typescript/src/client.d.ts.map +1 -0
- package/dist/sdk/typescript/src/client.js +176 -0
- package/dist/sdk/typescript/src/client.js.map +1 -0
- package/dist/sdk/typescript/src/errors.d.ts +50 -0
- package/dist/sdk/typescript/src/errors.d.ts.map +1 -0
- package/dist/sdk/typescript/src/errors.js +103 -0
- package/dist/sdk/typescript/src/errors.js.map +1 -0
- package/dist/sdk/typescript/src/index.d.ts +4 -0
- package/dist/sdk/typescript/src/index.d.ts.map +1 -0
- package/dist/sdk/typescript/src/index.js +15 -0
- package/dist/sdk/typescript/src/index.js.map +1 -0
- package/dist/sdk/typescript/src/types.d.ts +101 -0
- package/dist/sdk/typescript/src/types.d.ts.map +1 -0
- package/dist/sdk/typescript/src/types.js +6 -0
- package/dist/sdk/typescript/src/types.js.map +1 -0
- package/dist/src/admin/index.d.ts +2 -0
- package/dist/src/admin/index.d.ts.map +1 -0
- package/dist/src/admin/index.js +6 -0
- package/dist/src/admin/index.js.map +1 -0
- package/dist/src/admin/routes.d.ts +5 -0
- package/dist/src/admin/routes.d.ts.map +1 -0
- package/dist/src/admin/routes.js +471 -0
- package/dist/src/admin/routes.js.map +1 -0
- package/dist/src/admin/templates.d.ts +51 -0
- package/dist/src/admin/templates.d.ts.map +1 -0
- package/dist/src/admin/templates.js +500 -0
- package/dist/src/admin/templates.js.map +1 -0
- package/dist/src/anomaly/detector.d.ts +141 -0
- package/dist/src/anomaly/detector.d.ts.map +1 -0
- package/dist/src/anomaly/detector.js +554 -0
- package/dist/src/anomaly/detector.js.map +1 -0
- package/dist/src/anomaly/index.d.ts +2 -0
- package/dist/src/anomaly/index.d.ts.map +1 -0
- package/dist/src/anomaly/index.js +7 -0
- package/dist/src/anomaly/index.js.map +1 -0
- package/dist/src/approval/manager.d.ts +147 -0
- package/dist/src/approval/manager.d.ts.map +1 -0
- package/dist/src/approval/manager.js +511 -0
- package/dist/src/approval/manager.js.map +1 -0
- package/dist/src/approval/webhook.d.ts +36 -0
- package/dist/src/approval/webhook.d.ts.map +1 -0
- package/dist/src/approval/webhook.js +135 -0
- package/dist/src/approval/webhook.js.map +1 -0
- package/dist/src/audit/logger.d.ts +70 -0
- package/dist/src/audit/logger.d.ts.map +1 -0
- package/dist/src/audit/logger.js +440 -0
- package/dist/src/audit/logger.js.map +1 -0
- package/dist/src/auth/index.d.ts +6 -0
- package/dist/src/auth/index.d.ts.map +1 -0
- package/dist/src/auth/index.js +22 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/auth/password.d.ts +3 -0
- package/dist/src/auth/password.d.ts.map +1 -0
- package/dist/src/auth/password.js +25 -0
- package/dist/src/auth/password.js.map +1 -0
- package/dist/src/auth/pkce.d.ts +13 -0
- package/dist/src/auth/pkce.d.ts.map +1 -0
- package/dist/src/auth/pkce.js +58 -0
- package/dist/src/auth/pkce.js.map +1 -0
- package/dist/src/auth/providers.d.ts +28 -0
- package/dist/src/auth/providers.d.ts.map +1 -0
- package/dist/src/auth/providers.js +198 -0
- package/dist/src/auth/providers.js.map +1 -0
- package/dist/src/auth/routes.d.ts +14 -0
- package/dist/src/auth/routes.d.ts.map +1 -0
- package/dist/src/auth/routes.js +431 -0
- package/dist/src/auth/routes.js.map +1 -0
- package/dist/src/auth/session.d.ts +24 -0
- package/dist/src/auth/session.d.ts.map +1 -0
- package/dist/src/auth/session.js +105 -0
- package/dist/src/auth/session.js.map +1 -0
- package/dist/src/billing/index.d.ts +7 -0
- package/dist/src/billing/index.d.ts.map +1 -0
- package/dist/src/billing/index.js +14 -0
- package/dist/src/billing/index.js.map +1 -0
- package/dist/src/billing/plan-enforcer.d.ts +44 -0
- package/dist/src/billing/plan-enforcer.d.ts.map +1 -0
- package/dist/src/billing/plan-enforcer.js +110 -0
- package/dist/src/billing/plan-enforcer.js.map +1 -0
- package/dist/src/billing/routes.d.ts +15 -0
- package/dist/src/billing/routes.d.ts.map +1 -0
- package/dist/src/billing/routes.js +193 -0
- package/dist/src/billing/routes.js.map +1 -0
- package/dist/src/billing/stripe-client.d.ts +14 -0
- package/dist/src/billing/stripe-client.d.ts.map +1 -0
- package/dist/src/billing/stripe-client.js +51 -0
- package/dist/src/billing/stripe-client.js.map +1 -0
- package/dist/src/billing/webhook-handler.d.ts +19 -0
- package/dist/src/billing/webhook-handler.d.ts.map +1 -0
- package/dist/src/billing/webhook-handler.js +169 -0
- package/dist/src/billing/webhook-handler.js.map +1 -0
- package/dist/src/billing/webhook-routes.d.ts +5 -0
- package/dist/src/billing/webhook-routes.d.ts.map +1 -0
- package/dist/src/billing/webhook-routes.js +30 -0
- package/dist/src/billing/webhook-routes.js.map +1 -0
- package/dist/src/budget/manager.d.ts +95 -0
- package/dist/src/budget/manager.d.ts.map +1 -0
- package/dist/src/budget/manager.js +547 -0
- package/dist/src/budget/manager.js.map +1 -0
- package/dist/src/budget/usage-extractor.d.ts +38 -0
- package/dist/src/budget/usage-extractor.d.ts.map +1 -0
- package/dist/src/budget/usage-extractor.js +165 -0
- package/dist/src/budget/usage-extractor.js.map +1 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +115 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/config/defaults.d.ts +3 -0
- package/dist/src/config/defaults.d.ts.map +1 -0
- package/dist/src/config/defaults.js +243 -0
- package/dist/src/config/defaults.js.map +1 -0
- package/dist/src/config/validate.d.ts +15 -0
- package/dist/src/config/validate.d.ts.map +1 -0
- package/dist/src/config/validate.js +105 -0
- package/dist/src/config/validate.js.map +1 -0
- package/dist/src/dlp/composite-scanner.d.ts +47 -0
- package/dist/src/dlp/composite-scanner.d.ts.map +1 -0
- package/dist/src/dlp/composite-scanner.js +186 -0
- package/dist/src/dlp/composite-scanner.js.map +1 -0
- package/dist/src/dlp/index.d.ts +10 -0
- package/dist/src/dlp/index.d.ts.map +1 -0
- package/dist/src/dlp/index.js +26 -0
- package/dist/src/dlp/index.js.map +1 -0
- package/dist/src/dlp/interfaces.d.ts +33 -0
- package/dist/src/dlp/interfaces.d.ts.map +1 -0
- package/dist/src/dlp/interfaces.js +3 -0
- package/dist/src/dlp/interfaces.js.map +1 -0
- package/dist/src/dlp/patterns.d.ts +9 -0
- package/dist/src/dlp/patterns.d.ts.map +1 -0
- package/dist/src/dlp/patterns.js +25 -0
- package/dist/src/dlp/patterns.js.map +1 -0
- package/dist/src/dlp/prompt-injection-backend.d.ts +68 -0
- package/dist/src/dlp/prompt-injection-backend.d.ts.map +1 -0
- package/dist/src/dlp/prompt-injection-backend.js +148 -0
- package/dist/src/dlp/prompt-injection-backend.js.map +1 -0
- package/dist/src/dlp/prompt-injection-patterns.d.ts +32 -0
- package/dist/src/dlp/prompt-injection-patterns.d.ts.map +1 -0
- package/dist/src/dlp/prompt-injection-patterns.js +290 -0
- package/dist/src/dlp/prompt-injection-patterns.js.map +1 -0
- package/dist/src/dlp/regex-backend.d.ts +32 -0
- package/dist/src/dlp/regex-backend.d.ts.map +1 -0
- package/dist/src/dlp/regex-backend.js +153 -0
- package/dist/src/dlp/regex-backend.js.map +1 -0
- package/dist/src/dlp/scanner.d.ts +122 -0
- package/dist/src/dlp/scanner.d.ts.map +1 -0
- package/dist/src/dlp/scanner.js +444 -0
- package/dist/src/dlp/scanner.js.map +1 -0
- package/dist/src/dlp/text-normalizer.d.ts +41 -0
- package/dist/src/dlp/text-normalizer.d.ts.map +1 -0
- package/dist/src/dlp/text-normalizer.js +203 -0
- package/dist/src/dlp/text-normalizer.js.map +1 -0
- package/dist/src/dlp/trufflehog-backend.d.ts +64 -0
- package/dist/src/dlp/trufflehog-backend.d.ts.map +1 -0
- package/dist/src/dlp/trufflehog-backend.js +151 -0
- package/dist/src/dlp/trufflehog-backend.js.map +1 -0
- package/dist/src/executor/http-executor.d.ts +25 -0
- package/dist/src/executor/http-executor.d.ts.map +1 -0
- package/dist/src/executor/http-executor.js +333 -0
- package/dist/src/executor/http-executor.js.map +1 -0
- package/dist/src/executor/index.d.ts +6 -0
- package/dist/src/executor/index.d.ts.map +1 -0
- package/dist/src/executor/index.js +12 -0
- package/dist/src/executor/index.js.map +1 -0
- package/dist/src/executor/interfaces.d.ts +11 -0
- package/dist/src/executor/interfaces.d.ts.map +1 -0
- package/dist/src/executor/interfaces.js +3 -0
- package/dist/src/executor/interfaces.js.map +1 -0
- package/dist/src/executor/noop-executor.d.ts +13 -0
- package/dist/src/executor/noop-executor.d.ts.map +1 -0
- package/dist/src/executor/noop-executor.js +21 -0
- package/dist/src/executor/noop-executor.js.map +1 -0
- package/dist/src/executor/registry.d.ts +30 -0
- package/dist/src/executor/registry.d.ts.map +1 -0
- package/dist/src/executor/registry.js +62 -0
- package/dist/src/executor/registry.js.map +1 -0
- package/dist/src/executor/slack-executor.d.ts +24 -0
- package/dist/src/executor/slack-executor.d.ts.map +1 -0
- package/dist/src/executor/slack-executor.js +147 -0
- package/dist/src/executor/slack-executor.js.map +1 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +74 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/auth-verifier.d.ts +23 -0
- package/dist/src/mcp/auth-verifier.d.ts.map +1 -0
- package/dist/src/mcp/auth-verifier.js +162 -0
- package/dist/src/mcp/auth-verifier.js.map +1 -0
- package/dist/src/mcp/bridge.d.ts +132 -0
- package/dist/src/mcp/bridge.d.ts.map +1 -0
- package/dist/src/mcp/bridge.js +734 -0
- package/dist/src/mcp/bridge.js.map +1 -0
- package/dist/src/mcp/http-transport.d.ts +32 -0
- package/dist/src/mcp/http-transport.d.ts.map +1 -0
- package/dist/src/mcp/http-transport.js +538 -0
- package/dist/src/mcp/http-transport.js.map +1 -0
- package/dist/src/mcp/index.d.ts +10 -0
- package/dist/src/mcp/index.d.ts.map +1 -0
- package/dist/src/mcp/index.js +17 -0
- package/dist/src/mcp/index.js.map +1 -0
- package/dist/src/mcp/oauth-pages.d.ts +23 -0
- package/dist/src/mcp/oauth-pages.d.ts.map +1 -0
- package/dist/src/mcp/oauth-pages.js +121 -0
- package/dist/src/mcp/oauth-pages.js.map +1 -0
- package/dist/src/mcp/oauth-postgres-stores.d.ts +55 -0
- package/dist/src/mcp/oauth-postgres-stores.d.ts.map +1 -0
- package/dist/src/mcp/oauth-postgres-stores.js +226 -0
- package/dist/src/mcp/oauth-postgres-stores.js.map +1 -0
- package/dist/src/mcp/oauth-provider.d.ts +95 -0
- package/dist/src/mcp/oauth-provider.d.ts.map +1 -0
- package/dist/src/mcp/oauth-provider.js +360 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-stores.d.ts +62 -0
- package/dist/src/mcp/oauth-stores.d.ts.map +1 -0
- package/dist/src/mcp/oauth-stores.js +154 -0
- package/dist/src/mcp/oauth-stores.js.map +1 -0
- package/dist/src/mcp/server.d.ts +18 -0
- package/dist/src/mcp/server.d.ts.map +1 -0
- package/dist/src/mcp/server.js +51 -0
- package/dist/src/mcp/server.js.map +1 -0
- package/dist/src/metrics/collector.d.ts +106 -0
- package/dist/src/metrics/collector.d.ts.map +1 -0
- package/dist/src/metrics/collector.js +311 -0
- package/dist/src/metrics/collector.js.map +1 -0
- package/dist/src/metrics/index.d.ts +2 -0
- package/dist/src/metrics/index.d.ts.map +1 -0
- package/dist/src/metrics/index.js +6 -0
- package/dist/src/metrics/index.js.map +1 -0
- package/dist/src/middleware/auth.d.ts +77 -0
- package/dist/src/middleware/auth.d.ts.map +1 -0
- package/dist/src/middleware/auth.js +720 -0
- package/dist/src/middleware/auth.js.map +1 -0
- package/dist/src/middleware/session.d.ts +18 -0
- package/dist/src/middleware/session.d.ts.map +1 -0
- package/dist/src/middleware/session.js +67 -0
- package/dist/src/middleware/session.js.map +1 -0
- package/dist/src/middleware/validate.d.ts +3 -0
- package/dist/src/middleware/validate.d.ts.map +1 -0
- package/dist/src/middleware/validate.js +85 -0
- package/dist/src/middleware/validate.js.map +1 -0
- package/dist/src/policy/engine.d.ts +107 -0
- package/dist/src/policy/engine.d.ts.map +1 -0
- package/dist/src/policy/engine.js +646 -0
- package/dist/src/policy/engine.js.map +1 -0
- package/dist/src/policy/index.d.ts +3 -0
- package/dist/src/policy/index.d.ts.map +1 -0
- package/dist/src/policy/index.js +8 -0
- package/dist/src/policy/index.js.map +1 -0
- package/dist/src/policy/opa-engine.d.ts +176 -0
- package/dist/src/policy/opa-engine.d.ts.map +1 -0
- package/dist/src/policy/opa-engine.js +790 -0
- package/dist/src/policy/opa-engine.js.map +1 -0
- package/dist/src/proxy/forward-proxy.d.ts +30 -0
- package/dist/src/proxy/forward-proxy.d.ts.map +1 -0
- package/dist/src/proxy/forward-proxy.js +580 -0
- package/dist/src/proxy/forward-proxy.js.map +1 -0
- package/dist/src/proxy/index.d.ts +2 -0
- package/dist/src/proxy/index.d.ts.map +1 -0
- package/dist/src/proxy/index.js +8 -0
- package/dist/src/proxy/index.js.map +1 -0
- package/dist/src/ratelimit/limiter.d.ts +45 -0
- package/dist/src/ratelimit/limiter.d.ts.map +1 -0
- package/dist/src/ratelimit/limiter.js +158 -0
- package/dist/src/ratelimit/limiter.js.map +1 -0
- package/dist/src/replay/engine.d.ts +40 -0
- package/dist/src/replay/engine.d.ts.map +1 -0
- package/dist/src/replay/engine.js +106 -0
- package/dist/src/replay/engine.js.map +1 -0
- package/dist/src/replay/index.d.ts +2 -0
- package/dist/src/replay/index.d.ts.map +1 -0
- package/dist/src/replay/index.js +6 -0
- package/dist/src/replay/index.js.map +1 -0
- package/dist/src/saas/index.d.ts +2 -0
- package/dist/src/saas/index.d.ts.map +1 -0
- package/dist/src/saas/index.js +18 -0
- package/dist/src/saas/index.js.map +1 -0
- package/dist/src/saas/routes.d.ts +18 -0
- package/dist/src/saas/routes.d.ts.map +1 -0
- package/dist/src/saas/routes.js +1566 -0
- package/dist/src/saas/routes.js.map +1 -0
- package/dist/src/server/app.d.ts +44 -0
- package/dist/src/server/app.d.ts.map +1 -0
- package/dist/src/server/app.js +854 -0
- package/dist/src/server/app.js.map +1 -0
- package/dist/src/server/errors.d.ts +32 -0
- package/dist/src/server/errors.d.ts.map +1 -0
- package/dist/src/server/errors.js +39 -0
- package/dist/src/server/errors.js.map +1 -0
- package/dist/src/server/gateway.d.ts +165 -0
- package/dist/src/server/gateway.d.ts.map +1 -0
- package/dist/src/server/gateway.js +964 -0
- package/dist/src/server/gateway.js.map +1 -0
- package/dist/src/server/index.d.ts +2 -0
- package/dist/src/server/index.d.ts.map +1 -0
- package/dist/src/server/index.js +295 -0
- package/dist/src/server/index.js.map +1 -0
- package/dist/src/server/logger.d.ts +33 -0
- package/dist/src/server/logger.d.ts.map +1 -0
- package/dist/src/server/logger.js +230 -0
- package/dist/src/server/logger.js.map +1 -0
- package/dist/src/server/stream-proxy.d.ts +32 -0
- package/dist/src/server/stream-proxy.d.ts.map +1 -0
- package/dist/src/server/stream-proxy.js +184 -0
- package/dist/src/server/stream-proxy.js.map +1 -0
- package/dist/src/storage/file-persistence.d.ts +48 -0
- package/dist/src/storage/file-persistence.d.ts.map +1 -0
- package/dist/src/storage/file-persistence.js +280 -0
- package/dist/src/storage/file-persistence.js.map +1 -0
- package/dist/src/storage/index.d.ts +5 -0
- package/dist/src/storage/index.d.ts.map +1 -0
- package/dist/src/storage/index.js +21 -0
- package/dist/src/storage/index.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +237 -0
- package/dist/src/storage/interfaces.d.ts.map +1 -0
- package/dist/src/storage/interfaces.js +3 -0
- package/dist/src/storage/interfaces.js.map +1 -0
- package/dist/src/storage/memory.d.ts +162 -0
- package/dist/src/storage/memory.d.ts.map +1 -0
- package/dist/src/storage/memory.js +603 -0
- package/dist/src/storage/memory.js.map +1 -0
- package/dist/src/storage/postgres.d.ts +267 -0
- package/dist/src/storage/postgres.d.ts.map +1 -0
- package/dist/src/storage/postgres.js +1555 -0
- package/dist/src/storage/postgres.js.map +1 -0
- package/dist/src/storage/redis.d.ts +202 -0
- package/dist/src/storage/redis.d.ts.map +1 -0
- package/dist/src/storage/redis.js +629 -0
- package/dist/src/storage/redis.js.map +1 -0
- package/dist/src/tracing/index.d.ts +2 -0
- package/dist/src/tracing/index.d.ts.map +1 -0
- package/dist/src/tracing/index.js +6 -0
- package/dist/src/tracing/index.js.map +1 -0
- package/dist/src/tracing/provider.d.ts +43 -0
- package/dist/src/tracing/provider.d.ts.map +1 -0
- package/dist/src/tracing/provider.js +74 -0
- package/dist/src/tracing/provider.js.map +1 -0
- package/dist/src/trust/calculator.d.ts +54 -0
- package/dist/src/trust/calculator.d.ts.map +1 -0
- package/dist/src/trust/calculator.js +102 -0
- package/dist/src/trust/calculator.js.map +1 -0
- package/dist/src/trust/index.d.ts +2 -0
- package/dist/src/trust/index.d.ts.map +1 -0
- package/dist/src/trust/index.js +7 -0
- package/dist/src/trust/index.js.map +1 -0
- package/dist/src/types/budget.d.ts +30 -0
- package/dist/src/types/budget.d.ts.map +1 -0
- package/dist/src/types/budget.js +3 -0
- package/dist/src/types/budget.js.map +1 -0
- package/dist/src/types/config.d.ts +176 -0
- package/dist/src/types/config.d.ts.map +1 -0
- package/dist/src/types/config.js +3 -0
- package/dist/src/types/config.js.map +1 -0
- package/dist/src/types/events.d.ts +24 -0
- package/dist/src/types/events.d.ts.map +1 -0
- package/dist/src/types/events.js +3 -0
- package/dist/src/types/events.js.map +1 -0
- package/dist/src/types/index.d.ts +8 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +24 -0
- package/dist/src/types/index.js.map +1 -0
- package/dist/src/types/policy.d.ts +60 -0
- package/dist/src/types/policy.d.ts.map +1 -0
- package/dist/src/types/policy.js +3 -0
- package/dist/src/types/policy.js.map +1 -0
- package/dist/src/types/stripe-config.d.ts +12 -0
- package/dist/src/types/stripe-config.d.ts.map +1 -0
- package/dist/src/types/stripe-config.js +3 -0
- package/dist/src/types/stripe-config.js.map +1 -0
- package/dist/src/types/subscription.d.ts +24 -0
- package/dist/src/types/subscription.d.ts.map +1 -0
- package/dist/src/types/subscription.js +38 -0
- package/dist/src/types/subscription.js.map +1 -0
- package/dist/src/types/tool-call.d.ts +42 -0
- package/dist/src/types/tool-call.d.ts.map +1 -0
- package/dist/src/types/tool-call.js +3 -0
- package/dist/src/types/tool-call.js.map +1 -0
- package/dist/src/types/tool-result.d.ts +58 -0
- package/dist/src/types/tool-result.d.ts.map +1 -0
- package/dist/src/types/tool-result.js +3 -0
- package/dist/src/types/tool-result.js.map +1 -0
- package/dist/src/types/user.d.ts +101 -0
- package/dist/src/types/user.d.ts.map +1 -0
- package/dist/src/types/user.js +6 -0
- package/dist/src/types/user.js.map +1 -0
- package/dist/tests/integration/api.test.d.ts +2 -0
- package/dist/tests/integration/api.test.d.ts.map +1 -0
- package/dist/tests/integration/api.test.js +1199 -0
- package/dist/tests/integration/api.test.js.map +1 -0
- package/dist/tests/integration/proxy.test.d.ts +2 -0
- package/dist/tests/integration/proxy.test.d.ts.map +1 -0
- package/dist/tests/integration/proxy.test.js +251 -0
- package/dist/tests/integration/proxy.test.js.map +1 -0
- package/dist/tests/integration/storage.test.d.ts +16 -0
- package/dist/tests/integration/storage.test.d.ts.map +1 -0
- package/dist/tests/integration/storage.test.js +826 -0
- package/dist/tests/integration/storage.test.js.map +1 -0
- package/dist/tests/unit/admin.test.d.ts +2 -0
- package/dist/tests/unit/admin.test.d.ts.map +1 -0
- package/dist/tests/unit/admin.test.js +698 -0
- package/dist/tests/unit/admin.test.js.map +1 -0
- package/dist/tests/unit/anomaly-detector.test.d.ts +2 -0
- package/dist/tests/unit/anomaly-detector.test.d.ts.map +1 -0
- package/dist/tests/unit/anomaly-detector.test.js +903 -0
- package/dist/tests/unit/anomaly-detector.test.js.map +1 -0
- package/dist/tests/unit/approval-manager.test.d.ts +2 -0
- package/dist/tests/unit/approval-manager.test.d.ts.map +1 -0
- package/dist/tests/unit/approval-manager.test.js +528 -0
- package/dist/tests/unit/approval-manager.test.js.map +1 -0
- package/dist/tests/unit/approval-webhook.test.d.ts +2 -0
- package/dist/tests/unit/approval-webhook.test.d.ts.map +1 -0
- package/dist/tests/unit/approval-webhook.test.js +355 -0
- package/dist/tests/unit/approval-webhook.test.js.map +1 -0
- package/dist/tests/unit/audit-logger.test.d.ts +2 -0
- package/dist/tests/unit/audit-logger.test.d.ts.map +1 -0
- package/dist/tests/unit/audit-logger.test.js +635 -0
- package/dist/tests/unit/audit-logger.test.js.map +1 -0
- package/dist/tests/unit/auth-routes.test.d.ts +2 -0
- package/dist/tests/unit/auth-routes.test.d.ts.map +1 -0
- package/dist/tests/unit/auth-routes.test.js +281 -0
- package/dist/tests/unit/auth-routes.test.js.map +1 -0
- package/dist/tests/unit/auth.test.d.ts +2 -0
- package/dist/tests/unit/auth.test.d.ts.map +1 -0
- package/dist/tests/unit/auth.test.js +1382 -0
- package/dist/tests/unit/auth.test.js.map +1 -0
- package/dist/tests/unit/billing.test.d.ts +2 -0
- package/dist/tests/unit/billing.test.d.ts.map +1 -0
- package/dist/tests/unit/billing.test.js +579 -0
- package/dist/tests/unit/billing.test.js.map +1 -0
- package/dist/tests/unit/budget-manager.test.d.ts +2 -0
- package/dist/tests/unit/budget-manager.test.d.ts.map +1 -0
- package/dist/tests/unit/budget-manager.test.js +778 -0
- package/dist/tests/unit/budget-manager.test.js.map +1 -0
- package/dist/tests/unit/budget-race.test.d.ts +2 -0
- package/dist/tests/unit/budget-race.test.d.ts.map +1 -0
- package/dist/tests/unit/budget-race.test.js +58 -0
- package/dist/tests/unit/budget-race.test.js.map +1 -0
- package/dist/tests/unit/cli.test.d.ts +2 -0
- package/dist/tests/unit/cli.test.d.ts.map +1 -0
- package/dist/tests/unit/cli.test.js +93 -0
- package/dist/tests/unit/cli.test.js.map +1 -0
- package/dist/tests/unit/concurrency.test.d.ts +2 -0
- package/dist/tests/unit/concurrency.test.d.ts.map +1 -0
- package/dist/tests/unit/concurrency.test.js +1270 -0
- package/dist/tests/unit/concurrency.test.js.map +1 -0
- package/dist/tests/unit/config-validate.test.d.ts +2 -0
- package/dist/tests/unit/config-validate.test.d.ts.map +1 -0
- package/dist/tests/unit/config-validate.test.js +230 -0
- package/dist/tests/unit/config-validate.test.js.map +1 -0
- package/dist/tests/unit/defaults.test.d.ts +2 -0
- package/dist/tests/unit/defaults.test.d.ts.map +1 -0
- package/dist/tests/unit/defaults.test.js +364 -0
- package/dist/tests/unit/defaults.test.js.map +1 -0
- package/dist/tests/unit/dlp-backends.test.d.ts +2 -0
- package/dist/tests/unit/dlp-backends.test.d.ts.map +1 -0
- package/dist/tests/unit/dlp-backends.test.js +563 -0
- package/dist/tests/unit/dlp-backends.test.js.map +1 -0
- package/dist/tests/unit/dlp-scanner.test.d.ts +2 -0
- package/dist/tests/unit/dlp-scanner.test.d.ts.map +1 -0
- package/dist/tests/unit/dlp-scanner.test.js +739 -0
- package/dist/tests/unit/dlp-scanner.test.js.map +1 -0
- package/dist/tests/unit/error-responses.test.d.ts +2 -0
- package/dist/tests/unit/error-responses.test.d.ts.map +1 -0
- package/dist/tests/unit/error-responses.test.js +101 -0
- package/dist/tests/unit/error-responses.test.js.map +1 -0
- package/dist/tests/unit/executor-registry.test.d.ts +2 -0
- package/dist/tests/unit/executor-registry.test.d.ts.map +1 -0
- package/dist/tests/unit/executor-registry.test.js +390 -0
- package/dist/tests/unit/executor-registry.test.js.map +1 -0
- package/dist/tests/unit/forward-proxy.test.d.ts +2 -0
- package/dist/tests/unit/forward-proxy.test.d.ts.map +1 -0
- package/dist/tests/unit/forward-proxy.test.js +621 -0
- package/dist/tests/unit/forward-proxy.test.js.map +1 -0
- package/dist/tests/unit/gateway-features.test.d.ts +2 -0
- package/dist/tests/unit/gateway-features.test.d.ts.map +1 -0
- package/dist/tests/unit/gateway-features.test.js +753 -0
- package/dist/tests/unit/gateway-features.test.js.map +1 -0
- package/dist/tests/unit/http-executor.test.d.ts +2 -0
- package/dist/tests/unit/http-executor.test.d.ts.map +1 -0
- package/dist/tests/unit/http-executor.test.js +310 -0
- package/dist/tests/unit/http-executor.test.js.map +1 -0
- package/dist/tests/unit/mcp-bridge.test.d.ts +2 -0
- package/dist/tests/unit/mcp-bridge.test.d.ts.map +1 -0
- package/dist/tests/unit/mcp-bridge.test.js +1136 -0
- package/dist/tests/unit/mcp-bridge.test.js.map +1 -0
- package/dist/tests/unit/mcp-http-transport.test.d.ts +2 -0
- package/dist/tests/unit/mcp-http-transport.test.d.ts.map +1 -0
- package/dist/tests/unit/mcp-http-transport.test.js +899 -0
- package/dist/tests/unit/mcp-http-transport.test.js.map +1 -0
- package/dist/tests/unit/mcp-oauth.test.d.ts +2 -0
- package/dist/tests/unit/mcp-oauth.test.d.ts.map +1 -0
- package/dist/tests/unit/mcp-oauth.test.js +759 -0
- package/dist/tests/unit/mcp-oauth.test.js.map +1 -0
- package/dist/tests/unit/mcp-server.test.d.ts +15 -0
- package/dist/tests/unit/mcp-server.test.d.ts.map +1 -0
- package/dist/tests/unit/mcp-server.test.js +158 -0
- package/dist/tests/unit/mcp-server.test.js.map +1 -0
- package/dist/tests/unit/metrics.test.d.ts +2 -0
- package/dist/tests/unit/metrics.test.d.ts.map +1 -0
- package/dist/tests/unit/metrics.test.js +208 -0
- package/dist/tests/unit/metrics.test.js.map +1 -0
- package/dist/tests/unit/oauth.test.d.ts +2 -0
- package/dist/tests/unit/oauth.test.d.ts.map +1 -0
- package/dist/tests/unit/oauth.test.js +281 -0
- package/dist/tests/unit/oauth.test.js.map +1 -0
- package/dist/tests/unit/opa-circuit-breaker.test.d.ts +2 -0
- package/dist/tests/unit/opa-circuit-breaker.test.d.ts.map +1 -0
- package/dist/tests/unit/opa-circuit-breaker.test.js +297 -0
- package/dist/tests/unit/opa-circuit-breaker.test.js.map +1 -0
- package/dist/tests/unit/opa-engine.test.d.ts +2 -0
- package/dist/tests/unit/opa-engine.test.d.ts.map +1 -0
- package/dist/tests/unit/opa-engine.test.js +1813 -0
- package/dist/tests/unit/opa-engine.test.js.map +1 -0
- package/dist/tests/unit/pipeline-timing.test.d.ts +2 -0
- package/dist/tests/unit/pipeline-timing.test.d.ts.map +1 -0
- package/dist/tests/unit/pipeline-timing.test.js +528 -0
- package/dist/tests/unit/pipeline-timing.test.js.map +1 -0
- package/dist/tests/unit/policy-engine.test.d.ts +2 -0
- package/dist/tests/unit/policy-engine.test.d.ts.map +1 -0
- package/dist/tests/unit/policy-engine.test.js +1345 -0
- package/dist/tests/unit/policy-engine.test.js.map +1 -0
- package/dist/tests/unit/policy-store.test.d.ts +2 -0
- package/dist/tests/unit/policy-store.test.d.ts.map +1 -0
- package/dist/tests/unit/policy-store.test.js +60 -0
- package/dist/tests/unit/policy-store.test.js.map +1 -0
- package/dist/tests/unit/postgres-storage.test.d.ts +2 -0
- package/dist/tests/unit/postgres-storage.test.d.ts.map +1 -0
- package/dist/tests/unit/postgres-storage.test.js +614 -0
- package/dist/tests/unit/postgres-storage.test.js.map +1 -0
- package/dist/tests/unit/prompt-injection-backend.test.d.ts +2 -0
- package/dist/tests/unit/prompt-injection-backend.test.d.ts.map +1 -0
- package/dist/tests/unit/prompt-injection-backend.test.js +621 -0
- package/dist/tests/unit/prompt-injection-backend.test.js.map +1 -0
- package/dist/tests/unit/proxy-hardening.test.d.ts +2 -0
- package/dist/tests/unit/proxy-hardening.test.d.ts.map +1 -0
- package/dist/tests/unit/proxy-hardening.test.js +166 -0
- package/dist/tests/unit/proxy-hardening.test.js.map +1 -0
- package/dist/tests/unit/rate-limiter.test.d.ts +2 -0
- package/dist/tests/unit/rate-limiter.test.d.ts.map +1 -0
- package/dist/tests/unit/rate-limiter.test.js +443 -0
- package/dist/tests/unit/rate-limiter.test.js.map +1 -0
- package/dist/tests/unit/redis-storage.test.d.ts +2 -0
- package/dist/tests/unit/redis-storage.test.d.ts.map +1 -0
- package/dist/tests/unit/redis-storage.test.js +766 -0
- package/dist/tests/unit/redis-storage.test.js.map +1 -0
- package/dist/tests/unit/replay-engine.test.d.ts +2 -0
- package/dist/tests/unit/replay-engine.test.d.ts.map +1 -0
- package/dist/tests/unit/replay-engine.test.js +371 -0
- package/dist/tests/unit/replay-engine.test.js.map +1 -0
- package/dist/tests/unit/saas-routes.test.d.ts +2 -0
- package/dist/tests/unit/saas-routes.test.d.ts.map +1 -0
- package/dist/tests/unit/saas-routes.test.js +1399 -0
- package/dist/tests/unit/saas-routes.test.js.map +1 -0
- package/dist/tests/unit/session.test.d.ts +2 -0
- package/dist/tests/unit/session.test.d.ts.map +1 -0
- package/dist/tests/unit/session.test.js +532 -0
- package/dist/tests/unit/session.test.js.map +1 -0
- package/dist/tests/unit/slack-executor.test.d.ts +2 -0
- package/dist/tests/unit/slack-executor.test.d.ts.map +1 -0
- package/dist/tests/unit/slack-executor.test.js +209 -0
- package/dist/tests/unit/slack-executor.test.js.map +1 -0
- package/dist/tests/unit/storage-hardening.test.d.ts +2 -0
- package/dist/tests/unit/storage-hardening.test.d.ts.map +1 -0
- package/dist/tests/unit/storage-hardening.test.js +165 -0
- package/dist/tests/unit/storage-hardening.test.js.map +1 -0
- package/dist/tests/unit/storage.test.d.ts +2 -0
- package/dist/tests/unit/storage.test.d.ts.map +1 -0
- package/dist/tests/unit/storage.test.js +698 -0
- package/dist/tests/unit/storage.test.js.map +1 -0
- package/dist/tests/unit/text-normalizer.test.d.ts +2 -0
- package/dist/tests/unit/text-normalizer.test.d.ts.map +1 -0
- package/dist/tests/unit/text-normalizer.test.js +229 -0
- package/dist/tests/unit/text-normalizer.test.js.map +1 -0
- package/dist/tests/unit/tracing.test.d.ts +2 -0
- package/dist/tests/unit/tracing.test.d.ts.map +1 -0
- package/dist/tests/unit/tracing.test.js +611 -0
- package/dist/tests/unit/tracing.test.js.map +1 -0
- package/dist/tests/unit/trust-calculator.test.d.ts +2 -0
- package/dist/tests/unit/trust-calculator.test.d.ts.map +1 -0
- package/dist/tests/unit/trust-calculator.test.js +497 -0
- package/dist/tests/unit/trust-calculator.test.js.map +1 -0
- package/dist/tests/unit/ts-sdk.test.d.ts +2 -0
- package/dist/tests/unit/ts-sdk.test.d.ts.map +1 -0
- package/dist/tests/unit/ts-sdk.test.js +421 -0
- package/dist/tests/unit/ts-sdk.test.js.map +1 -0
- package/dist/tests/unit/usage-extractor-llm.test.d.ts +2 -0
- package/dist/tests/unit/usage-extractor-llm.test.d.ts.map +1 -0
- package/dist/tests/unit/usage-extractor-llm.test.js +139 -0
- package/dist/tests/unit/usage-extractor-llm.test.js.map +1 -0
- package/dist/tests/unit/usage-extractor.test.d.ts +2 -0
- package/dist/tests/unit/usage-extractor.test.d.ts.map +1 -0
- package/dist/tests/unit/usage-extractor.test.js +271 -0
- package/dist/tests/unit/usage-extractor.test.js.map +1 -0
- package/dist/tests/unit/user-stores.test.d.ts +2 -0
- package/dist/tests/unit/user-stores.test.d.ts.map +1 -0
- package/dist/tests/unit/user-stores.test.js +687 -0
- package/dist/tests/unit/user-stores.test.js.map +1 -0
- package/dist/tests/unit/validate.test.d.ts +2 -0
- package/dist/tests/unit/validate.test.d.ts.map +1 -0
- package/dist/tests/unit/validate.test.js +545 -0
- package/dist/tests/unit/validate.test.js.map +1 -0
- package/package.json +86 -0
- package/policy-packs/README.md +42 -0
- package/policy-packs/default.yaml +46 -0
- package/policy-packs/dev_fast.yaml +54 -0
- package/policy-packs/prod_strict.yaml +83 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.validateConfig = validateConfig;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
/**
|
|
39
|
+
* Validate gateway configuration before startup.
|
|
40
|
+
* Returns fatal errors (should prevent startup) and warnings (log and continue).
|
|
41
|
+
*/
|
|
42
|
+
function validateConfig(config) {
|
|
43
|
+
const issues = [];
|
|
44
|
+
const isProduction = process.env.NODE_ENV === 'production';
|
|
45
|
+
// Port validation
|
|
46
|
+
if (!Number.isInteger(config.port) || config.port < 1 || config.port > 65535) {
|
|
47
|
+
issues.push({ level: 'fatal', message: `Invalid port: ${config.port}. Must be between 1 and 65535.` });
|
|
48
|
+
}
|
|
49
|
+
// Policy file must be readable
|
|
50
|
+
try {
|
|
51
|
+
fs.accessSync(config.policy.pack_path, fs.constants.R_OK);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
issues.push({ level: 'fatal', message: `Policy file not readable: ${config.policy.pack_path}` });
|
|
55
|
+
}
|
|
56
|
+
// Weak secrets in production
|
|
57
|
+
if (isProduction) {
|
|
58
|
+
if (!process.env.JWT_SECRET) {
|
|
59
|
+
issues.push({ level: 'fatal', message: 'JWT_SECRET must be set in production.' });
|
|
60
|
+
}
|
|
61
|
+
if (!process.env.APPROVAL_SECRET) {
|
|
62
|
+
issues.push({ level: 'fatal', message: 'APPROVAL_SECRET must be set in production.' });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Warnings: no persistent storage
|
|
66
|
+
if (!process.env.REDIS_URL && !process.env.DATABASE_URL) {
|
|
67
|
+
issues.push({ level: 'warning', message: 'No persistent storage configured (REDIS_URL or DATABASE_URL). Data will be lost on restart.' });
|
|
68
|
+
}
|
|
69
|
+
// Auth enabled but no keys
|
|
70
|
+
if (config.auth.enabled && Object.keys(config.auth.api_keys).length === 0 && !config.auth.jwt?.enabled) {
|
|
71
|
+
issues.push({ level: 'warning', message: 'Auth is enabled but no API keys or JWT configured. All authenticated requests will fail.' });
|
|
72
|
+
}
|
|
73
|
+
// Audit log directory
|
|
74
|
+
if (config.audit.enabled && config.audit.log_dir) {
|
|
75
|
+
try {
|
|
76
|
+
fs.accessSync(config.audit.log_dir, fs.constants.W_OK);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
issues.push({ level: 'warning', message: `Audit log directory not writable: ${config.audit.log_dir}` });
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Auth must be enabled — MCP HTTP transport requires authentication
|
|
83
|
+
if (!config.auth.enabled) {
|
|
84
|
+
issues.push({ level: 'fatal', message: 'Auth is disabled. MCP HTTP transport requires authentication. Set AUTH_ENABLED=true.' });
|
|
85
|
+
}
|
|
86
|
+
// RBAC default_role must not be admin or operator
|
|
87
|
+
if (config.auth.rbac?.default_role) {
|
|
88
|
+
const dr = config.auth.rbac.default_role;
|
|
89
|
+
if (dr === 'admin' || dr === 'operator') {
|
|
90
|
+
issues.push({ level: 'fatal', message: `RBAC default_role '${dr}' is a privileged role. Use 'agent', 'readonly', or a custom role.` });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Proxy port validation
|
|
94
|
+
if (config.proxy?.enabled) {
|
|
95
|
+
if (!Number.isInteger(config.proxy.port) || config.proxy.port < 1 || config.proxy.port > 65535) {
|
|
96
|
+
issues.push({ level: 'fatal', message: `Invalid proxy port: ${config.proxy.port}. Must be between 1 and 65535.` });
|
|
97
|
+
}
|
|
98
|
+
if (config.proxy.port === config.port) {
|
|
99
|
+
issues.push({ level: 'fatal', message: `Proxy port (${config.proxy.port}) conflicts with server port (${config.port}).` });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const hasFatal = issues.some(i => i.level === 'fatal');
|
|
103
|
+
return { valid: !hasFatal, issues };
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/config/validate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,wCAsEC;AAvFD,uCAAyB;AAazB;;;GAGG;AACH,SAAgB,cAAc,CAAC,MAAqB;IAClD,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC;IAE3D,kBAAkB;IAClB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC;QAC7E,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAA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KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,KAAK,EAAE,CAAC;YAC/F,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,MAAM,CAAC,KAAK,CAAC,IAAI,gCAAgC,EAAE,CAAC,CAAC;QACrH,CAAC;QACD,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,MAAM,CAAC,KAAK,CAAC,IAAI,iCAAiC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC7H,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC;IACvD,OAAO,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DLPReport } from '../types/tool-result';
|
|
2
|
+
import { DLPConfig } from '../types/config';
|
|
3
|
+
import { DLPScanner } from './scanner';
|
|
4
|
+
import { DLPBackend } from './interfaces';
|
|
5
|
+
/**
|
|
6
|
+
* CompositeDLPScanner wraps the existing DLPScanner and augments it with
|
|
7
|
+
* additional pluggable DLP backends (e.g. TruffleHog, regex backend).
|
|
8
|
+
*
|
|
9
|
+
* The scan flow:
|
|
10
|
+
* 1. Run the standard DLPScanner.scan() for full existing behavior
|
|
11
|
+
* 2. Extract all string values from the data object recursively
|
|
12
|
+
* 3. For each additional backend, call scanString on each extracted string
|
|
13
|
+
* 4. Merge backend detections into the DLPReport (deduplicate by pattern_name)
|
|
14
|
+
* 5. Recalculate severity based on all combined findings
|
|
15
|
+
*
|
|
16
|
+
* This design preserves full backward compatibility -- the existing DLPScanner
|
|
17
|
+
* continues to handle redaction, policy integration, and all current features.
|
|
18
|
+
* The backends provide supplemental detections that are merged into the report.
|
|
19
|
+
*/
|
|
20
|
+
export declare class CompositeDLPScanner {
|
|
21
|
+
private readonly dlpScanner;
|
|
22
|
+
private readonly backends;
|
|
23
|
+
private readonly config;
|
|
24
|
+
constructor(config: DLPConfig, backends: DLPBackend[]);
|
|
25
|
+
/**
|
|
26
|
+
* Get the underlying DLPScanner instance (for redaction operations, etc.).
|
|
27
|
+
*/
|
|
28
|
+
get scanner(): DLPScanner;
|
|
29
|
+
/**
|
|
30
|
+
* Scan data for secrets and PII using the built-in scanner and all backends.
|
|
31
|
+
*
|
|
32
|
+
* @param data - The data to scan (object, array, string, or primitive).
|
|
33
|
+
* @param basePath - Dot-notation prefix for paths within the data structure.
|
|
34
|
+
* @returns A merged DLPReport with detections from all sources.
|
|
35
|
+
*/
|
|
36
|
+
scan(data: unknown, basePath?: string): DLPReport;
|
|
37
|
+
/**
|
|
38
|
+
* Recursively extract all string values and their dot-notation paths
|
|
39
|
+
* from a nested data structure.
|
|
40
|
+
*/
|
|
41
|
+
private extractStrings;
|
|
42
|
+
/**
|
|
43
|
+
* Return the highest severity from an array of severities.
|
|
44
|
+
*/
|
|
45
|
+
private highestSeverity;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=composite-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-scanner.d.ts","sourceRoot":"","sources":["../../../src/dlp/composite-scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC;AAKxD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;gBAEvB,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE;IAMrD;;OAEG;IACH,IAAI,OAAO,IAAI,UAAU,CAExB;IAED;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,GAAE,MAAW,GAAG,SAAS;IAyGrD;;;OAGG;IACH,OAAO,CAAC,cAAc;IAuCtB;;OAEG;IACH,OAAO,CAAC,eAAe;CAaxB"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompositeDLPScanner = void 0;
|
|
4
|
+
const scanner_1 = require("./scanner");
|
|
5
|
+
/** Maximum recursion depth for extracting string values from nested structures. */
|
|
6
|
+
const MAX_EXTRACT_DEPTH = 32;
|
|
7
|
+
/**
|
|
8
|
+
* CompositeDLPScanner wraps the existing DLPScanner and augments it with
|
|
9
|
+
* additional pluggable DLP backends (e.g. TruffleHog, regex backend).
|
|
10
|
+
*
|
|
11
|
+
* The scan flow:
|
|
12
|
+
* 1. Run the standard DLPScanner.scan() for full existing behavior
|
|
13
|
+
* 2. Extract all string values from the data object recursively
|
|
14
|
+
* 3. For each additional backend, call scanString on each extracted string
|
|
15
|
+
* 4. Merge backend detections into the DLPReport (deduplicate by pattern_name)
|
|
16
|
+
* 5. Recalculate severity based on all combined findings
|
|
17
|
+
*
|
|
18
|
+
* This design preserves full backward compatibility -- the existing DLPScanner
|
|
19
|
+
* continues to handle redaction, policy integration, and all current features.
|
|
20
|
+
* The backends provide supplemental detections that are merged into the report.
|
|
21
|
+
*/
|
|
22
|
+
class CompositeDLPScanner {
|
|
23
|
+
constructor(config, backends) {
|
|
24
|
+
this.config = config;
|
|
25
|
+
this.dlpScanner = new scanner_1.DLPScanner(config);
|
|
26
|
+
this.backends = backends;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get the underlying DLPScanner instance (for redaction operations, etc.).
|
|
30
|
+
*/
|
|
31
|
+
get scanner() {
|
|
32
|
+
return this.dlpScanner;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Scan data for secrets and PII using the built-in scanner and all backends.
|
|
36
|
+
*
|
|
37
|
+
* @param data - The data to scan (object, array, string, or primitive).
|
|
38
|
+
* @param basePath - Dot-notation prefix for paths within the data structure.
|
|
39
|
+
* @returns A merged DLPReport with detections from all sources.
|
|
40
|
+
*/
|
|
41
|
+
scan(data, basePath = '') {
|
|
42
|
+
// Step 1: Run the standard DLPScanner for existing behavior
|
|
43
|
+
const baseReport = this.dlpScanner.scan(data, basePath);
|
|
44
|
+
// If DLP is disabled or there are no backends, return the base report as-is
|
|
45
|
+
if (!this.config.enabled || this.backends.length === 0) {
|
|
46
|
+
return baseReport;
|
|
47
|
+
}
|
|
48
|
+
// Step 2: Extract all string values with their paths from the data,
|
|
49
|
+
// including fields that the default recursive walker would miss
|
|
50
|
+
// (context.purpose, context.labels, actor.display).
|
|
51
|
+
const stringEntries = this.extractStrings(data, basePath, 0);
|
|
52
|
+
// Step 2.5: Explicitly extract commonly-missed ToolCall text fields.
|
|
53
|
+
// The generic walker handles args.* but context and actor are top-level
|
|
54
|
+
// fields that may not be traversed if 'data' is the full ToolCall object
|
|
55
|
+
// or if basePath filtering skips them.
|
|
56
|
+
if (data && typeof data === 'object' && !Array.isArray(data)) {
|
|
57
|
+
const obj = data;
|
|
58
|
+
// context.purpose
|
|
59
|
+
if (obj.context && typeof obj.context === 'object') {
|
|
60
|
+
const ctx = obj.context;
|
|
61
|
+
if (typeof ctx.purpose === 'string') {
|
|
62
|
+
const p = basePath ? `${basePath}.context.purpose` : 'context.purpose';
|
|
63
|
+
if (!stringEntries.some(e => e.path === p)) {
|
|
64
|
+
stringEntries.push({ value: ctx.purpose, path: p });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// context.labels[]
|
|
68
|
+
if (Array.isArray(ctx.labels)) {
|
|
69
|
+
for (let i = 0; i < ctx.labels.length; i++) {
|
|
70
|
+
if (typeof ctx.labels[i] === 'string') {
|
|
71
|
+
const p = basePath ? `${basePath}.context.labels[${i}]` : `context.labels[${i}]`;
|
|
72
|
+
if (!stringEntries.some(e => e.path === p)) {
|
|
73
|
+
stringEntries.push({ value: ctx.labels[i], path: p });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// actor.display
|
|
80
|
+
if (obj.actor && typeof obj.actor === 'object') {
|
|
81
|
+
const actor = obj.actor;
|
|
82
|
+
if (typeof actor.display === 'string') {
|
|
83
|
+
const p = basePath ? `${basePath}.actor.display` : 'actor.display';
|
|
84
|
+
if (!stringEntries.some(e => e.path === p)) {
|
|
85
|
+
stringEntries.push({ value: actor.display, path: p });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
// Step 3: Run each backend on each string value
|
|
91
|
+
const backendDetections = [];
|
|
92
|
+
for (const backend of this.backends) {
|
|
93
|
+
for (const entry of stringEntries) {
|
|
94
|
+
try {
|
|
95
|
+
const detections = backend.scanString(entry.value);
|
|
96
|
+
for (const detection of detections) {
|
|
97
|
+
backendDetections.push({ detection, path: entry.path });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
// Graceful degradation: log and continue with other backends/strings
|
|
102
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
103
|
+
console.warn(`[CompositeDLPScanner] backend '${backend.name}' failed on path '${entry.path}': ${message}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// Step 4: Merge backend detections into the base report (deduplicate by pattern_name)
|
|
108
|
+
const existingPatterns = new Set(baseReport.detected);
|
|
109
|
+
const additionalDetected = [];
|
|
110
|
+
const additionalRedactions = [];
|
|
111
|
+
for (const { detection, path } of backendDetections) {
|
|
112
|
+
if (!existingPatterns.has(detection.pattern_name)) {
|
|
113
|
+
existingPatterns.add(detection.pattern_name);
|
|
114
|
+
additionalDetected.push(detection.pattern_name);
|
|
115
|
+
additionalRedactions.push({
|
|
116
|
+
path,
|
|
117
|
+
method: this.config.default_redaction_method,
|
|
118
|
+
original_type: detection.pattern_name,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const mergedDetected = [...baseReport.detected, ...additionalDetected];
|
|
123
|
+
const mergedRedactions = [...baseReport.redactions, ...additionalRedactions];
|
|
124
|
+
// Step 5: Recalculate severity based on all findings
|
|
125
|
+
const allSeverities = [baseReport.severity];
|
|
126
|
+
for (const { detection } of backendDetections) {
|
|
127
|
+
allSeverities.push(detection.severity);
|
|
128
|
+
}
|
|
129
|
+
const severity = this.highestSeverity(allSeverities);
|
|
130
|
+
return {
|
|
131
|
+
detected: mergedDetected,
|
|
132
|
+
redactions: mergedRedactions,
|
|
133
|
+
severity,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Recursively extract all string values and their dot-notation paths
|
|
138
|
+
* from a nested data structure.
|
|
139
|
+
*/
|
|
140
|
+
extractStrings(data, path, depth) {
|
|
141
|
+
if (depth > MAX_EXTRACT_DEPTH) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
if (data === null || data === undefined) {
|
|
145
|
+
return [];
|
|
146
|
+
}
|
|
147
|
+
if (typeof data === 'string') {
|
|
148
|
+
return [{ value: data, path }];
|
|
149
|
+
}
|
|
150
|
+
if (Array.isArray(data)) {
|
|
151
|
+
const results = [];
|
|
152
|
+
for (let i = 0; i < data.length; i++) {
|
|
153
|
+
const childPath = path ? `${path}[${i}]` : `[${i}]`;
|
|
154
|
+
results.push(...this.extractStrings(data[i], childPath, depth + 1));
|
|
155
|
+
}
|
|
156
|
+
return results;
|
|
157
|
+
}
|
|
158
|
+
if (typeof data === 'object') {
|
|
159
|
+
const results = [];
|
|
160
|
+
for (const [key, value] of Object.entries(data)) {
|
|
161
|
+
const childPath = path ? `${path}.${key}` : key;
|
|
162
|
+
results.push(...this.extractStrings(value, childPath, depth + 1));
|
|
163
|
+
}
|
|
164
|
+
return results;
|
|
165
|
+
}
|
|
166
|
+
// Non-string primitives are ignored
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Return the highest severity from an array of severities.
|
|
171
|
+
*/
|
|
172
|
+
highestSeverity(severities) {
|
|
173
|
+
const rank = { low: 0, medium: 1, high: 2 };
|
|
174
|
+
let highest = 'low';
|
|
175
|
+
for (const sev of severities) {
|
|
176
|
+
if (rank[sev] > rank[highest]) {
|
|
177
|
+
highest = sev;
|
|
178
|
+
}
|
|
179
|
+
if (highest === 'high')
|
|
180
|
+
break; // Short-circuit
|
|
181
|
+
}
|
|
182
|
+
return highest;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.CompositeDLPScanner = CompositeDLPScanner;
|
|
186
|
+
//# sourceMappingURL=composite-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-scanner.js","sourceRoot":"","sources":["../../../src/dlp/composite-scanner.ts"],"names":[],"mappings":";;;AAEA,uCAAuC;AAGvC,mFAAmF;AACnF,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B;;;;;;;;;;;;;;GAcG;AACH,MAAa,mBAAmB;IAK9B,YAAY,MAAiB,EAAE,QAAsB;QACnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAU,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI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AC;YAC7B,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC9B,OAAO,GAAG,GAAG,CAAC;YAChB,CAAC;YACD,IAAI,OAAO,KAAK,MAAM;gBAAE,MAAM,CAAC,gBAAgB;QACjD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA7LD,kDA6LC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { DLPScanner } from './scanner';
|
|
2
|
+
export { DLPBackend, DLPDetection } from './interfaces';
|
|
3
|
+
export { DLPPattern, SECRET_PATTERNS, PII_PATTERNS } from './patterns';
|
|
4
|
+
export { RegexDLPBackend, RegexBackendConfig } from './regex-backend';
|
|
5
|
+
export { TruffleHogBackend, TruffleHogConfig } from './trufflehog-backend';
|
|
6
|
+
export { CompositeDLPScanner } from './composite-scanner';
|
|
7
|
+
export { PROMPT_INJECTION_PATTERNS, OUTPUT_INJECTION_PATTERNS } from './prompt-injection-patterns';
|
|
8
|
+
export { PromptInjectionBackend, PromptInjectionConfig } from './prompt-injection-backend';
|
|
9
|
+
export { normalizeText, normalizeLeetspeak, ZERO_WIDTH_REGEX, HOMOGLYPH_MAP, LEETSPEAK_MAP } from './text-normalizer';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dlp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LEETSPEAK_MAP = exports.HOMOGLYPH_MAP = exports.ZERO_WIDTH_REGEX = exports.normalizeLeetspeak = exports.normalizeText = exports.PromptInjectionBackend = exports.OUTPUT_INJECTION_PATTERNS = exports.PROMPT_INJECTION_PATTERNS = exports.CompositeDLPScanner = exports.TruffleHogBackend = exports.RegexDLPBackend = exports.PII_PATTERNS = exports.SECRET_PATTERNS = exports.DLPScanner = void 0;
|
|
4
|
+
var scanner_1 = require("./scanner");
|
|
5
|
+
Object.defineProperty(exports, "DLPScanner", { enumerable: true, get: function () { return scanner_1.DLPScanner; } });
|
|
6
|
+
var patterns_1 = require("./patterns");
|
|
7
|
+
Object.defineProperty(exports, "SECRET_PATTERNS", { enumerable: true, get: function () { return patterns_1.SECRET_PATTERNS; } });
|
|
8
|
+
Object.defineProperty(exports, "PII_PATTERNS", { enumerable: true, get: function () { return patterns_1.PII_PATTERNS; } });
|
|
9
|
+
var regex_backend_1 = require("./regex-backend");
|
|
10
|
+
Object.defineProperty(exports, "RegexDLPBackend", { enumerable: true, get: function () { return regex_backend_1.RegexDLPBackend; } });
|
|
11
|
+
var trufflehog_backend_1 = require("./trufflehog-backend");
|
|
12
|
+
Object.defineProperty(exports, "TruffleHogBackend", { enumerable: true, get: function () { return trufflehog_backend_1.TruffleHogBackend; } });
|
|
13
|
+
var composite_scanner_1 = require("./composite-scanner");
|
|
14
|
+
Object.defineProperty(exports, "CompositeDLPScanner", { enumerable: true, get: function () { return composite_scanner_1.CompositeDLPScanner; } });
|
|
15
|
+
var prompt_injection_patterns_1 = require("./prompt-injection-patterns");
|
|
16
|
+
Object.defineProperty(exports, "PROMPT_INJECTION_PATTERNS", { enumerable: true, get: function () { return prompt_injection_patterns_1.PROMPT_INJECTION_PATTERNS; } });
|
|
17
|
+
Object.defineProperty(exports, "OUTPUT_INJECTION_PATTERNS", { enumerable: true, get: function () { return prompt_injection_patterns_1.OUTPUT_INJECTION_PATTERNS; } });
|
|
18
|
+
var prompt_injection_backend_1 = require("./prompt-injection-backend");
|
|
19
|
+
Object.defineProperty(exports, "PromptInjectionBackend", { enumerable: true, get: function () { return prompt_injection_backend_1.PromptInjectionBackend; } });
|
|
20
|
+
var text_normalizer_1 = require("./text-normalizer");
|
|
21
|
+
Object.defineProperty(exports, "normalizeText", { enumerable: true, get: function () { return text_normalizer_1.normalizeText; } });
|
|
22
|
+
Object.defineProperty(exports, "normalizeLeetspeak", { enumerable: true, get: function () { return text_normalizer_1.normalizeLeetspeak; } });
|
|
23
|
+
Object.defineProperty(exports, "ZERO_WIDTH_REGEX", { enumerable: true, get: function () { return text_normalizer_1.ZERO_WIDTH_REGEX; } });
|
|
24
|
+
Object.defineProperty(exports, "HOMOGLYPH_MAP", { enumerable: true, get: function () { return text_normalizer_1.HOMOGLYPH_MAP; } });
|
|
25
|
+
Object.defineProperty(exports, "LEETSPEAK_MAP", { enumerable: true, get: function () { return text_normalizer_1.LEETSPEAK_MAP; } });
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dlp/index.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAA9B,qGAAA,UAAU,OAAA;AAEnB,uCAAuE;AAAlD,2GAAA,eAAe,OAAA;AAAE,wGAAA,YAAY,OAAA;AAClD,iDAAsE;AAA7D,gHAAA,eAAe,OAAA;AACxB,2DAA2E;AAAlE,uHAAA,iBAAiB,OAAA;AAC1B,yDAA0D;AAAjD,wHAAA,mBAAmB,OAAA;AAC5B,yEAAmG;AAA1F,sIAAA,yBAAyB,OAAA;AAAE,sIAAA,yBAAyB,OAAA;AAC7D,uEAA2F;AAAlF,kIAAA,sBAAsB,OAAA;AAC/B,qDAAsH;AAA7G,gHAAA,aAAa,OAAA;AAAE,qHAAA,kBAAkB,OAAA;AAAE,mHAAA,gBAAgB,OAAA;AAAE,gHAAA,aAAa,OAAA;AAAE,gHAAA,aAAa,OAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DLPSeverity } from '../types/tool-result';
|
|
2
|
+
/**
|
|
3
|
+
* A detection returned by a DLP backend scanner.
|
|
4
|
+
*
|
|
5
|
+
* Each detection identifies a single sensitive value found within a string,
|
|
6
|
+
* including its location so that upstream consumers can apply redactions.
|
|
7
|
+
*/
|
|
8
|
+
export interface DLPDetection {
|
|
9
|
+
/** Name of the pattern or detector that matched (e.g. 'aws_access_key', 'GitHubToken'). */
|
|
10
|
+
pattern_name: string;
|
|
11
|
+
/** Severity of the detection. */
|
|
12
|
+
severity: DLPSeverity;
|
|
13
|
+
/** The matched text. */
|
|
14
|
+
match: string;
|
|
15
|
+
/** Start index within the scanned string. */
|
|
16
|
+
start: number;
|
|
17
|
+
/** End index (exclusive) within the scanned string. */
|
|
18
|
+
end: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Pluggable backend interface for DLP secret/PII scanning.
|
|
22
|
+
*
|
|
23
|
+
* Implementations scan raw string values and return structured detections.
|
|
24
|
+
* The gateway can compose multiple backends (regex, trufflehog, etc.) via
|
|
25
|
+
* the CompositeDLPScanner.
|
|
26
|
+
*/
|
|
27
|
+
export interface DLPBackend {
|
|
28
|
+
/** Scan a string for secrets/PII. Returns detected pattern names and their locations. */
|
|
29
|
+
scanString(value: string): DLPDetection[];
|
|
30
|
+
/** Name of this backend for logging. */
|
|
31
|
+
readonly name: string;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/dlp/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,2FAA2F;IAC3F,YAAY,EAAE,MAAM,CAAC;IACrB,iCAAiC;IACjC,QAAQ,EAAE,WAAW,CAAC;IACtB,wBAAwB;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,yFAAyF;IACzF,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;IAC1C,wCAAwC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/dlp/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DLPSeverity } from '../types/tool-result';
|
|
2
|
+
export interface DLPPattern {
|
|
3
|
+
name: string;
|
|
4
|
+
pattern: RegExp;
|
|
5
|
+
severity: DLPSeverity;
|
|
6
|
+
}
|
|
7
|
+
export declare const SECRET_PATTERNS: DLPPattern[];
|
|
8
|
+
export declare const PII_PATTERNS: DLPPattern[];
|
|
9
|
+
//# sourceMappingURL=patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../../src/dlp/patterns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,WAAW,CAAC;CACvB;AAGD,eAAO,MAAM,eAAe,EAAE,UAAU,EAWvC,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,UAAU,EAMpC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PII_PATTERNS = exports.SECRET_PATTERNS = void 0;
|
|
4
|
+
// Detection patterns for secrets
|
|
5
|
+
exports.SECRET_PATTERNS = [
|
|
6
|
+
{ name: 'aws_access_key', pattern: /AKIA[0-9A-Z]{16}/g, severity: 'high' },
|
|
7
|
+
{ name: 'aws_secret_key', pattern: /(?:aws_secret_access_key|secret_key)\s*[=:]\s*[A-Za-z0-9/+=]{40}/gi, severity: 'high' },
|
|
8
|
+
{ name: 'github_token', pattern: /gh[pousr]_[A-Za-z0-9_]{36,255}/g, severity: 'high' },
|
|
9
|
+
{ name: 'generic_api_key', pattern: /(?:api[_-]?key|apikey)\s*[=:]\s*['"]?[A-Za-z0-9_\-]{20,}['"]?/gi, severity: 'medium' },
|
|
10
|
+
{ name: 'bearer_token', pattern: /Bearer\s+[A-Za-z0-9\-._~+/]+=*/g, severity: 'high' },
|
|
11
|
+
{ name: 'jwt_token', pattern: /eyJ[A-Za-z0-9_-]*\.eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_\-]+/g, severity: 'high' },
|
|
12
|
+
{ name: 'private_key', pattern: /-----BEGIN (?:RSA |EC |DSA )?PRIVATE KEY-----/g, severity: 'high' },
|
|
13
|
+
{ name: 'password_field', pattern: /(?:password|passwd|pwd)\s*[=:]\s*['"]?[^\s'"]{8,}['"]?/gi, severity: 'high' },
|
|
14
|
+
{ name: 'slack_token', pattern: /xox[baprs]-[0-9a-zA-Z-]{10,}/g, severity: 'high' },
|
|
15
|
+
{ name: 'generic_secret', pattern: /(?:secret|token|credential)\s*[=:]\s*['"]?[A-Za-z0-9_\-]{16,}['"]?/gi, severity: 'medium' },
|
|
16
|
+
];
|
|
17
|
+
// PII patterns
|
|
18
|
+
exports.PII_PATTERNS = [
|
|
19
|
+
{ name: 'email', pattern: /[a-zA-Z0-9._%+\-]+@(?!(?:\d{1,3}\.){3}\d{1,3}\b)[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]+)*\.[a-zA-Z]{2,}/g, severity: 'medium' },
|
|
20
|
+
{ name: 'phone_us', pattern: /(?:\+1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/g, severity: 'medium' },
|
|
21
|
+
{ name: 'ssn', pattern: /\b\d{3}-\d{2}-\d{4}\b/g, severity: 'high' },
|
|
22
|
+
{ name: 'credit_card', pattern: /\b(?:\d{4}[-\s]?){3}\d{4}\b/g, severity: 'high' },
|
|
23
|
+
{ name: 'ip_address', pattern: /\b(?:\d{1,3}\.){3}\d{1,3}\b/g, severity: 'low' },
|
|
24
|
+
];
|
|
25
|
+
//# sourceMappingURL=patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patterns.js","sourceRoot":"","sources":["../../../src/dlp/patterns.ts"],"names":[],"mappings":";;;AAQA,iCAAiC;AACpB,QAAA,eAAe,GAAiB;IAC3C,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,EAAE;IAC1E,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,oEAAoE,EAAE,QAAQ,EAAE,MAAM,EAAE;IAC3H,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,iCAAiC,EAAE,QAAQ,EAAE,MAAM,EAAE;IACtF,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,iEAAiE,EAAE,QAAQ,EAAE,QAAQ,EAAE;IAC3H,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,iCAAiC,EAAE,QAAQ,EAAE,MAAM,EAAE;IACtF,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,wDAAwD,EAAE,QAAQ,EAAE,MAAM,EAAE;IAC1G,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,gDAAgD,EAAE,QAAQ,EAAE,MAAM,EAAE;IACpG,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,0DAA0D,EAAE,QAAQ,EAAE,MAAM,EAAE;IACjH,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,+BAA+B,EAAE,QAAQ,EAAE,MAAM,EAAE;IACnF,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,sEAAsE,EAAE,QAAQ,EAAE,QAAQ,EAAE;CAChI,CAAC;AAEF,eAAe;AACF,QAAA,YAAY,GAAiB;IACxC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,oGAAoG,EAAE,QAAQ,EAAE,QAAQ,EAAE;IACpJ,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,qDAAqD,EAAE,QAAQ,EAAE,QAAQ,EAAE;IACxG,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,wBAAwB,EAAE,QAAQ,EAAE,MAAM,EAAE;IACpE,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,8BAA8B,EAAE,QAAQ,EAAE,MAAM,EAAE;IAClF,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,8BAA8B,EAAE,QAAQ,EAAE,KAAK,EAAE;CACjF,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { DLPBackend, DLPDetection } from './interfaces';
|
|
2
|
+
import { DLPPattern } from './patterns';
|
|
3
|
+
export interface PromptInjectionConfig {
|
|
4
|
+
/** Enable prompt injection detection. Default true. */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
/** Additional custom patterns to scan alongside the built-in set. */
|
|
7
|
+
custom_patterns?: DLPPattern[];
|
|
8
|
+
/** Enable output-side pattern scanning. Default false. */
|
|
9
|
+
scan_output?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* DLP backend that detects common prompt injection patterns in text.
|
|
13
|
+
*
|
|
14
|
+
* Scans for 13 categories of prompt injection:
|
|
15
|
+
* - Direct instruction overrides
|
|
16
|
+
* - Role manipulation
|
|
17
|
+
* - Jailbreak keywords
|
|
18
|
+
* - System prompt extraction attempts
|
|
19
|
+
* - Delimiter injection
|
|
20
|
+
* - Context manipulation
|
|
21
|
+
* - Authority impersonation
|
|
22
|
+
* - Indirect injection
|
|
23
|
+
* - Encoding indicators
|
|
24
|
+
* - Synonym variants
|
|
25
|
+
* - Prompt leakage requests
|
|
26
|
+
* - Obfuscation markers
|
|
27
|
+
* - Multi-turn manipulation
|
|
28
|
+
*
|
|
29
|
+
* All text is normalized before pattern matching to resist evasion via
|
|
30
|
+
* zero-width chars, HTML entities, homoglyphs, URL encoding, etc.
|
|
31
|
+
*
|
|
32
|
+
* Combination severity scoring: 3+ medium = effective high, 2+ high = effective critical.
|
|
33
|
+
*/
|
|
34
|
+
export declare class PromptInjectionBackend implements DLPBackend {
|
|
35
|
+
readonly name = "prompt_injection";
|
|
36
|
+
private readonly enabled;
|
|
37
|
+
private readonly patterns;
|
|
38
|
+
private readonly outputPatterns;
|
|
39
|
+
private readonly scanOutput;
|
|
40
|
+
constructor(config?: PromptInjectionConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Scan a string for prompt injection patterns.
|
|
43
|
+
*
|
|
44
|
+
* Text is normalized before matching to defeat evasion techniques.
|
|
45
|
+
* Patterns are matched against both the standard-normalized text and
|
|
46
|
+
* the leetspeak-normalized variant. Positions in detections refer to
|
|
47
|
+
* the original (un-normalized) string for accurate redaction.
|
|
48
|
+
*/
|
|
49
|
+
scanString(value: string): DLPDetection[];
|
|
50
|
+
/**
|
|
51
|
+
* Scan output text specifically for output-side injection patterns.
|
|
52
|
+
* Called during postExecute DLP scanning.
|
|
53
|
+
*/
|
|
54
|
+
scanOutputText(value: string): DLPDetection[];
|
|
55
|
+
/**
|
|
56
|
+
* Run all patterns against a text value and append matches to the detections array.
|
|
57
|
+
*/
|
|
58
|
+
private matchPatterns;
|
|
59
|
+
/**
|
|
60
|
+
* Apply combination severity escalation:
|
|
61
|
+
* - 3+ medium detections -> add effective_severity 'high' metadata
|
|
62
|
+
* - 2+ high detections -> add effective_severity 'critical' metadata
|
|
63
|
+
*
|
|
64
|
+
* Mutates detections in place by upgrading severity where applicable.
|
|
65
|
+
*/
|
|
66
|
+
private applyCombinationScoring;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=prompt-injection-backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-injection-backend.d.ts","sourceRoot":"","sources":["../../../src/dlp/prompt-injection-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAKxC,MAAM,WAAW,qBAAqB;IACpC,uDAAuD;IACvD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qEAAqE;IACrE,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC;IAC/B,0DAA0D;IAC1D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,sBAAuB,YAAW,UAAU;IACvD,QAAQ,CAAC,IAAI,sBAAsB;IAEnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IACxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;gBAEzB,MAAM,CAAC,EAAE,qBAAqB;IAU1C;;;;;;;OAOG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE;IAyCzC;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE;IAW7C;;OAEG;IACH,OAAO,CAAC,aAAa;IAyBrB;;;;;;OAMG;IACH,OAAO,CAAC,uBAAuB;CAyBhC"}
|