@highflame/policy 2.1.23 → 2.1.25

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.
@@ -137,6 +137,20 @@ action call_tool appliesTo {
137
137
  suspicious_pattern?: Bool,
138
138
  pattern_type?: String,
139
139
  sequence_risk?: Long,
140
+
141
+ // --- Usage Budget (multi-window, multi-dimension) ---
142
+ budget_remaining_pct?: Long,
143
+ budget_exceeded?: Bool,
144
+ budget_cost_micros_this_turn?: Long,
145
+ budget_model?: String,
146
+ budget_tokens_pct_session?: Long,
147
+ budget_tokens_pct_daily?: Long,
148
+ budget_tokens_pct_monthly?: Long,
149
+ budget_cost_pct_daily?: Long,
150
+ budget_cost_pct_monthly?: Long,
151
+ budget_exceeded_session?: Bool,
152
+ budget_exceeded_daily?: Bool,
153
+ budget_exceeded_monthly?: Bool,
140
154
  },
141
155
  };
142
156
 
@@ -176,6 +190,20 @@ action connect_server appliesTo {
176
190
  mcp_server_verified?: Bool,
177
191
  mcp_config_risk?: Bool,
178
192
  mcp_risk_score?: Long,
193
+
194
+ // --- Usage Budget (multi-window, multi-dimension) ---
195
+ budget_remaining_pct?: Long,
196
+ budget_exceeded?: Bool,
197
+ budget_cost_micros_this_turn?: Long,
198
+ budget_model?: String,
199
+ budget_tokens_pct_session?: Long,
200
+ budget_tokens_pct_daily?: Long,
201
+ budget_tokens_pct_monthly?: Long,
202
+ budget_cost_pct_daily?: Long,
203
+ budget_cost_pct_monthly?: Long,
204
+ budget_exceeded_session?: Bool,
205
+ budget_exceeded_daily?: Bool,
206
+ budget_exceeded_monthly?: Bool,
179
207
  },
180
208
  };
181
209
 
@@ -224,6 +252,20 @@ action process_prompt appliesTo {
224
252
  // --- LLM-specific ---
225
253
  model_name?: String, // Target model name (e.g., "gpt-4", "claude-3-opus")
226
254
  model_provider?: String, // Provider name (e.g., "openai", "anthropic", "bedrock")
255
+
256
+ // --- Usage Budget (multi-window, multi-dimension) ---
257
+ budget_remaining_pct?: Long,
258
+ budget_exceeded?: Bool,
259
+ budget_cost_micros_this_turn?: Long,
260
+ budget_model?: String,
261
+ budget_tokens_pct_session?: Long,
262
+ budget_tokens_pct_daily?: Long,
263
+ budget_tokens_pct_monthly?: Long,
264
+ budget_cost_pct_daily?: Long,
265
+ budget_cost_pct_monthly?: Long,
266
+ budget_exceeded_session?: Bool,
267
+ budget_exceeded_daily?: Bool,
268
+ budget_exceeded_monthly?: Bool,
227
269
  },
228
270
  };
229
271
 
@@ -252,6 +294,20 @@ action read_file appliesTo {
252
294
  pii_detected?: Bool,
253
295
  pii_types?: Set<String>,
254
296
  pii_count?: Long,
297
+
298
+ // --- Usage Budget (multi-window, multi-dimension) ---
299
+ budget_remaining_pct?: Long,
300
+ budget_exceeded?: Bool,
301
+ budget_cost_micros_this_turn?: Long,
302
+ budget_model?: String,
303
+ budget_tokens_pct_session?: Long,
304
+ budget_tokens_pct_daily?: Long,
305
+ budget_tokens_pct_monthly?: Long,
306
+ budget_cost_pct_daily?: Long,
307
+ budget_cost_pct_monthly?: Long,
308
+ budget_exceeded_session?: Bool,
309
+ budget_exceeded_daily?: Bool,
310
+ budget_exceeded_monthly?: Bool,
255
311
  },
256
312
  };
257
313
 
@@ -280,6 +336,20 @@ action write_file appliesTo {
280
336
  pii_detected?: Bool,
281
337
  pii_types?: Set<String>,
282
338
  pii_count?: Long,
339
+
340
+ // --- Usage Budget (multi-window, multi-dimension) ---
341
+ budget_remaining_pct?: Long,
342
+ budget_exceeded?: Bool,
343
+ budget_cost_micros_this_turn?: Long,
344
+ budget_model?: String,
345
+ budget_tokens_pct_session?: Long,
346
+ budget_tokens_pct_daily?: Long,
347
+ budget_tokens_pct_monthly?: Long,
348
+ budget_cost_pct_daily?: Long,
349
+ budget_cost_pct_monthly?: Long,
350
+ budget_exceeded_session?: Bool,
351
+ budget_exceeded_daily?: Bool,
352
+ budget_exceeded_monthly?: Bool,
283
353
  },
284
354
  };
285
355
 
@@ -29,7 +29,7 @@
29
29
  "key": "content_type",
30
30
  "type": "string",
31
31
  "required": true,
32
- "description": "Type of content being analyzed: 'prompt', 'response', 'tool_call', or 'file'"
32
+ "description": "Type of content being analyzed: 'prompt', 'response', 'tool_call', 'file', or 'clipboard'"
33
33
  },
34
34
  {
35
35
  "key": "detector_count",
@@ -206,6 +206,22 @@ namespace Guardrails {
206
206
  "session_max_secret_score"?: Long,
207
207
  "session_cumulative_risk_score"?: Long,
208
208
 
209
+ // Usage Budget — multi-window token & cost enforcement (optional)
210
+ // Emitted by usage_budget detector. Enforced across session/daily/monthly windows
211
+ // and user/app/project/account dimensions. Percentages are 0-100.
212
+ "budget_remaining_pct"?: Long, // Min remaining % across all windows
213
+ "budget_exceeded"?: Bool, // Any window limit exceeded
214
+ "budget_cost_micros_this_turn"?: Long, // Cost of this request in microdollars (USD * 1e6)
215
+ "budget_model"?: String, // Model name used for cost calculation
216
+ "budget_tokens_pct_session"?: Long, // Session token usage % (0-100)
217
+ "budget_tokens_pct_daily"?: Long, // Daily token usage % (0-100)
218
+ "budget_tokens_pct_monthly"?: Long, // Monthly token usage % (0-100)
219
+ "budget_cost_pct_daily"?: Long, // Daily cost usage % (0-100)
220
+ "budget_cost_pct_monthly"?: Long, // Monthly cost usage % (0-100)
221
+ "budget_exceeded_session"?: Bool, // Session-scoped budget exceeded
222
+ "budget_exceeded_daily"?: Bool, // Any daily-scoped budget exceeded
223
+ "budget_exceeded_monthly"?: Bool, // Any monthly-scoped budget exceeded
224
+
209
225
  // Agent Identity — authenticated agent principal metadata (optional)
210
226
  // Present when the request is made by an AI agent (API key or JWT with agent claims).
211
227
  // Empty strings for human user requests. Use these to write agent-specific policies.
@@ -245,9 +261,20 @@ namespace Guardrails {
245
261
  "loop_count"?: Long,
246
262
  "loop_tool"?: String,
247
263
 
248
- // Agentic - Budget Control (optional)
249
- "budget_remaining_pct"?: Long, // 0-100
250
- "budget_exceeded"?: Bool,
264
+ // Usage Budget — multi-window token & cost enforcement (optional)
265
+ // See ProcessPromptContext for full documentation.
266
+ "budget_remaining_pct"?: Long, // Min remaining % across all windows
267
+ "budget_exceeded"?: Bool, // Any window limit exceeded
268
+ "budget_cost_micros_this_turn"?: Long, // Cost of this request in microdollars
269
+ "budget_model"?: String,
270
+ "budget_tokens_pct_session"?: Long,
271
+ "budget_tokens_pct_daily"?: Long,
272
+ "budget_tokens_pct_monthly"?: Long,
273
+ "budget_cost_pct_daily"?: Long,
274
+ "budget_cost_pct_monthly"?: Long,
275
+ "budget_exceeded_session"?: Bool,
276
+ "budget_exceeded_daily"?: Bool,
277
+ "budget_exceeded_monthly"?: Bool,
251
278
 
252
279
  // Semantic - Topic Classification (optional)
253
280
  "content_topics"?: Set<String>, // ["controlled_substances", "weapons_manufacturing", ...]
@@ -375,6 +402,21 @@ namespace Guardrails {
375
402
  "session_max_secret_score"?: Long,
376
403
  "session_cumulative_risk_score"?: Long,
377
404
 
405
+ // Usage Budget — multi-window token & cost enforcement (optional)
406
+ // See ProcessPromptContext for full documentation.
407
+ "budget_remaining_pct"?: Long,
408
+ "budget_exceeded"?: Bool,
409
+ "budget_cost_micros_this_turn"?: Long,
410
+ "budget_model"?: String,
411
+ "budget_tokens_pct_session"?: Long,
412
+ "budget_tokens_pct_daily"?: Long,
413
+ "budget_tokens_pct_monthly"?: Long,
414
+ "budget_cost_pct_daily"?: Long,
415
+ "budget_cost_pct_monthly"?: Long,
416
+ "budget_exceeded_session"?: Bool,
417
+ "budget_exceeded_daily"?: Bool,
418
+ "budget_exceeded_monthly"?: Bool,
419
+
378
420
  // Agent Identity — authenticated agent principal metadata (optional)
379
421
  "agent_id"?: String,
380
422
  "agent_type"?: String,
@@ -424,6 +466,21 @@ namespace Guardrails {
424
466
  "session_max_secret_score"?: Long,
425
467
  "session_cumulative_risk_score"?: Long,
426
468
 
469
+ // Usage Budget — multi-window token & cost enforcement (optional)
470
+ // See ProcessPromptContext for full documentation.
471
+ "budget_remaining_pct"?: Long,
472
+ "budget_exceeded"?: Bool,
473
+ "budget_cost_micros_this_turn"?: Long,
474
+ "budget_model"?: String,
475
+ "budget_tokens_pct_session"?: Long,
476
+ "budget_tokens_pct_daily"?: Long,
477
+ "budget_tokens_pct_monthly"?: Long,
478
+ "budget_cost_pct_daily"?: Long,
479
+ "budget_cost_pct_monthly"?: Long,
480
+ "budget_exceeded_session"?: Bool,
481
+ "budget_exceeded_daily"?: Bool,
482
+ "budget_exceeded_monthly"?: Bool,
483
+
427
484
  // Agent Identity — authenticated agent principal metadata (optional)
428
485
  "agent_id"?: String,
429
486
  "agent_type"?: String,
@@ -473,6 +530,21 @@ namespace Guardrails {
473
530
  "session_max_secret_score"?: Long,
474
531
  "session_cumulative_risk_score"?: Long,
475
532
 
533
+ // Usage Budget — multi-window token & cost enforcement (optional)
534
+ // See ProcessPromptContext for full documentation.
535
+ "budget_remaining_pct"?: Long,
536
+ "budget_exceeded"?: Bool,
537
+ "budget_cost_micros_this_turn"?: Long,
538
+ "budget_model"?: String,
539
+ "budget_tokens_pct_session"?: Long,
540
+ "budget_tokens_pct_daily"?: Long,
541
+ "budget_tokens_pct_monthly"?: Long,
542
+ "budget_cost_pct_daily"?: Long,
543
+ "budget_cost_pct_monthly"?: Long,
544
+ "budget_exceeded_session"?: Bool,
545
+ "budget_exceeded_daily"?: Bool,
546
+ "budget_exceeded_monthly"?: Bool,
547
+
476
548
  // Agent Identity — authenticated agent principal metadata (optional)
477
549
  "agent_id"?: String,
478
550
  "agent_type"?: String,
@@ -137,6 +137,20 @@ action call_tool appliesTo {
137
137
  suspicious_pattern?: Bool,
138
138
  pattern_type?: String,
139
139
  sequence_risk?: Long,
140
+
141
+ // --- Usage Budget (multi-window, multi-dimension) ---
142
+ budget_remaining_pct?: Long,
143
+ budget_exceeded?: Bool,
144
+ budget_cost_micros_this_turn?: Long,
145
+ budget_model?: String,
146
+ budget_tokens_pct_session?: Long,
147
+ budget_tokens_pct_daily?: Long,
148
+ budget_tokens_pct_monthly?: Long,
149
+ budget_cost_pct_daily?: Long,
150
+ budget_cost_pct_monthly?: Long,
151
+ budget_exceeded_session?: Bool,
152
+ budget_exceeded_daily?: Bool,
153
+ budget_exceeded_monthly?: Bool,
140
154
  },
141
155
  };
142
156
 
@@ -166,6 +180,20 @@ action connect_server appliesTo {
166
180
  mcp_server_verified?: Bool,
167
181
  mcp_config_risk?: Bool,
168
182
  mcp_risk_score?: Long,
183
+
184
+ // --- Usage Budget (multi-window, multi-dimension) ---
185
+ budget_remaining_pct?: Long,
186
+ budget_exceeded?: Bool,
187
+ budget_cost_micros_this_turn?: Long,
188
+ budget_model?: String,
189
+ budget_tokens_pct_session?: Long,
190
+ budget_tokens_pct_daily?: Long,
191
+ budget_tokens_pct_monthly?: Long,
192
+ budget_cost_pct_daily?: Long,
193
+ budget_cost_pct_monthly?: Long,
194
+ budget_exceeded_session?: Bool,
195
+ budget_exceeded_daily?: Bool,
196
+ budget_exceeded_monthly?: Bool,
169
197
  },
170
198
  };
171
199
 
@@ -210,6 +238,20 @@ action process_prompt appliesTo {
210
238
  // --- Encoding ---
211
239
  contains_invisible_chars?: Bool,
212
240
  invisible_chars_score?: Long,
241
+
242
+ // --- Usage Budget (multi-window, multi-dimension) ---
243
+ budget_remaining_pct?: Long,
244
+ budget_exceeded?: Bool,
245
+ budget_cost_micros_this_turn?: Long,
246
+ budget_model?: String,
247
+ budget_tokens_pct_session?: Long,
248
+ budget_tokens_pct_daily?: Long,
249
+ budget_tokens_pct_monthly?: Long,
250
+ budget_cost_pct_daily?: Long,
251
+ budget_cost_pct_monthly?: Long,
252
+ budget_exceeded_session?: Bool,
253
+ budget_exceeded_daily?: Bool,
254
+ budget_exceeded_monthly?: Bool,
213
255
  },
214
256
  };
215
257
 
@@ -238,6 +280,20 @@ action read_file appliesTo {
238
280
  pii_detected?: Bool,
239
281
  pii_types?: Set<String>,
240
282
  pii_count?: Long,
283
+
284
+ // --- Usage Budget (multi-window, multi-dimension) ---
285
+ budget_remaining_pct?: Long,
286
+ budget_exceeded?: Bool,
287
+ budget_cost_micros_this_turn?: Long,
288
+ budget_model?: String,
289
+ budget_tokens_pct_session?: Long,
290
+ budget_tokens_pct_daily?: Long,
291
+ budget_tokens_pct_monthly?: Long,
292
+ budget_cost_pct_daily?: Long,
293
+ budget_cost_pct_monthly?: Long,
294
+ budget_exceeded_session?: Bool,
295
+ budget_exceeded_daily?: Bool,
296
+ budget_exceeded_monthly?: Bool,
241
297
  },
242
298
  };
243
299
 
@@ -266,6 +322,20 @@ action write_file appliesTo {
266
322
  pii_detected?: Bool,
267
323
  pii_types?: Set<String>,
268
324
  pii_count?: Long,
325
+
326
+ // --- Usage Budget (multi-window, multi-dimension) ---
327
+ budget_remaining_pct?: Long,
328
+ budget_exceeded?: Bool,
329
+ budget_cost_micros_this_turn?: Long,
330
+ budget_model?: String,
331
+ budget_tokens_pct_session?: Long,
332
+ budget_tokens_pct_daily?: Long,
333
+ budget_tokens_pct_monthly?: Long,
334
+ budget_cost_pct_daily?: Long,
335
+ budget_cost_pct_monthly?: Long,
336
+ budget_exceeded_session?: Bool,
337
+ budget_exceeded_daily?: Bool,
338
+ budget_exceeded_monthly?: Bool,
269
339
  },
270
340
  };
271
341
 
@@ -0,0 +1,76 @@
1
+ // =============================================================================
2
+ // Clipboard Policy (Default)
3
+ // =============================================================================
4
+ // Controls over paste operations into AI chat services. Covers:
5
+ // - Blanket paste blocking (admin-configurable)
6
+ // - Paste-with-secrets blocking
7
+ // - Paste-with-source-code blocking
8
+ //
9
+ // Cross-cutting secret rules (e.g. high-risk credential types) are defined
10
+ // in secrets.cedar and apply to paste content as well.
11
+ //
12
+ // Category: clipboard
13
+ // Namespace: Sentry
14
+ // =============================================================================
15
+
16
+ // Block all paste operations
17
+ @id("sentry-org-block-all-paste")
18
+ @name("Block all paste operations")
19
+ @description("Unconditionally block all paste operations into AI chat services. Enable this rule to prevent any content from being pasted into AI chats regardless of content. Disable to allow paste (subject to other policy rules).")
20
+ @severity("high")
21
+ @tags("paste,clipboard,data-protection,organization")
22
+ @reject_message("Paste blocked: your organization does not allow pasting content into AI services. Type your message directly or contact your administrator.")
23
+ forbid (
24
+ principal,
25
+ action == Sentry::Action::"paste_content",
26
+ resource
27
+ );
28
+
29
+ // Block pasted content containing secrets
30
+ @id("sentry-org-block-secrets-paste")
31
+ @name("Block paste with secrets")
32
+ @description("Block paste operations when secrets are detected. Prevents credential leakage when users paste from terminals, config files, or code editors into AI chats.")
33
+ @severity("critical")
34
+ @tags("secrets,paste-safety,credentials,nist-sc-28")
35
+ @reject_message("Paste blocked: secrets or credentials detected in pasted content. Remove API keys, tokens, and passwords before pasting into AI services.")
36
+ forbid (
37
+ principal,
38
+ action == Sentry::Action::"paste_content",
39
+ resource
40
+ )
41
+ when {
42
+ context has contains_secrets && context.contains_secrets
43
+ };
44
+
45
+ // Block pasted content containing PII
46
+ @id("sentry-pii-block-paste")
47
+ @name("Block paste with PII")
48
+ @description("Block paste operations when PII is detected in pasted content. Prevents data leakage when employees paste content from emails, spreadsheets, or documents containing personal data into AI chats.")
49
+ @severity("critical")
50
+ @tags("pii,paste-safety,data-leakage,gdpr-art-32")
51
+ @reject_message("Paste blocked: personally identifiable information detected in pasted content. Remove PII before pasting into AI services.")
52
+ forbid (
53
+ principal,
54
+ action == Sentry::Action::"paste_content",
55
+ resource
56
+ )
57
+ when {
58
+ context has pii_detected && context.pii_detected
59
+ };
60
+
61
+ // Block pasted source code
62
+ @id("sentry-org-block-code-paste")
63
+ @name("Block pasted source code")
64
+ @description("Block paste operations when content is primarily source code (>80%). Prevents code exfiltration via clipboard from IDEs, terminals, or code repositories into AI chats.")
65
+ @severity("high")
66
+ @tags("source-code,paste-safety,ip-protection,data-leakage")
67
+ @reject_message("Paste blocked: the content appears to be primarily source code (>80%). Pasting bulk source code into AI services risks intellectual property exposure.")
68
+ forbid (
69
+ principal,
70
+ action == Sentry::Action::"paste_content",
71
+ resource
72
+ )
73
+ when {
74
+ context has contains_code && context.contains_code &&
75
+ context has code_ratio && context.code_ratio > 80
76
+ };
@@ -97,20 +97,20 @@ when {
97
97
  context has contains_secrets && context.contains_secrets
98
98
  };
99
99
 
100
- // Block files with bulk PII
101
- @id("sentry-file-block-bulk-pii")
102
- @name("Block files with bulk PII")
103
- @description("Block file uploads containing 3 or more PII matches. Files with bulk PII likely contain customer lists, employee records, or patient data that must not be shared with AI services.")
100
+ // Block file uploads containing PII
101
+ @id("sentry-pii-block-uploads")
102
+ @name("Block file uploads with PII")
103
+ @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.")
104
104
  @severity("critical")
105
- @tags("pii,file-upload,bulk,gdpr-art-32")
106
- @reject_message("Upload blocked: multiple PII items detected in the file (3+). Documents containing bulk personal data must not be shared with AI services.")
105
+ @tags("pii,file-upload,data-protection,gdpr-art-32")
106
+ @reject_message("File upload blocked: personally identifiable information detected in the document. Files containing PII must not be shared with AI services.")
107
107
  forbid (
108
108
  principal,
109
109
  action == Sentry::Action::"upload_file",
110
110
  resource
111
111
  )
112
112
  when {
113
- context has pii_count && context.pii_count >= 3
113
+ context has pii_detected && context.pii_detected
114
114
  };
115
115
 
116
116
  // Block files with phishing links
@@ -1,138 +1,22 @@
1
1
  // =============================================================================
2
2
  // Organization Rules Policy (Default)
3
3
  // =============================================================================
4
- // Organization-wide security policies for browser AI interactions:
5
- // - Credential/secret leakage prevention across all channels
6
- // - Source code protection
7
- // - Session-aware escalation
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.
8
7
  //
9
- // These rules complement category-specific policies (PII, Content Safety,
10
- // File Safety) with cross-cutting organizational controls.
8
+ // This template covers:
9
+ // - Source code protection in messages (non-paste channels)
10
+ // - Session-aware threat escalation
11
11
  //
12
12
  // Category: organization
13
13
  // Namespace: Sentry
14
14
  // =============================================================================
15
15
 
16
16
  // ---------------------------------------------------------------------------
17
- // Section 1: Credential & Secret Leakage Prevention
18
- // Block secrets/credentials across messages, pastes, and file uploads.
19
- // Shield SecretsDetector identifies 18+ secret types via regex.
20
- // ---------------------------------------------------------------------------
21
-
22
- // Block messages containing secrets
23
- @id("sentry-org-block-secrets-messages")
24
- @name("Block messages with secrets")
25
- @description("Block messages when detection engines identify API keys, tokens, or credential patterns. First line of defense against accidental credential exposure in AI chat interactions.")
26
- @severity("critical")
27
- @tags("secrets,credentials,messages,nist-sc-28,nist-ia-5")
28
- @reject_message("Your message was blocked because it contains detected secrets such as API keys, tokens, or credentials. Remove all secrets before sending to AI services.")
29
- forbid (
30
- principal,
31
- action == Sentry::Action::"send_message",
32
- resource
33
- )
34
- when {
35
- context has contains_secrets && context.contains_secrets
36
- };
37
-
38
- // Block pasted content containing secrets
39
- @id("sentry-org-block-secrets-paste")
40
- @name("Block paste with secrets")
41
- @description("Block paste operations when secrets are detected. Prevents credential leakage when users paste from terminals, config files, or code editors into AI chats.")
42
- @severity("critical")
43
- @tags("secrets,paste-safety,credentials,nist-sc-28")
44
- @reject_message("Paste blocked: secrets or credentials detected in pasted content. Remove API keys, tokens, and passwords before pasting into AI services.")
45
- forbid (
46
- principal,
47
- action == Sentry::Action::"paste_content",
48
- resource
49
- )
50
- when {
51
- context has contains_secrets && context.contains_secrets
52
- };
53
-
54
- // Block high-risk secret types across all actions
55
- @id("sentry-org-block-high-risk-secrets")
56
- @name("Block high-risk credential types")
57
- @description("Block content containing cloud provider keys (AWS, GCP, Azure), GitHub tokens, SSH private keys, or database connection strings across all actions. These credential types pose the highest exfiltration risk.")
58
- @severity("critical")
59
- @tags("secrets,aws,github,ssh,cloud,nist-ia-5,mitre-t1552")
60
- @reject_message("Content blocked: high-risk credentials detected (cloud keys, GitHub tokens, SSH keys). Use a secrets manager — never share credentials with AI services.")
61
- forbid (
62
- principal,
63
- action,
64
- resource
65
- )
66
- when {
67
- context has secret_types &&
68
- (context.secret_types.contains("aws_access_key") ||
69
- context.secret_types.contains("aws_secret_key") ||
70
- context.secret_types.contains("gcp_service_account") ||
71
- context.secret_types.contains("azure_connection_string") ||
72
- context.secret_types.contains("github_token") ||
73
- context.secret_types.contains("github_fine_grained") ||
74
- context.secret_types.contains("private_key"))
75
- };
76
-
77
- // Block API keys and tokens across all actions
78
- @id("sentry-org-block-api-keys")
79
- @name("Block API keys and tokens")
80
- @description("Block content containing generic API keys, JWT tokens, and OAuth credentials. These are the most commonly leaked credential types when users interact with AI services.")
81
- @severity("high")
82
- @tags("secrets,api-key,jwt,oauth,nist-ia-5")
83
- @reject_message("Content blocked: API keys, JWT tokens, or OAuth credentials detected. These must never be shared with AI services.")
84
- forbid (
85
- principal,
86
- action,
87
- resource
88
- )
89
- when {
90
- context has secret_types &&
91
- (context.secret_types.contains("generic_api_key") ||
92
- context.secret_types.contains("jwt_token") ||
93
- context.secret_types.contains("openai_key") ||
94
- context.secret_types.contains("anthropic_key") ||
95
- context.secret_types.contains("stripe_key"))
96
- };
97
-
98
- // Block bulk secret exposure
99
- @id("sentry-org-block-bulk-secrets")
100
- @name("Block bulk secret exposure")
101
- @description("Block content when 3+ distinct secrets are found. Multiple secrets indicate a configuration dump, .env file paste, or credential harvesting being sent to AI services.")
102
- @severity("critical")
103
- @tags("secrets,bulk,data-exfiltration,nist-sc-28")
104
- @reject_message("Content blocked: multiple credentials detected (3+). Configuration dumps and credential lists must never be shared with AI services.")
105
- forbid (
106
- principal,
107
- action,
108
- resource
109
- )
110
- when {
111
- context has secret_count && context.secret_count >= 3
112
- };
113
-
114
- // Block detected credential patterns
115
- @id("sentry-org-block-detected-credentials")
116
- @name("Block detected credential patterns")
117
- @description("Block content flagged by detection engine rules for credential exposure, API key leaks, and token exposure. Defense-in-depth behind contains_secrets.")
118
- @severity("critical")
119
- @tags("secrets,credentials,detection-rules,nist-ia-5")
120
- @reject_message("Content blocked: detection engines identified credential patterns including secret exposure, API keys, or token leaks.")
121
- forbid (
122
- principal,
123
- action,
124
- resource
125
- )
126
- when {
127
- context has detected_threats &&
128
- (context.detected_threats.contains("secret_exposure") ||
129
- context.detected_threats.contains("credential_leak") ||
130
- context.detected_threats.contains("api_key_exposure"))
131
- };
132
-
133
- // ---------------------------------------------------------------------------
134
- // Section 2: Source Code Protection
135
- // Prevent bulk source code from being shared with AI services.
17
+ // Section 1: Source Code Protection (Messages)
18
+ // Prevent bulk source code from being shared via messages.
19
+ // Paste-targeted code protection is in clipboard.cedar.
136
20
  // ---------------------------------------------------------------------------
137
21
 
138
22
  // Block messages with high code content
@@ -152,25 +36,8 @@ when {
152
36
  context has code_ratio && context.code_ratio > 80
153
37
  };
154
38
 
155
- // Block pasted source code
156
- @id("sentry-org-block-code-paste")
157
- @name("Block pasted source code")
158
- @description("Block paste operations when content is primarily source code (>80%). Prevents code exfiltration via clipboard from IDEs, terminals, or code repositories into AI chats.")
159
- @severity("high")
160
- @tags("source-code,paste-safety,ip-protection,data-leakage")
161
- @reject_message("Paste blocked: the content appears to be primarily source code (>80%). Pasting bulk source code into AI services risks intellectual property exposure.")
162
- forbid (
163
- principal,
164
- action == Sentry::Action::"paste_content",
165
- resource
166
- )
167
- when {
168
- context has contains_code && context.contains_code &&
169
- context has code_ratio && context.code_ratio > 80
170
- };
171
-
172
39
  // ---------------------------------------------------------------------------
173
- // Section 3: Session-Aware Escalation
40
+ // Section 2: Session-Aware Escalation
174
41
  // Escalate protections when threats are detected across the session.
175
42
  // ---------------------------------------------------------------------------
176
43
 
@@ -189,19 +56,3 @@ forbid (
189
56
  when {
190
57
  context has session_threat_turns && context.session_threat_turns >= 3
191
58
  };
192
-
193
- // Block AI responses when session has leaked secrets
194
- @id("sentry-org-session-secrets-response")
195
- @name("Block responses after secret detection")
196
- @description("Block AI responses when secrets were detected earlier in the session. If credentials were leaked in a previous turn, the AI service may have processed them and could echo or reference them in responses.")
197
- @severity("high")
198
- @tags("session,secrets,response-safety,defense-in-depth")
199
- @reject_message("AI response blocked: secrets were detected in an earlier message in this session. Responses may contain or reference the exposed credentials.")
200
- forbid (
201
- principal,
202
- action == Sentry::Action::"receive_response",
203
- resource
204
- )
205
- when {
206
- context has session_secrets_detected && context.session_secrets_detected
207
- };
@@ -46,38 +46,6 @@ when {
46
46
  context has pii_detected && context.pii_detected
47
47
  };
48
48
 
49
- // Block pasted content containing PII
50
- @id("sentry-pii-block-paste")
51
- @name("Block paste with PII")
52
- @description("Block paste operations when PII is detected in pasted content. Prevents data leakage when employees paste content from emails, spreadsheets, or documents containing personal data into AI chats.")
53
- @severity("critical")
54
- @tags("pii,paste-safety,data-leakage,gdpr-art-32")
55
- @reject_message("Paste blocked: personally identifiable information detected in pasted content. Remove PII before pasting into AI services.")
56
- forbid (
57
- principal,
58
- action == Sentry::Action::"paste_content",
59
- resource
60
- )
61
- when {
62
- context has pii_detected && context.pii_detected
63
- };
64
-
65
- // Block file uploads containing PII
66
- @id("sentry-pii-block-uploads")
67
- @name("Block file uploads with PII")
68
- @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.")
69
- @severity("critical")
70
- @tags("pii,file-upload,data-protection,gdpr-art-32")
71
- @reject_message("File upload blocked: personally identifiable information detected in the document. Files containing PII must not be shared with AI services.")
72
- forbid (
73
- principal,
74
- action == Sentry::Action::"upload_file",
75
- resource
76
- )
77
- when {
78
- context has pii_detected && context.pii_detected
79
- };
80
-
81
49
  // ---------------------------------------------------------------------------
82
50
  // Section 2: Granular PII Type Blocking
83
51
  // Blocks specific PII types based on regulatory requirements.