@highflame/policy 2.1.35 → 2.1.37

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 (81) hide show
  1. package/_schemas/ai_gateway/context.json +431 -11
  2. package/_schemas/ai_gateway/schema.cedarschema +91 -11
  3. package/_schemas/ai_gateway/templates/defaults/agent_security.cedar +66 -43
  4. package/_schemas/ai_gateway/templates/defaults/baseline.cedar +9 -11
  5. package/_schemas/ai_gateway/templates/defaults/semantic.cedar +63 -40
  6. package/_schemas/ai_gateway/templates/defaults/tools.cedar +48 -36
  7. package/_schemas/ai_gateway/templates/llm_default_allow.cedar +9 -10
  8. package/_schemas/ai_gateway/templates/mcp_server_allowlist.cedar +22 -14
  9. package/_schemas/ai_gateway/templates/mcp_tool_permissions.cedar +29 -27
  10. package/_schemas/ai_gateway/templates/pii_redaction.cedar +38 -33
  11. package/_schemas/ai_gateway/templates/templates.json +52 -50
  12. package/_schemas/guardrails/context.json +12 -12
  13. package/_schemas/guardrails/schema.cedarschema +12 -12
  14. package/_schemas/guardrails/templates/defaults/agent_identity.cedar +60 -56
  15. package/_schemas/guardrails/templates/defaults/agentic_safety.cedar +83 -58
  16. package/_schemas/guardrails/templates/defaults/baseline.cedar +9 -12
  17. package/_schemas/guardrails/templates/defaults/injection.cedar +48 -36
  18. package/_schemas/guardrails/templates/defaults/pii.cedar +27 -20
  19. package/_schemas/guardrails/templates/defaults/secrets.cedar +39 -22
  20. package/_schemas/guardrails/templates/defaults/security_patterns.cedar +38 -25
  21. package/_schemas/guardrails/templates/defaults/semantic.cedar +47 -31
  22. package/_schemas/guardrails/templates/defaults/tool_risk.cedar +34 -26
  23. package/_schemas/guardrails/templates/defaults/toxicity.cedar +57 -47
  24. package/_schemas/guardrails/templates/mcp_tool_permissions.cedar +60 -43
  25. package/_schemas/guardrails/templates/profiles/a2a_security/cross_origin.cedar +29 -42
  26. package/_schemas/guardrails/templates/profiles/a2a_security/escalation_detection.cedar +43 -57
  27. package/_schemas/guardrails/templates/profiles/a2a_security/identity_enforcement.cedar +40 -57
  28. package/_schemas/guardrails/templates/profiles/a2a_security/inter_agent_injection.cedar +48 -62
  29. package/_schemas/guardrails/templates/profiles/a2a_security/supply_chain.cedar +40 -56
  30. package/_schemas/guardrails/templates/profiles/advanced_detection/pii.cedar +24 -34
  31. package/_schemas/guardrails/templates/profiles/advanced_detection/secrets.cedar +45 -37
  32. package/_schemas/guardrails/templates/profiles/advanced_detection/threat_severity.cedar +11 -16
  33. package/_schemas/guardrails/templates/profiles/chat_assistant/privacy.cedar +22 -9
  34. package/_schemas/guardrails/templates/profiles/chat_assistant/security.cedar +27 -15
  35. package/_schemas/guardrails/templates/profiles/chat_assistant/trust_safety.cedar +37 -22
  36. package/_schemas/guardrails/templates/profiles/code_agent/agentic_security.cedar +68 -47
  37. package/_schemas/guardrails/templates/profiles/code_agent/encoding.cedar +17 -21
  38. package/_schemas/guardrails/templates/profiles/code_agent/path_security.cedar +74 -73
  39. package/_schemas/guardrails/templates/profiles/code_agent/security.cedar +13 -9
  40. package/_schemas/guardrails/templates/profiles/code_agent/supply_chain.cedar +36 -58
  41. package/_schemas/guardrails/templates/profiles/data_pipeline/agentic_security.cedar +22 -15
  42. package/_schemas/guardrails/templates/profiles/data_pipeline/data_protection.cedar +52 -0
  43. package/_schemas/guardrails/templates/profiles/data_pipeline/privacy.cedar +41 -18
  44. package/_schemas/guardrails/templates/profiles/data_pipeline/security.cedar +18 -36
  45. package/_schemas/guardrails/templates/profiles/multi_agent/agent_safety.cedar +86 -79
  46. package/_schemas/guardrails/templates/profiles/multi_agent/agent_trust.cedar +73 -70
  47. package/_schemas/guardrails/templates/templates.json +198 -217
  48. package/_schemas/overwatch/context.json +14 -14
  49. package/_schemas/overwatch/schema.cedarschema +12 -12
  50. package/_schemas/sentry/context.json +11 -11
  51. package/_schemas/sentry/schema.cedarschema +11 -11
  52. package/_schemas/sentry/templates/defaults/baseline.cedar +8 -12
  53. package/_schemas/sentry/templates/defaults/clipboard.cedar +43 -42
  54. package/_schemas/sentry/templates/defaults/content_safety.cedar +38 -68
  55. package/_schemas/sentry/templates/defaults/file_safety.cedar +18 -26
  56. package/_schemas/sentry/templates/defaults/organization.cedar +10 -17
  57. package/_schemas/sentry/templates/defaults/pii.cedar +52 -73
  58. package/_schemas/sentry/templates/defaults/secrets.cedar +65 -58
  59. package/_schemas/sentry/templates/defaults/semantic.cedar +40 -59
  60. package/_schemas/sentry/templates/templates.json +53 -43
  61. package/dist/ai_gateway-context.gen.d.ts +18 -4
  62. package/dist/ai_gateway-context.gen.js +18 -4
  63. package/dist/ai_gateway-defaults.gen.d.ts +4 -1
  64. package/dist/ai_gateway-defaults.gen.js +398 -320
  65. package/dist/builder.d.ts +2 -1
  66. package/dist/builder.js +5 -2
  67. package/dist/guardrails-context.gen.d.ts +5 -5
  68. package/dist/guardrails-context.gen.js +5 -5
  69. package/dist/guardrails-defaults.gen.d.ts +4 -1
  70. package/dist/guardrails-defaults.gen.js +2130 -1903
  71. package/dist/overwatch-context.gen.d.ts +5 -5
  72. package/dist/overwatch-context.gen.js +5 -5
  73. package/dist/overwatch-defaults.gen.d.ts +4 -1
  74. package/dist/overwatch-defaults.gen.js +560 -566
  75. package/dist/sentry-context.gen.d.ts +3 -3
  76. package/dist/sentry-context.gen.js +3 -3
  77. package/dist/sentry-defaults.gen.d.ts +4 -1
  78. package/dist/sentry-defaults.gen.js +392 -453
  79. package/dist/service-schemas.gen.d.ts +4 -4
  80. package/dist/service-schemas.gen.js +249 -99
  81. package/package.json +1 -1
@@ -1,38 +1,32 @@
1
1
  // =============================================================================
2
- // Content Safety Policy (Default)
2
+ // Content Safety (Default)
3
3
  // =============================================================================
4
- // Detects and blocks violent, harmful, hateful, sexual, and profane content
5
- // in AI chat interactions across messages and file uploads.
4
+ // Blocks violent, harmful, hateful, sexual, and profane content across
5
+ // messages and file uploads. Paste-targeted content rules live in
6
+ // clipboard.cedar.
6
7
  //
7
- // Paste-specific content safety rules live in clipboard.cedar — see
8
- // "Clipboard Policy".
8
+ // Thresholds:
9
+ // - violence, weapons, sexual, crime: >= 80 (critical/high)
10
+ // - hate_speech: >= 75 (lower threshold, zero tolerance)
11
+ // - profanity: >= 90 (higher threshold, allows normal expression)
9
12
  //
10
- // The detection engine runs ML classifiers (toxicity, content safety) and
11
- // produces normalized scores (0-100) for each category.
13
+ // Context keys consumed:
14
+ // - violence_score, weapons_score, hate_speech_score: Long (0-100)
15
+ // - crime_score, sexual_score, profanity_score: Long (0-100)
12
16
  //
13
17
  // Compliance:
14
- // NIST 800-53 SI-4 (Information System Monitoring)
15
- // EU AI Act Art. 52 (Transparency for AI Systems)
16
- // OWASP LLM02 (Insecure Output Handling)
17
- // ISO 42001 (AI Management System)
18
+ // - NIST 800-53 SI-4; EU AI Act Art. 52; ISO 42001; OWASP LLM02
18
19
  //
19
- // Category: content_safety
20
+ // Category: trust-safety
20
21
  // Namespace: Sentry
21
22
  // =============================================================================
22
23
 
23
- // ---------------------------------------------------------------------------
24
- // Section 1: Violence & Weapons
25
- // Blocks content promoting, describing, or instructing violence and weapons.
26
- // Applies to messages and file uploads.
27
- // ---------------------------------------------------------------------------
28
-
29
- // Block violent content across all input channels
30
- @id("sentry-cs-block-violence")
24
+ @id("trust-safety.block-violence")
31
25
  @name("Block violent content")
32
- @description("Block content when the ML violence detection score exceeds threshold (80/100). Catches graphic violence descriptions, instructions for causing harm, and violent threat language in messages and uploads.")
26
+ @description("Blocks process_prompt and upload_file when violence_score >= 80.")
33
27
  @severity("critical")
34
- @tags("violence,content-safety,trust-safety,nist-si-4,iso-42001")
35
- @reject_message("Content blocked: violent content detected. AI services must not process violent content in enterprise environments. Please rephrase without violence-related language.")
28
+ @tags("category:trust-safety,threat:violence,detection:ml,compliance:nist-si-4,compliance:iso-42001")
29
+ @reject_message("Content blocked: violent content detected.")
36
30
  forbid (
37
31
  principal,
38
32
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -42,13 +36,12 @@ when {
42
36
  context has violence_score && context.violence_score >= 80
43
37
  };
44
38
 
45
- // Block weapons content
46
- @id("sentry-cs-block-weapons")
39
+ @id("trust-safety.block-weapons")
47
40
  @name("Block weapons content")
48
- @description("Block content when the ML weapons detection score exceeds threshold (80/100). Catches weapon manufacturing instructions, procurement guidance, and detailed specifications.")
41
+ @description("Blocks process_prompt and upload_file when weapons_score >= 80.")
49
42
  @severity("critical")
50
- @tags("weapons,content-safety,trust-safety,nist-si-4")
51
- @reject_message("Content blocked: weapons-related content detected. AI services must not process weapons manufacturing, procurement, or specification content.")
43
+ @tags("category:trust-safety,threat:weapons,detection:ml,compliance:nist-si-4")
44
+ @reject_message("Content blocked: weapons-related content detected.")
52
45
  forbid (
53
46
  principal,
54
47
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -58,18 +51,12 @@ when {
58
51
  context has weapons_score && context.weapons_score >= 80
59
52
  };
60
53
 
61
- // ---------------------------------------------------------------------------
62
- // Section 2: Hate Speech & Discrimination
63
- // Lower threshold (75) — enterprises have zero tolerance for hate speech.
64
- // ---------------------------------------------------------------------------
65
-
66
- // Block hate speech content
67
- @id("sentry-cs-block-hate-speech")
54
+ @id("trust-safety.block-hate-speech")
68
55
  @name("Block hate speech")
69
- @description("Block content when the ML hate speech score exceeds threshold (75/100). Lower threshold than other categories because enterprises have zero tolerance for discriminatory content. Catches slurs, dehumanizing language, and targeted harassment.")
56
+ @description("Blocks process_prompt and upload_file when hate_speech_score >= 75.")
70
57
  @severity("critical")
71
- @tags("hate-speech,content-safety,trust-safety,nist-si-4,eu-ai-act")
72
- @reject_message("Content blocked: hate speech or discriminatory content detected. AI services must not process hateful, discriminatory, or dehumanizing content.")
58
+ @tags("category:trust-safety,threat:hate-speech,detection:ml,compliance:nist-si-4,compliance:eu-ai-act")
59
+ @reject_message("Content blocked: hate speech or discriminatory content detected.")
73
60
  forbid (
74
61
  principal,
75
62
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -79,17 +66,12 @@ when {
79
66
  context has hate_speech_score && context.hate_speech_score >= 75
80
67
  };
81
68
 
82
- // ---------------------------------------------------------------------------
83
- // Section 3: Criminal Content
84
- // ---------------------------------------------------------------------------
85
-
86
- // Block criminal content
87
- @id("sentry-cs-block-crime")
69
+ @id("trust-safety.block-crime")
88
70
  @name("Block criminal content")
89
- @description("Block content when the ML criminal activity detection score exceeds threshold (80/100). Catches illegal activity instructions, fraud techniques, and criminal behavior content.")
71
+ @description("Blocks process_prompt and upload_file when crime_score >= 80.")
90
72
  @severity("high")
91
- @tags("crime,content-safety,trust-safety,nist-si-4")
92
- @reject_message("Content blocked: criminal activity content detected. AI services must not process content related to illegal activities or fraud.")
73
+ @tags("category:trust-safety,threat:crime,detection:ml,compliance:nist-si-4")
74
+ @reject_message("Content blocked: criminal activity content detected.")
93
75
  forbid (
94
76
  principal,
95
77
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -99,17 +81,12 @@ when {
99
81
  context has crime_score && context.crime_score >= 80
100
82
  };
101
83
 
102
- // ---------------------------------------------------------------------------
103
- // Section 4: Sexual Content
104
- // ---------------------------------------------------------------------------
105
-
106
- // Block sexual content
107
- @id("sentry-cs-block-sexual")
84
+ @id("trust-safety.block-sexual")
108
85
  @name("Block sexual content")
109
- @description("Block content when the ML sexual content score exceeds threshold (80/100). Ensures AI services do not process sexually explicit material in enterprise environments.")
86
+ @description("Blocks process_prompt and upload_file when sexual_score >= 80.")
110
87
  @severity("high")
111
- @tags("sexual,content-safety,trust-safety,eu-ai-act,iso-42001")
112
- @reject_message("Content blocked: sexual content detected. AI services must not process sexually explicit material in enterprise environments.")
88
+ @tags("category:trust-safety,threat:sexual,detection:ml,compliance:eu-ai-act,compliance:iso-42001")
89
+ @reject_message("Content blocked: sexually explicit content detected.")
113
90
  forbid (
114
91
  principal,
115
92
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -119,18 +96,12 @@ when {
119
96
  context has sexual_score && context.sexual_score >= 80
120
97
  };
121
98
 
122
- // ---------------------------------------------------------------------------
123
- // Section 5: Profanity
124
- // Higher threshold (90) allows normal expression while blocking abuse.
125
- // ---------------------------------------------------------------------------
126
-
127
- // Block excessive profanity
128
- @id("sentry-cs-block-profanity")
129
- @name("Block profanity")
130
- @description("Block content when the ML profanity detection score exceeds threshold (90/100). Higher threshold allows normal expression while blocking abusive or harassing language patterns.")
99
+ @id("trust-safety.block-profanity")
100
+ @name("Block excessive profanity")
101
+ @description("Blocks process_prompt when profanity_score >= 90.")
131
102
  @severity("medium")
132
- @tags("profanity,content-safety,trust-safety")
133
- @reject_message("Content blocked: excessive profanity detected. Please rephrase in a professional manner.")
103
+ @tags("category:trust-safety,threat:profanity,detection:ml,surface:process-prompt")
104
+ @reject_message("Content blocked: excessive profanity detected please rephrase in professional language.")
134
105
  forbid (
135
106
  principal,
136
107
  action == Sentry::Action::"process_prompt",
@@ -139,4 +110,3 @@ forbid (
139
110
  when {
140
111
  context has profanity_score && context.profanity_score >= 90
141
112
  };
142
-
@@ -1,54 +1,46 @@
1
1
  // =============================================================================
2
- // File & Attachment Safety Policy (Default)
2
+ // File & Attachment Safety (Default)
3
3
  // =============================================================================
4
4
  // Blocks file uploads to AI chat services when document content contains
5
5
  // secrets or PII.
6
6
  //
7
- // Detection layers:
8
- // 1. Secrets in file content — from Shield SecretsDetector
9
- // 2. PII in file content — from Shield PIIRegexDetector
7
+ // Context keys consumed:
8
+ // - secrets_detected: Bool
9
+ // - pii_detected: Bool
10
10
  //
11
11
  // Compliance:
12
- // NIST 800-53 SC-28 (Protection of Information at Rest)
13
- // GDPR Art. 32 (Security of Processing)
12
+ // - NIST 800-53 SC-28; GDPR Art. 32
14
13
  //
15
- // Category: file_safety
14
+ // Category: file-safety
16
15
  // Namespace: Sentry
17
16
  // =============================================================================
18
17
 
19
- // ---------------------------------------------------------------------------
20
- // Section 1: File Content Security
21
- // Block text files containing secrets or PII.
22
- // ---------------------------------------------------------------------------
23
-
24
- // Block text files with secrets
25
- @id("sentry-file-block-secrets")
26
- @name("Block text files with secrets")
27
- @description("Block file uploads when secrets or credentials are detected in document content. Prevents uploading configuration files, code, or documents containing API keys, tokens, or passwords to AI services.")
18
+ @id("file-safety.block-upload-secrets")
19
+ @name("Block file uploads with secrets")
20
+ @description("Blocks upload_file when secrets_detected is true.")
28
21
  @severity("critical")
29
- @tags("secrets,file-upload,credentials,nist-sc-28")
30
- @reject_message("Upload blocked: secrets or credentials detected in the file. Files containing API keys, tokens, or passwords must not be shared with AI services.")
22
+ @tags("category:file-safety,threat:secrets,detection:rule,surface:upload-file,owasp:llm06")
23
+ @reject_message("File upload blocked: secrets or credentials detected in document content.")
31
24
  forbid (
32
25
  principal,
33
26
  action == Sentry::Action::"upload_file",
34
27
  resource
35
28
  )
36
29
  when {
37
- context has contains_secrets && context.contains_secrets
30
+ context has secrets_detected && context.secrets_detected == true
38
31
  };
39
32
 
40
- // Block text files with PII
41
- @id("sentry-pii-block-uploads")
42
- @name("Block text files with PII")
43
- @description("Block file uploads when PII is detected in document content. Prevents sharing of documents containing personal data (customer lists, HR records, medical files) with AI services.")
33
+ @id("file-safety.block-upload-pii")
34
+ @name("Block file uploads with PII")
35
+ @description("Blocks upload_file when pii_detected is true.")
44
36
  @severity("critical")
45
- @tags("pii,file-upload,data-protection,gdpr-art-32")
46
- @reject_message("File upload blocked: personally identifiable information detected in the document. Files containing PII must not be shared with AI services.")
37
+ @tags("category:file-safety,threat:pii,detection:rule,surface:upload-file,compliance:gdpr")
38
+ @reject_message("File upload blocked: personally identifiable information detected in document content.")
47
39
  forbid (
48
40
  principal,
49
41
  action == Sentry::Action::"upload_file",
50
42
  resource
51
43
  )
52
44
  when {
53
- context has pii_detected && context.pii_detected
45
+ context has pii_detected && context.pii_detected == true
54
46
  };
@@ -1,29 +1,22 @@
1
1
  // =============================================================================
2
- // Organization Rules Policy (Default)
2
+ // Organization Rules (Default)
3
3
  // =============================================================================
4
4
  // Cross-cutting organization-wide rules that don't fit other categories.
5
- // Secret/credential rules live in secrets.cedar; paste/clipboard rules live
6
- // in clipboard.cedar.
5
+ // Currently: session-aware threat escalation circuit breaker.
7
6
  //
8
- // This template covers:
9
- // - Session-aware threat escalation
7
+ // Context keys consumed:
8
+ // - session_threat_turns: Long
10
9
  //
11
- // Category: organization
10
+ // Category: organization
12
11
  // Namespace: Sentry
13
12
  // =============================================================================
14
13
 
15
- // ---------------------------------------------------------------------------
16
- // Section 1: Session-Aware Escalation
17
- // Escalate protections when threats are detected across the session.
18
- // ---------------------------------------------------------------------------
19
-
20
- // Block all actions after repeated threat detection
21
- @id("sentry-org-session-threat-escalation")
22
- @name("Escalate after repeated threats")
23
- @description("Block all actions when threats have been detected in 3+ turns of the session. Repeated threat detections indicate either a persistent attacker or a compromised data source requiring investigation.")
14
+ @id("organization.block-session-threat-escalation")
15
+ @name("Block session after repeated threats")
16
+ @description("Blocks all actions when session_threat_turns >= 3.")
24
17
  @severity("high")
25
- @tags("session,escalation,behavioral,defense-in-depth")
26
- @reject_message("Session blocked: security threats have been detected in multiple turns of this conversation. This session has been flagged for review. Please start a new session or contact your security team.")
18
+ @tags("category:organization,detection:aggregate,posture:catch-all,scope:org-wide")
19
+ @reject_message("Request blocked: 3+ threat turns in this session the session has been flagged; please start a new session or contact your security team.")
27
20
  forbid (
28
21
  principal,
29
22
  action,
@@ -1,65 +1,57 @@
1
1
  // =============================================================================
2
- // PII Detection Policy (Default)
2
+ // PII Detection (Default)
3
3
  // =============================================================================
4
- // Detects and blocks personally identifiable information across messages
5
- // and file uploads. Uses multi-layered detection:
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.
6
8
  //
7
9
  // Paste-targeted PII rules live in clipboard.cedar.
8
10
  //
9
- // 1. PII boolean flag (pii_detected) — broadest catch from detection engine
10
- // 2. Granular PII type matching (pii_types) — type-specific blocking
11
- // 3. PII confidence score (pii_confidence) — ML classifier confidence
12
- // 4. Detection rule triggers (detected_threats) — named rule matches
13
- // 5. Bulk PII exposure (pii_count) — data dump prevention
14
- //
15
- // PII Types Detected by Shield PIIRegexDetector:
16
- // ssn, credit_card, email, phone_us, ip_address, date_of_birth,
17
- // passport, iban, aws_key, api_key_generic
11
+ // 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
18
  //
19
19
  // Compliance:
20
- // PCI DSS 3.4, 4.1 (Payment Card Data)
21
- // GDPR Art. 32 (Security of Processing)
22
- // HIPAA §164.312 (Technical Safeguards)
23
- // CCPA §1798.150 (Data Protection)
24
- // OWASP LLM06 (Sensitive Information Disclosure)
20
+ // - PCI DSS 3.4/4.1, GDPR Art. 32, HIPAA §164.312, CCPA §1798.150
25
21
  //
26
- // Category: pii
22
+ // Category: privacy
27
23
  // Namespace: Sentry
28
24
  // =============================================================================
29
25
 
30
26
  // ---------------------------------------------------------------------------
31
- // Section 1: Primary PII Detection
32
- // Fires when the detection pipeline identifies PII in any content.
27
+ // Section 1: Primary PII detection
33
28
  // ---------------------------------------------------------------------------
34
29
 
35
- // Block messages and uploads containing detected PII
36
- @id("sentry-pii-block-messages")
30
+ @id("privacy.block-pii")
37
31
  @name("Block messages and uploads with PII")
38
- @description("Block messages and file uploads when the detection engine identifies any PII patterns. Prevents employees from accidentally sharing personal data with AI chat services.")
32
+ @description("Blocks process_prompt and upload_file when pii_detected is true.")
39
33
  @severity("critical")
40
- @tags("pii,privacy,data-protection,gdpr-art-32,owasp-llm06")
41
- @reject_message("Content blocked: personally identifiable information was detected. Remove all PII (names, addresses, SSNs, credit cards, etc.) before sending to AI services.")
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.")
42
36
  forbid (
43
37
  principal,
44
38
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
45
39
  resource
46
40
  )
47
41
  when {
48
- context has pii_detected && context.pii_detected
42
+ context has pii_detected && context.pii_detected == true
49
43
  };
50
44
 
51
45
  // ---------------------------------------------------------------------------
52
- // Section 2: Granular PII Type Blocking
53
- // Blocks specific PII types based on regulatory requirements.
46
+ // Section 2: Granular PII type blocking
54
47
  // ---------------------------------------------------------------------------
55
48
 
56
- // Block credit card numbers (PCI DSS compliance)
57
- @id("sentry-pii-block-credit-cards")
49
+ @id("privacy.block-credit-card")
58
50
  @name("Block credit card numbers")
59
- @description("Block messages and file uploads containing credit card number patterns. PCI DSS 3.4 requires PANs are rendered unreadable — AI services must never receive raw card numbers.")
51
+ @description("Blocks process_prompt and upload_file when pii_types or detected_threats contains \"credit_card\".")
60
52
  @severity("critical")
61
- @tags("pci,credit-card,payment,compliance,pci-dss-3.4")
62
- @reject_message("Content blocked: credit card number patterns detected. Sharing payment card data with AI services violates PCI DSS. Use tokenized references instead.")
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.")
63
55
  forbid (
64
56
  principal,
65
57
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -70,13 +62,12 @@ when {
70
62
  (context has detected_threats && context.detected_threats.contains("credit_card"))
71
63
  };
72
64
 
73
- // Block Social Security Numbers
74
- @id("sentry-pii-block-ssn")
65
+ @id("privacy.block-ssn")
75
66
  @name("Block Social Security Numbers")
76
- @description("Block messages and file uploads containing SSN patterns (XXX-XX-XXXX and variants). SSNs are high-value identity theft targets — exposure through AI services is a critical privacy violation.")
67
+ @description("Blocks process_prompt and upload_file when pii_types or detected_threats contains \"ssn\".")
77
68
  @severity("critical")
78
- @tags("ssn,identity,privacy,compliance,nist-si-4")
79
- @reject_message("Content blocked: Social Security Number patterns detected. SSNs must never be shared with AI services.")
69
+ @tags("category:privacy,threat:pii,detection:pattern,compliance:gdpr")
70
+ @reject_message("Content blocked: Social Security Number patterns detected.")
80
71
  forbid (
81
72
  principal,
82
73
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -87,13 +78,12 @@ when {
87
78
  (context has detected_threats && context.detected_threats.contains("ssn"))
88
79
  };
89
80
 
90
- // Block passport numbers
91
- @id("sentry-pii-block-passport")
81
+ @id("privacy.block-passport")
92
82
  @name("Block passport numbers")
93
- @description("Block messages and file uploads containing passport number patterns. Passport numbers are government-issued identifiers with high identity theft risk.")
83
+ @description("Blocks process_prompt and upload_file when pii_types contains \"passport\".")
94
84
  @severity("critical")
95
- @tags("passport,identity,privacy,gdpr")
96
- @reject_message("Content blocked: passport number patterns detected. Government-issued identifiers must not be shared with AI services.")
85
+ @tags("category:privacy,threat:pii,detection:pattern,compliance:gdpr")
86
+ @reject_message("Content blocked: passport number patterns detected.")
97
87
  forbid (
98
88
  principal,
99
89
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -103,13 +93,12 @@ when {
103
93
  context has pii_types && context.pii_types.contains("passport")
104
94
  };
105
95
 
106
- // Block IBAN (International Bank Account Numbers)
107
- @id("sentry-pii-block-iban")
96
+ @id("privacy.block-iban")
108
97
  @name("Block bank account numbers")
109
- @description("Block messages and file uploads containing IBAN patterns. Bank account numbers are sensitive financial identifiers that must not be exposed to AI services.")
98
+ @description("Blocks process_prompt and upload_file when pii_types contains \"iban\".")
110
99
  @severity("critical")
111
- @tags("iban,financial,privacy,gdpr,pci-dss")
112
- @reject_message("Content blocked: bank account number (IBAN) patterns detected. Financial account numbers must not be shared with AI services.")
100
+ @tags("category:privacy,threat:pii,detection:pattern,compliance:gdpr,compliance:pci-dss")
101
+ @reject_message("Content blocked: bank account number (IBAN) patterns detected.")
113
102
  forbid (
114
103
  principal,
115
104
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -119,13 +108,12 @@ when {
119
108
  context has pii_types && context.pii_types.contains("iban")
120
109
  };
121
110
 
122
- // Block bulk PII exposure
123
- @id("sentry-pii-block-bulk-exposure")
111
+ @id("privacy.block-pii-bulk")
124
112
  @name("Block bulk PII exposure")
125
- @description("Block messages and file uploads containing 3 or more PII matches. Multiple PII items indicate a data dump — customer lists, CSV exports, or database content being leaked to AI services.")
113
+ @description("Blocks process_prompt and upload_file when pii_count >= 3.")
126
114
  @severity("critical")
127
- @tags("pii,bulk,data-exfiltration,gdpr-art-32,ccpa")
128
- @reject_message("Content blocked: multiple PII items detected (3+). Bulk personal data must never be shared with AI services. Use data masking or tokenization.")
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.")
129
117
  forbid (
130
118
  principal,
131
119
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -136,38 +124,30 @@ when {
136
124
  };
137
125
 
138
126
  // ---------------------------------------------------------------------------
139
- // Section 3: PII Confidence Detection
140
- // Catches PII patterns via ML classifier that escape regex detection.
127
+ // Section 3: ML classifier and aggregation
141
128
  // ---------------------------------------------------------------------------
142
129
 
143
- // Block high-confidence PII
144
- @id("sentry-pii-block-high-confidence")
145
- @name("Block high-confidence PII")
146
- @description("Block messages and file uploads when the PII confidence score exceeds threshold (80/100). Catches novel PII patterns including names, addresses, and identifiers that regex rules may miss.")
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.")
147
133
  @severity("critical")
148
- @tags("pii,confidence,privacy,compliance,ml-classifier")
149
- @reject_message("Content blocked: the ML classifier detected personally identifiable information with high confidence. The content appears to contain personal data.")
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.")
150
136
  forbid (
151
137
  principal,
152
138
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
153
139
  resource
154
140
  )
155
141
  when {
156
- context has pii_confidence && context.pii_confidence >= 80
142
+ context has pii_score && context.pii_score >= 80
157
143
  };
158
144
 
159
- // ---------------------------------------------------------------------------
160
- // Section 4: PII Threat Category
161
- // Defense-in-depth via threat aggregation layer.
162
- // ---------------------------------------------------------------------------
163
-
164
- // Block PII threat category
165
- @id("sentry-pii-block-threat-category")
145
+ @id("privacy.block-pii-category")
166
146
  @name("Block PII threat category")
167
- @description("Block messages and file uploads when threat categorization identifies PII. Defense-in-depth behind the pii_detected boolean — catches cases where PII is flagged at the aggregation layer.")
147
+ @description("Blocks process_prompt and upload_file when threat_categories contains \"pii\".")
168
148
  @severity("high")
169
- @tags("pii,privacy,data-protection,gdpr")
170
- @reject_message("Content blocked: threat scanners detected personally identifiable information. Remove all PII before submitting.")
149
+ @tags("category:privacy,threat:pii,detection:aggregate,compliance:gdpr")
150
+ @reject_message("Content blocked: threat scanners aggregated a PII threat category.")
171
151
  forbid (
172
152
  principal,
173
153
  action in [Sentry::Action::"process_prompt", Sentry::Action::"upload_file"],
@@ -176,4 +156,3 @@ forbid (
176
156
  when {
177
157
  context has threat_categories && context.threat_categories.contains("pii")
178
158
  };
179
-