@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
@@ -1,158 +1,164 @@
1
1
  // =============================================================================
2
- // PII Detection (Default)
2
+ // Structural PII (Tier 1)
3
3
  // =============================================================================
4
- // Blocks personally identifiable information across messages and file uploads
5
- // using multi-layered detection: detector boolean, granular PII type
6
- // matching, ML classifier confidence, threat category aggregation, and bulk
7
- // exposure thresholds.
4
+ // Blocks high-sensitivity identifiers that have a deterministic structure (SSNs, credit cards, IBANs, API keys) using fast regex pattern matching — high precision, low latency, few false positives. One forbid rule per identifier group.
8
5
  //
9
- // Paste-targeted PII rules live in clipboard.cedar.
6
+ // Sensitivity tiers and the structural (regex) / contextual (model) type
7
+ // vocabulary are defined canonically in schemas/_shared/pii_taxonomy.json and
8
+ // enforced by tools/lint-templates.
10
9
  //
11
10
  // Context keys consumed:
12
- // - pii_detected: Bool
13
- // - pii_types: Set<String>
14
- // - pii_count: Long
15
- // - pii_score: Long (0-100)
16
- // - detected_threats: Set<String>
17
- // - threat_categories: Set<String>
18
- //
19
- // Compliance:
20
- // - PCI DSS 3.4/4.1, GDPR Art. 32, HIPAA §164.312, CCPA §1798.150
11
+ // - pii_types: Set<String> (union of structural lowercase + contextual uppercase types)
21
12
  //
22
13
  // Category: privacy
23
14
  // Namespace: Sentry
24
15
  // =============================================================================
25
16
 
26
- // ---------------------------------------------------------------------------
27
- // Section 1: Primary PII detection
28
- // ---------------------------------------------------------------------------
29
-
30
- @id("privacy.block-pii")
31
- @name("Block messages and uploads with PII")
32
- @description("Blocks process_prompt and upload_file when pii_detected is true.")
33
- @severity("critical")
34
- @tags("category:privacy,threat:pii,detection:rule,compliance:gdpr,owasp:llm06")
35
- @reject_message("Content blocked: personally identifiable information detected — remove before sending to AI services.")
36
- forbid (
37
- principal,
38
- action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
39
- resource
40
- )
41
- when {
42
- context has pii_detected && context.pii_detected == true
43
- };
44
-
45
- // ---------------------------------------------------------------------------
46
- // Section 2: Granular PII type blocking
47
- // ---------------------------------------------------------------------------
48
-
49
- @id("privacy.block-credit-card")
50
- @name("Block credit card numbers")
51
- @description("Blocks process_prompt and upload_file when pii_types or detected_threats contains \"credit_card\".")
52
- @severity("critical")
53
- @tags("category:privacy,threat:pii,detection:pattern,compliance:pci-dss")
54
- @reject_message("Content blocked: credit card number patterns detected — PCI DSS prohibits raw PAN handling.")
17
+ @id("privacy.block-pii-national-id")
18
+ @name("Block national ID numbers (structural)")
19
+ @description("Blocks prompts, pastes, and file uploads that contain a national ID (SSN, passport, or driver's license).")
20
+ @severity("high")
21
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
22
+ @reject_message("Content blocked: national identifier (SSN, passport, or driver's license) patterns detected.")
55
23
  forbid (
56
24
  principal,
57
- action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
25
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
58
26
  resource
59
27
  )
60
28
  when {
61
- (context has pii_types && context.pii_types.contains("credit_card")) ||
62
- (context has detected_threats && context.detected_threats.contains("credit_card"))
29
+ context has pii_types &&
30
+ (
31
+ context.pii_types.contains("ssn") ||
32
+ context.pii_types.contains("passport") ||
33
+ context.pii_types.contains("national_id") ||
34
+ context.pii_types.contains("drivers_license")
35
+ )
63
36
  };
64
37
 
65
- @id("privacy.block-ssn")
66
- @name("Block Social Security Numbers")
67
- @description("Blocks process_prompt and upload_file when pii_types or detected_threats contains \"ssn\".")
38
+ @id("privacy.block-pii-credit-card")
39
+ @name("Block credit card numbers (structural)")
40
+ @description("Blocks prompts, pastes, and file uploads that contain a credit card number.")
68
41
  @severity("critical")
69
- @tags("category:privacy,threat:pii,detection:pattern,compliance:gdpr")
70
- @reject_message("Content blocked: Social Security Number patterns detected.")
42
+ @tags("category:privacy,threat:pii,detection:pattern,compliance:pci-dss,owasp:llm06")
43
+ @reject_message("Content blocked: credit card number patterns detected.")
71
44
  forbid (
72
45
  principal,
73
- action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
46
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
74
47
  resource
75
48
  )
76
49
  when {
77
- (context has pii_types && context.pii_types.contains("ssn")) ||
78
- (context has detected_threats && context.detected_threats.contains("ssn"))
50
+ context has pii_types && context.pii_types.contains("credit_card")
79
51
  };
80
52
 
81
- @id("privacy.block-passport")
82
- @name("Block passport numbers")
83
- @description("Blocks process_prompt and upload_file when pii_types contains \"passport\".")
53
+ @id("privacy.block-pii-bank-account")
54
+ @name("Block bank account numbers (structural)")
55
+ @description("Blocks prompts, pastes, and file uploads that contain a bank account number (IBAN, SWIFT/BIC, or routing number).")
84
56
  @severity("critical")
85
- @tags("category:privacy,threat:pii,detection:pattern,compliance:gdpr")
86
- @reject_message("Content blocked: passport number patterns detected.")
57
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
58
+ @reject_message("Content blocked: bank account (IBAN) number patterns detected.")
87
59
  forbid (
88
60
  principal,
89
- action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
61
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
90
62
  resource
91
63
  )
92
64
  when {
93
- context has pii_types && context.pii_types.contains("passport")
65
+ context has pii_types &&
66
+ (
67
+ context.pii_types.contains("iban") ||
68
+ context.pii_types.contains("bank_account") ||
69
+ context.pii_types.contains("swift_bic") ||
70
+ context.pii_types.contains("aba_routing")
71
+ )
94
72
  };
95
73
 
96
- @id("privacy.block-iban")
97
- @name("Block bank account numbers")
98
- @description("Blocks process_prompt and upload_file when pii_types contains \"iban\".")
99
- @severity("critical")
100
- @tags("category:privacy,threat:pii,detection:pattern,compliance:gdpr,compliance:pci-dss")
101
- @reject_message("Content blocked: bank account number (IBAN) patterns detected.")
74
+ @id("privacy.block-pii-medical")
75
+ @name("Block medical identifiers (structural)")
76
+ @description("Blocks prompts, pastes, and file uploads that contain medical data (record number, MBI, NPI, or blood type).")
77
+ @severity("medium")
78
+ @tags("category:privacy,threat:pii,detection:pattern,compliance:hipaa,owasp:llm06")
79
+ @reject_message("Content blocked: medical record identifier patterns detected.")
102
80
  forbid (
103
81
  principal,
104
- action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
82
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
105
83
  resource
106
84
  )
107
85
  when {
108
- context has pii_types && context.pii_types.contains("iban")
86
+ context has pii_types &&
87
+ (
88
+ context.pii_types.contains("medical_record") ||
89
+ context.pii_types.contains("patient_record") ||
90
+ context.pii_types.contains("medicare_beneficiary_id") ||
91
+ context.pii_types.contains("npi") ||
92
+ context.pii_types.contains("medical_term") ||
93
+ context.pii_types.contains("blood_type")
94
+ )
109
95
  };
110
96
 
111
- @id("privacy.block-pii-bulk")
112
- @name("Block bulk PII exposure")
113
- @description("Blocks process_prompt and upload_file when pii_count >= 3.")
114
- @severity("critical")
115
- @tags("category:privacy,threat:pii,threat:exfiltration,detection:aggregate,compliance:gdpr")
116
- @reject_message("Content blocked: 3+ PII items detected bulk personal data must not be shared with AI services.")
97
+ @id("privacy.block-pii-tax-id")
98
+ @name("Block tax identifiers (structural)")
99
+ @description("Blocks prompts, pastes, and file uploads that contain a tax ID (ITIN, EIN, or PTIN).")
100
+ @severity("high")
101
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
102
+ @reject_message("Content blocked: tax identifier (ITIN or EIN) patterns detected.")
117
103
  forbid (
118
104
  principal,
119
- action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
105
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
120
106
  resource
121
107
  )
122
108
  when {
123
- context has pii_count && context.pii_count >= 3
109
+ context has pii_types &&
110
+ (
111
+ context.pii_types.contains("itin") ||
112
+ context.pii_types.contains("ein") ||
113
+ context.pii_types.contains("ptin")
114
+ )
124
115
  };
125
116
 
126
- // ---------------------------------------------------------------------------
127
- // Section 3: ML classifier and aggregation
128
- // ---------------------------------------------------------------------------
129
-
130
- @id("privacy.block-pii-ml")
131
- @name("Block high-confidence PII (ML)")
132
- @description("Blocks process_prompt and upload_file when pii_score >= 80.")
117
+ @id("privacy.block-pii-credential")
118
+ @name("Block credentials (structural)")
119
+ @description("Blocks prompts, pastes, and file uploads that contain a credential or secret (API key, token, password hash, or private key).")
133
120
  @severity("critical")
134
- @tags("category:privacy,threat:pii,detection:ml,compliance:gdpr,compliance:hipaa")
135
- @reject_message("Content blocked: the ML classifier detected personally identifiable information with high confidence.")
121
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
122
+ @reject_message("Content blocked: credential or API key patterns detected.")
136
123
  forbid (
137
124
  principal,
138
- action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
125
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
139
126
  resource
140
127
  )
141
128
  when {
142
- context has pii_score && context.pii_score >= 80
129
+ context has pii_types &&
130
+ (
131
+ context.pii_types.contains("aws_access_key") ||
132
+ context.pii_types.contains("api_key") ||
133
+ context.pii_types.contains("jwt_token") ||
134
+ context.pii_types.contains("encryption_key") ||
135
+ context.pii_types.contains("http_basic_auth") ||
136
+ context.pii_types.contains("gcp_credential") ||
137
+ context.pii_types.contains("gcp_api_key") ||
138
+ context.pii_types.contains("gcp_signed_policy") ||
139
+ context.pii_types.contains("session_cookie") ||
140
+ context.pii_types.contains("oauth_token") ||
141
+ context.pii_types.contains("tls_certificate") ||
142
+ context.pii_types.contains("password_hash") ||
143
+ context.pii_types.contains("csrf_token")
144
+ )
143
145
  };
144
146
 
145
- @id("privacy.block-pii-category")
146
- @name("Block PII threat category")
147
- @description("Blocks process_prompt and upload_file when threat_categories contains \"pii\".")
147
+ @id("privacy.block-pii-crypto")
148
+ @name("Block cryptocurrency addresses (structural)")
149
+ @description("Blocks prompts, pastes, and file uploads that contain a cryptocurrency wallet address.")
148
150
  @severity("high")
149
- @tags("category:privacy,threat:pii,detection:aggregate,compliance:gdpr")
150
- @reject_message("Content blocked: threat scanners aggregated a PII threat category.")
151
+ @tags("category:privacy,threat:pii,detection:pattern,owasp:llm06")
152
+ @reject_message("Content blocked: cryptocurrency wallet address patterns detected.")
151
153
  forbid (
152
154
  principal,
153
- action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
155
+ action in [Sentry::Action::"process_prompt", Sentry::Action::"paste_content", Sentry::Action::"upload_file"],
154
156
  resource
155
157
  )
156
158
  when {
157
- context has threat_categories && context.threat_categories.contains("pii")
159
+ context has pii_types &&
160
+ (
161
+ context.pii_types.contains("bitcoin_address") ||
162
+ context.pii_types.contains("ethereum_address")
163
+ )
158
164
  };