@highflame/policy 2.2.3 → 2.2.5

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.
Files changed (27) hide show
  1. package/_schemas/ai_gateway/templates/defaults/pii.cedar +164 -0
  2. package/_schemas/ai_gateway/templates/defaults/pii_advanced.cedar +465 -0
  3. package/_schemas/ai_gateway/templates/defaults/pii_model.cedar +90 -0
  4. package/_schemas/ai_gateway/templates/secrets.cedar +46 -0
  5. package/_schemas/ai_gateway/templates/templates.json +88 -11
  6. package/_schemas/guardrails/templates/defaults/pii.cedar +137 -28
  7. package/_schemas/guardrails/templates/defaults/pii_model.cedar +90 -0
  8. package/_schemas/guardrails/templates/profiles/advanced_detection/pii.cedar +433 -31
  9. package/_schemas/guardrails/templates/templates.json +158 -43
  10. package/_schemas/sentry/templates/defaults/clipboard.cedar +3 -18
  11. package/_schemas/sentry/templates/defaults/file_safety.cedar +2 -17
  12. package/_schemas/sentry/templates/defaults/pii.cedar +102 -96
  13. package/_schemas/sentry/templates/defaults/pii_advanced.cedar +465 -0
  14. package/_schemas/sentry/templates/defaults/pii_model.cedar +90 -0
  15. package/_schemas/sentry/templates/templates.json +68 -11
  16. package/dist/ai_gateway-defaults.gen.d.ts +1 -1
  17. package/dist/ai_gateway-defaults.gen.js +838 -59
  18. package/dist/ai_gateway-detectors.gen.js +18 -4
  19. package/dist/guardrails-defaults.gen.js +834 -226
  20. package/dist/overwatch-defaults.gen.js +703 -114
  21. package/dist/overwatch-detectors.gen.js +31 -1
  22. package/dist/sentry-defaults.gen.js +746 -138
  23. package/dist/sentry-detectors.gen.js +109 -2
  24. package/package.json +1 -1
  25. package/_schemas/ai_gateway/templates/pii_redaction.cedar +0 -94
  26. package/_schemas/guardrails/templates/profiles/chat_assistant/privacy.cedar +0 -35
  27. package/_schemas/guardrails/templates/profiles/data_pipeline/privacy.cedar +0 -63
@@ -93,11 +93,95 @@ export const SENTRY_DETECTORS = [
93
93
  inhouse: false,
94
94
  model: null,
95
95
  latencyP50Ms: 2,
96
- emits: [{ name: "file_name", type: "String", modifiable: false, semantic: "category_label" }, { name: "file_extension", type: "String", modifiable: false, semantic: "category_label" }, { name: "file_size_bytes", type: "Long", modifiable: false, semantic: "count" }, { name: "file_type", type: "String", modifiable: false, semantic: "category_label" }, { name: "mip_label_id", type: "String", modifiable: false, semantic: "category_label" }, { name: "mip_label_name", type: "String", modifiable: false, semantic: "category_label" }],
96
+ emits: [{ name: "file_name", type: "String", modifiable: false, semantic: "category_label" }, { name: "file_extension", type: "String", modifiable: false, semantic: "category_label" }, { name: "file_size_bytes", type: "Long", modifiable: false, semantic: "count" }, { name: "file_type", type: "String", modifiable: false, semantic: "category_label" }, { name: "mip_label_id", type: "String", modifiable: false, semantic: "category_label" }, { name: "mip_label_name", type: "String", modifiable: false, semantic: "category_label" }, { name: "sensitivity_level", type: "String", modifiable: false, description: "Normalized MIP sensitivity level (public, internal, confidential, restricted)." }, { name: "is_encrypted", type: "Bool", modifiable: false, semantic: "boolean_flag", description: "True iff the file is encrypted via MIP protection (absent ⇒ unknown)." }, { name: "is_rights_managed", type: "Bool", modifiable: false, semantic: "boolean_flag", description: "True iff the file has IRM/RMS restrictions (absent ⇒ unknown)." }],
97
97
  supportedModes: ["enforce", "monitor", "alert"],
98
98
  defendsAgainst: ["pii_leakage", "finance_leakage", "legal_leakage"],
99
99
  exampleAttacks: [],
100
100
  },
101
+ {
102
+ id: "code",
103
+ displayName: "Code Detection",
104
+ category: "code",
105
+ stability: "preview",
106
+ tier: "fast",
107
+ inhouse: false,
108
+ model: null,
109
+ latencyP50Ms: null,
110
+ emits: [{ name: "contains_code", type: "Bool", modifiable: false, semantic: "boolean_flag", description: "True iff code-like content was detected." }, { name: "code_languages", type: "Set<String>", modifiable: false, semantic: "category_set", description: "Programming languages identified in the content." }, { name: "code_ratio", type: "Long", modifiable: false, description: "Ratio of code-like lines to total non-empty lines (0-100)." }],
111
+ supportedModes: ["enforce", "monitor", "alert"],
112
+ defendsAgainst: [],
113
+ exampleAttacks: [],
114
+ },
115
+ {
116
+ id: "language",
117
+ displayName: "Language Detection",
118
+ category: "context",
119
+ stability: "stable",
120
+ tier: "standard",
121
+ inhouse: false,
122
+ model: null,
123
+ latencyP50Ms: null,
124
+ emits: [{ name: "detected_language", type: "String", modifiable: false, description: "ISO 639-1 code (e.g. en, fr, ja) or `unknown`." }, { name: "is_english", type: "Bool", modifiable: false, semantic: "boolean_flag", description: "True iff the detected language is English." }, { name: "language_confidence", type: "Long", modifiable: false, semantic: "severity_0_100", description: "Language-detection confidence (0-100)." }],
125
+ supportedModes: ["enforce", "monitor", "alert"],
126
+ defendsAgainst: [],
127
+ exampleAttacks: [],
128
+ },
129
+ {
130
+ id: "script",
131
+ displayName: "Script Detection",
132
+ category: "context",
133
+ stability: "stable",
134
+ tier: "fast",
135
+ inhouse: false,
136
+ model: null,
137
+ latencyP50Ms: null,
138
+ emits: [{ name: "detected_script", type: "String", modifiable: false, description: "Dominant Unicode script (latin, cjk, cyrillic, arabic, devanagari, other, unknown)." }, { name: "is_latin_script", type: "Bool", modifiable: false, semantic: "boolean_flag", description: "True iff content is primarily Latin-script." }, { name: "script_confidence", type: "Long", modifiable: false, semantic: "severity_0_100", description: "Confidence in the dominant-script classification (0-100)." }],
139
+ supportedModes: ["enforce", "monitor", "alert"],
140
+ defendsAgainst: [],
141
+ exampleAttacks: [],
142
+ },
143
+ {
144
+ id: "keyword",
145
+ displayName: "Keyword Blocklist",
146
+ category: "content_safety",
147
+ stability: "stable",
148
+ tier: "fast",
149
+ inhouse: false,
150
+ model: null,
151
+ latencyP50Ms: null,
152
+ emits: [{ name: "keyword_matched", type: "Bool", modifiable: false, description: "True iff at least one keyword from any active category matched." }, { name: "keyword_categories", type: "Set<String>", modifiable: false, semantic: "category_set", description: "Distinct keyword categories with at least one match." }, { name: "keyword_count", type: "Long", modifiable: false, semantic: "count", description: "Total keyword matches across all categories." }],
153
+ supportedModes: ["enforce", "monitor", "alert"],
154
+ defendsAgainst: ["toxicity"],
155
+ exampleAttacks: [],
156
+ },
157
+ {
158
+ id: "hallucination",
159
+ displayName: "Hallucination Guard",
160
+ category: "content_safety",
161
+ stability: "stable",
162
+ tier: "standard",
163
+ inhouse: true,
164
+ model: { name: "guard-hallucination", version: "1.2.0" },
165
+ latencyP50Ms: 52,
166
+ emits: [{ name: "hallucination_score", type: "Long", modifiable: false, semantic: "severity_0_100", description: "Hallucination probability (0-100)." }, { name: "factuality_score", type: "Long", modifiable: false, semantic: "severity_0_100", description: "Factuality score (0-100) — complement of hallucination." }],
167
+ supportedModes: ["enforce", "monitor", "alert"],
168
+ defendsAgainst: ["misinformation"],
169
+ exampleAttacks: [],
170
+ },
171
+ {
172
+ id: "topic",
173
+ displayName: "Topic Classifier",
174
+ category: "context",
175
+ stability: "stable",
176
+ tier: "standard",
177
+ inhouse: false,
178
+ model: null,
179
+ latencyP50Ms: null,
180
+ emits: [{ name: "content_topics", type: "Set<String>", modifiable: false, semantic: "category_set", description: "Detected content topics." }, { name: "topic_confidence", type: "Long", modifiable: false, semantic: "severity_0_100", description: "Confidence in the dominant-topic classification (0-100)." }],
181
+ supportedModes: ["enforce", "monitor", "alert"],
182
+ defendsAgainst: [],
183
+ exampleAttacks: [],
184
+ },
101
185
  {
102
186
  id: "paste_monitor",
103
187
  displayName: "Paste Monitor",
@@ -116,21 +200,36 @@ export const SENTRY_DETECTORS = [
116
200
  // Semantic field → contributing detector ids (producesAttrs + normalizationAliases,
117
201
  // resolved at codegen). Used by the client field→detector resolver — no Shield round-trip.
118
202
  export const SENTRY_FIELD_TO_DETECTORS = {
119
- "content_topics": ["paste_monitor"],
203
+ "code_languages": ["code"],
204
+ "code_ratio": ["code"],
205
+ "contains_code": ["code"],
206
+ "content_topics": ["topic", "paste_monitor"],
120
207
  "crime_score": ["toxicity"],
208
+ "detected_language": ["language"],
209
+ "detected_script": ["script"],
121
210
  "encoded_content_detected": ["encoded_injection"],
122
211
  "encoded_count": ["encoded_injection"],
123
212
  "encoded_score": ["encoded_injection"],
124
213
  "encoded_types": ["encoded_injection"],
214
+ "factuality_score": ["hallucination"],
125
215
  "file_extension": ["file_metadata"],
126
216
  "file_name": ["file_metadata"],
127
217
  "file_size_bytes": ["file_metadata"],
128
218
  "file_type": ["file_metadata"],
219
+ "hallucination_score": ["hallucination"],
129
220
  "hate_speech_score": ["toxicity"],
130
221
  "injection_score": ["injection"],
131
222
  "invisible_chars_detected": ["encoded_injection"],
132
223
  "invisible_chars_score": ["encoded_injection"],
224
+ "is_encrypted": ["file_metadata"],
225
+ "is_english": ["language"],
226
+ "is_latin_script": ["script"],
227
+ "is_rights_managed": ["file_metadata"],
133
228
  "jailbreak_score": ["injection"],
229
+ "keyword_categories": ["keyword"],
230
+ "keyword_count": ["keyword"],
231
+ "keyword_matched": ["keyword"],
232
+ "language_confidence": ["language"],
134
233
  "mip_label_id": ["file_metadata"],
135
234
  "mip_label_name": ["file_metadata"],
136
235
  "paste_length": ["paste_monitor"],
@@ -142,12 +241,20 @@ export const SENTRY_FIELD_TO_DETECTORS = {
142
241
  "pii_score": ["pii"],
143
242
  "pii_types": ["pii"],
144
243
  "profanity_score": ["toxicity"],
244
+ "script_confidence": ["script"],
145
245
  "secret_count": ["secrets"],
146
246
  "secret_types": ["secrets"],
147
247
  "secrets_detected": ["secrets"],
248
+ "sensitivity_level": ["file_metadata"],
249
+ "session_injection_detected": ["injection"],
250
+ "session_pii_detected": ["pii"],
251
+ "session_pii_types": ["pii"],
252
+ "session_secret_types": ["secrets"],
253
+ "session_secrets_detected": ["secrets"],
148
254
  "sexual_score": ["toxicity"],
149
255
  "target_app": ["paste_monitor"],
150
256
  "target_url": ["paste_monitor"],
257
+ "topic_confidence": ["topic"],
151
258
  "violence_score": ["toxicity"],
152
259
  "weapons_score": ["toxicity"],
153
260
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highflame/policy",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "engines": {
5
5
  "node": ">=18"
6
6
  },
@@ -1,94 +0,0 @@
1
- // =============================================================================
2
- // PII & Secrets Redaction
3
- // =============================================================================
4
- // Blocks AI Gateway operations when personally identifiable information or
5
- // secrets are detected in the content. Covers both LLM prompt processing
6
- // and MCP tool calls, plus a bulk-exposure catch-all.
7
- //
8
- // Context keys consumed:
9
- // - pii_detected: Bool
10
- // - secrets_detected: Bool
11
- // - pii_count: Long
12
- //
13
- // Compliance:
14
- // - OWASP LLM06
15
- // - GDPR, HIPAA (depending on data classification)
16
- //
17
- // Category: data-protection
18
- // Namespace: AIGateway
19
- // =============================================================================
20
-
21
- @id("data-protection.block-pii")
22
- @name("Block PII in prompts")
23
- @description("Blocks process_prompt when pii_detected is true.")
24
- @severity("high")
25
- @tags("category:data-protection,threat:pii,detection:rule,surface:process-prompt,owasp:llm06")
26
- @reject_message("Prompt blocked: personally identifiable information was detected — remove sensitive data and retry.")
27
- forbid (
28
- principal,
29
- action == AIGateway::Action::"process_prompt",
30
- resource
31
- )
32
- when {
33
- context has pii_detected && context.pii_detected == true
34
- };
35
-
36
- @id("data-protection.block-secrets")
37
- @name("Block secrets in prompts")
38
- @description("Blocks process_prompt when secrets_detected is true.")
39
- @severity("critical")
40
- @tags("category:data-protection,threat:secrets,detection:rule,surface:process-prompt")
41
- @reject_message("Prompt blocked: secrets or credentials were detected — remove sensitive data and retry.")
42
- forbid (
43
- principal,
44
- action == AIGateway::Action::"process_prompt",
45
- resource
46
- )
47
- when {
48
- context has secrets_detected && context.secrets_detected == true
49
- };
50
-
51
- @id("data-protection.block-pii-tools")
52
- @name("Block PII in tool calls")
53
- @description("Blocks call_tool when pii_detected is true.")
54
- @severity("high")
55
- @tags("category:data-protection,threat:pii,detection:rule,surface:call-tool,owasp:llm06")
56
- @reject_message("Tool execution blocked: personally identifiable information was detected in tool arguments.")
57
- forbid (
58
- principal,
59
- action == AIGateway::Action::"call_tool",
60
- resource
61
- )
62
- when {
63
- context has pii_detected && context.pii_detected == true
64
- };
65
-
66
- @id("data-protection.block-secrets-tools")
67
- @name("Block secrets in tool calls")
68
- @description("Blocks call_tool when secrets_detected is true.")
69
- @severity("critical")
70
- @tags("category:data-protection,threat:secrets,detection:rule,surface:call-tool")
71
- @reject_message("Tool execution blocked: secrets or credentials were detected in tool arguments.")
72
- forbid (
73
- principal,
74
- action == AIGateway::Action::"call_tool",
75
- resource
76
- )
77
- when {
78
- context has secrets_detected && context.secrets_detected == true
79
- };
80
-
81
- @id("data-protection.block-pii-bulk")
82
- @name("Block bulk PII exposure")
83
- @description("Blocks any action when pii_count >= 3.")
84
- @severity("critical")
85
- @tags("category:data-protection,threat:exfiltration,detection:aggregate,posture:catch-all")
86
- @reject_message("Request blocked: multiple PII matches were detected — possible data exfiltration.")
87
- forbid (
88
- principal,
89
- action,
90
- resource
91
- )
92
- when {
93
- context has pii_count && context.pii_count >= 3
94
- };
@@ -1,35 +0,0 @@
1
- // =============================================================================
2
- // Chat Assistant — Privacy
3
- // =============================================================================
4
- // PII protection for customer-facing chatbots. Blocks PII in both directions
5
- // (input + output) across prompts, tool calls, and file operations.
6
- //
7
- // Context keys consumed:
8
- // - pii_detected: Bool
9
- //
10
- // Compliance:
11
- // - GDPR Art. 32, HIPAA, PCI-DSS
12
- //
13
- // Category: privacy
14
- // Namespace: Guardrails
15
- // =============================================================================
16
-
17
- @id("privacy.chat-block-pii")
18
- @name("Block PII in chat (both directions)")
19
- @description("Blocks process_prompt, call_tool, read_file, and write_file when pii_detected is true.")
20
- @severity("high")
21
- @tags("category:privacy,threat:pii,detection:rule,compliance:gdpr,compliance:hipaa")
22
- @reject_message("Request blocked: personally identifiable information was detected.")
23
- forbid (
24
- principal,
25
- action in [
26
- Guardrails::Action::"process_prompt",
27
- Guardrails::Action::"call_tool",
28
- Guardrails::Action::"read_file",
29
- Guardrails::Action::"write_file"
30
- ],
31
- resource
32
- )
33
- when {
34
- context has pii_detected && context.pii_detected == true
35
- };
@@ -1,63 +0,0 @@
1
- // =============================================================================
2
- // Data Pipeline — Privacy
3
- // =============================================================================
4
- // Strict PII protection for RAG pipelines and data processing agents.
5
- // Zero-tolerance for sensitive PII types — data pipelines must not leak PII.
6
- //
7
- // Context keys consumed:
8
- // - pii_detected: Bool
9
- // - pii_types: Set<String>
10
- //
11
- // Compliance:
12
- // - GDPR Art. 32, HIPAA §164.312, PCI DSS 3.4
13
- //
14
- // Category: privacy
15
- // Namespace: Guardrails
16
- // =============================================================================
17
-
18
- @id("privacy.data-pipeline-block-pii")
19
- @name("Block PII in data pipeline")
20
- @description("Blocks process_prompt, call_tool, read_file, and write_file when pii_detected is true.")
21
- @severity("critical")
22
- @tags("category:privacy,threat:pii,detection:rule,compliance:gdpr,compliance:hipaa")
23
- @reject_message("Request blocked: PII detected in a data pipeline — pipelines must not process or leak personal data.")
24
- forbid (
25
- principal,
26
- action in [
27
- Guardrails::Action::"process_prompt",
28
- Guardrails::Action::"call_tool",
29
- Guardrails::Action::"read_file",
30
- Guardrails::Action::"write_file"
31
- ],
32
- resource
33
- )
34
- when {
35
- context has pii_detected && context.pii_detected == true
36
- };
37
-
38
- @id("privacy.data-pipeline-block-pii-sensitive")
39
- @name("Block sensitive PII types in data pipeline")
40
- @description("Blocks process_prompt, call_tool, read_file, and write_file when pii_types contains SSN, credit_card, passport, medical_id, or tax_id.")
41
- @severity("critical")
42
- @tags("category:privacy,threat:pii,detection:rule,compliance:gdpr,compliance:hipaa,compliance:pci-dss")
43
- @reject_message("Request blocked: highly sensitive PII (SSN, credit card, passport, medical ID, or tax ID) detected in a data pipeline.")
44
- forbid (
45
- principal,
46
- action in [
47
- Guardrails::Action::"process_prompt",
48
- Guardrails::Action::"call_tool",
49
- Guardrails::Action::"read_file",
50
- Guardrails::Action::"write_file"
51
- ],
52
- resource
53
- )
54
- when {
55
- context has pii_types &&
56
- (
57
- context.pii_types.contains("ssn") ||
58
- context.pii_types.contains("credit_card") ||
59
- context.pii_types.contains("passport") ||
60
- context.pii_types.contains("medical_id") ||
61
- context.pii_types.contains("tax_id")
62
- )
63
- };