@highflame/policy 2.0.7 → 2.0.9

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 (128) hide show
  1. package/_schemas/overwatch/context.json +163 -1
  2. package/_schemas/overwatch/schema.cedarschema +45 -0
  3. package/dist/actions.gen.d.ts +0 -1
  4. package/dist/actions.gen.js +0 -1
  5. package/dist/annotations.d.ts +0 -1
  6. package/dist/annotations.js +0 -1
  7. package/dist/builder.d.ts +0 -1
  8. package/dist/builder.js +0 -1
  9. package/dist/context.gen.d.ts +0 -1
  10. package/dist/context.gen.js +0 -1
  11. package/dist/engine.d.ts +0 -1
  12. package/dist/engine.js +0 -1
  13. package/dist/entities.gen.d.ts +0 -1
  14. package/dist/entities.gen.js +0 -1
  15. package/dist/entity-metadata-types.gen.d.ts +0 -1
  16. package/dist/entity-metadata-types.gen.js +0 -1
  17. package/dist/errors.d.ts +0 -1
  18. package/dist/errors.js +0 -1
  19. package/dist/index.d.ts +0 -1
  20. package/dist/index.js +0 -1
  21. package/dist/overwatch-context.gen.d.ts +13 -1
  22. package/dist/overwatch-context.gen.js +13 -1
  23. package/dist/overwatch-defaults.gen.d.ts +1 -2
  24. package/dist/overwatch-defaults.gen.js +346 -2
  25. package/dist/overwatch-entities.gen.d.ts +0 -1
  26. package/dist/overwatch-entities.gen.js +0 -1
  27. package/dist/palisade-context.gen.d.ts +0 -1
  28. package/dist/palisade-context.gen.js +0 -1
  29. package/dist/palisade-entities.gen.d.ts +0 -1
  30. package/dist/palisade-entities.gen.js +0 -1
  31. package/dist/parser.d.ts +0 -1
  32. package/dist/parser.js +0 -1
  33. package/dist/schema.gen.d.ts +0 -1
  34. package/dist/schema.gen.js +0 -1
  35. package/dist/schemas.d.ts +0 -1
  36. package/dist/schemas.js +0 -1
  37. package/dist/service-schemas.gen.d.ts +0 -1
  38. package/dist/service-schemas.gen.js +0 -1
  39. package/dist/types.d.ts +0 -1
  40. package/dist/types.js +0 -1
  41. package/package.json +1 -2
  42. package/dist/actions.gen.d.ts.map +0 -1
  43. package/dist/actions.gen.js.map +0 -1
  44. package/dist/annotations.d.ts.map +0 -1
  45. package/dist/annotations.js.map +0 -1
  46. package/dist/builder.d.ts.map +0 -1
  47. package/dist/builder.js.map +0 -1
  48. package/dist/context.gen.d.ts.map +0 -1
  49. package/dist/context.gen.js.map +0 -1
  50. package/dist/engine.d.ts.map +0 -1
  51. package/dist/engine.js.map +0 -1
  52. package/dist/engine.test.d.ts +0 -8
  53. package/dist/engine.test.d.ts.map +0 -1
  54. package/dist/engine.test.js +0 -190
  55. package/dist/engine.test.js.map +0 -1
  56. package/dist/entities.gen.d.ts.map +0 -1
  57. package/dist/entities.gen.js.map +0 -1
  58. package/dist/entity-metadata-types.gen.d.ts.map +0 -1
  59. package/dist/entity-metadata-types.gen.js.map +0 -1
  60. package/dist/errors.d.ts.map +0 -1
  61. package/dist/errors.js.map +0 -1
  62. package/dist/index.d.ts.map +0 -1
  63. package/dist/index.js.map +0 -1
  64. package/dist/overwatch-context.gen.d.ts.map +0 -1
  65. package/dist/overwatch-context.gen.js.map +0 -1
  66. package/dist/overwatch-defaults.gen.d.ts.map +0 -1
  67. package/dist/overwatch-defaults.gen.js.map +0 -1
  68. package/dist/overwatch-defaults.test.d.ts +0 -8
  69. package/dist/overwatch-defaults.test.d.ts.map +0 -1
  70. package/dist/overwatch-defaults.test.js +0 -145
  71. package/dist/overwatch-defaults.test.js.map +0 -1
  72. package/dist/overwatch-entities.gen.d.ts.map +0 -1
  73. package/dist/overwatch-entities.gen.js.map +0 -1
  74. package/dist/overwatch-rebac.test.d.ts +0 -25
  75. package/dist/overwatch-rebac.test.d.ts.map +0 -1
  76. package/dist/overwatch-rebac.test.js +0 -301
  77. package/dist/overwatch-rebac.test.js.map +0 -1
  78. package/dist/palisade-context.gen.d.ts.map +0 -1
  79. package/dist/palisade-context.gen.js.map +0 -1
  80. package/dist/palisade-entities.gen.d.ts.map +0 -1
  81. package/dist/palisade-entities.gen.js.map +0 -1
  82. package/dist/parser.d.ts.map +0 -1
  83. package/dist/parser.js.map +0 -1
  84. package/dist/parser.test.d.ts +0 -8
  85. package/dist/parser.test.d.ts.map +0 -1
  86. package/dist/parser.test.js +0 -212
  87. package/dist/parser.test.js.map +0 -1
  88. package/dist/schema.gen.d.ts.map +0 -1
  89. package/dist/schema.gen.js.map +0 -1
  90. package/dist/schemas.d.ts.map +0 -1
  91. package/dist/schemas.js.map +0 -1
  92. package/dist/schemas.test.d.ts +0 -8
  93. package/dist/schemas.test.d.ts.map +0 -1
  94. package/dist/schemas.test.js +0 -375
  95. package/dist/schemas.test.js.map +0 -1
  96. package/dist/service-schemas.gen.d.ts.map +0 -1
  97. package/dist/service-schemas.gen.js.map +0 -1
  98. package/dist/studio-ui.test.d.ts +0 -8
  99. package/dist/studio-ui.test.d.ts.map +0 -1
  100. package/dist/studio-ui.test.js +0 -687
  101. package/dist/studio-ui.test.js.map +0 -1
  102. package/dist/types.d.ts.map +0 -1
  103. package/dist/types.js.map +0 -1
  104. package/src/actions.gen.ts +0 -57
  105. package/src/annotations.ts +0 -243
  106. package/src/builder.ts +0 -799
  107. package/src/context.gen.ts +0 -10
  108. package/src/engine.test.ts +0 -370
  109. package/src/engine.ts +0 -497
  110. package/src/entities.gen.ts +0 -65
  111. package/src/entity-metadata-types.gen.ts +0 -19
  112. package/src/errors.ts +0 -195
  113. package/src/index.ts +0 -62
  114. package/src/overwatch-context.gen.ts +0 -32
  115. package/src/overwatch-defaults.gen.ts +0 -907
  116. package/src/overwatch-defaults.test.ts +0 -176
  117. package/src/overwatch-entities.gen.ts +0 -41
  118. package/src/overwatch-rebac.test.ts +0 -346
  119. package/src/palisade-context.gen.ts +0 -28
  120. package/src/palisade-entities.gen.ts +0 -49
  121. package/src/parser.test.ts +0 -251
  122. package/src/parser.ts +0 -579
  123. package/src/schema.gen.ts +0 -134
  124. package/src/schemas.test.ts +0 -445
  125. package/src/schemas.ts +0 -91
  126. package/src/service-schemas.gen.ts +0 -608
  127. package/src/studio-ui.test.ts +0 -813
  128. package/src/types.ts +0 -66
@@ -1,907 +0,0 @@
1
- // Code generated by highflame-policy-codegen. DO NOT EDIT.
2
- // Source: schemas/overwatch/templates/templates.json
3
- //
4
- // Overwatch default policies and templates.
5
- // Cedar text is embedded at build time. PolicyRule[] can be parsed at runtime
6
- // using parseCedarToRules().
7
-
8
- /**
9
- * Overwatch policy category identifiers.
10
- * Maps to UI tab names in Studio.
11
- */
12
- export type OverwatchCategory = 'secrets' | 'pii' | 'semantic' | 'tools' | 'organization';
13
-
14
- /**
15
- * Category metadata for UI display.
16
- */
17
- export interface OverwatchCategoryInfo {
18
- id: OverwatchCategory;
19
- name: string;
20
- description: string;
21
- }
22
-
23
- /**
24
- * A default policy that is auto-created for new projects.
25
- */
26
- export interface OverwatchDefaultPolicy {
27
- /** Template identifier */
28
- id: string;
29
- /** Human-readable name */
30
- name: string;
31
- /** Description for UI display */
32
- description: string;
33
- /** Policy category */
34
- category: OverwatchCategory;
35
- /** Cedar policy text (source of truth) */
36
- cedarText: string;
37
- /** Severity level */
38
- severity: string;
39
- /** Tags for filtering */
40
- tags: string[];
41
- /** Whether this default should be activated immediately */
42
- isActive: boolean;
43
- }
44
-
45
- /**
46
- * A policy template available for users to create from.
47
- */
48
- export interface OverwatchTemplate {
49
- /** Template identifier */
50
- id: string;
51
- /** Human-readable name */
52
- name: string;
53
- /** Description for UI display */
54
- description: string;
55
- /** Policy category */
56
- category: OverwatchCategory;
57
- /** Cedar policy text */
58
- cedarText: string;
59
- /** Severity level */
60
- severity: string;
61
- /** Tags for filtering */
62
- tags: string[];
63
- }
64
-
65
- // =============================================================================
66
- // EMBEDDED CEDAR POLICY TEXT
67
- // =============================================================================
68
-
69
- const OVERWATCH_SECRETS_DEFAULT_CEDAR = `// =============================================================================
70
- // Secrets Detection Policy (Default)
71
- // =============================================================================
72
- // Detects and blocks credential leakage across prompts, tool calls, file
73
- // operations, and AI response content. Combines YARA-based threat detection
74
- // with pattern matching for known credential formats.
75
- //
76
- // Defense layers:
77
- // 1. YARA scanner detection (contains_secrets, yara_threats)
78
- // 2. Sensitive file path blocking (.env files)
79
- // 3. Response content pattern matching (AWS, GitHub, SSH keys)
80
- //
81
- // Compliance: NIST 800-53 SC-28, IA-5 | OWASP A02 | MITRE T1552, T1555
82
- // Category: secrets
83
- // Namespace: Overwatch
84
- // =============================================================================
85
-
86
- // ---------------------------------------------------------------------------
87
- // Section 1: YARA-Based Secret Detection
88
- // ---------------------------------------------------------------------------
89
-
90
- // Block prompts containing detected secrets
91
- @id("secrets-block-prompts")
92
- @name("Block prompts with secrets")
93
- @description("Block prompts when YARA scanners detect API keys, tokens, or credential patterns")
94
- @severity("critical")
95
- @tags("secrets,credentials,prompts,nist-sc-28,nist-ia-5")
96
- forbid (
97
- principal,
98
- action == Overwatch::Action::"process_prompt",
99
- resource
100
- )
101
- when {
102
- context has contains_secrets && context.contains_secrets == true
103
- };
104
-
105
- // Block file reads and tool calls when secrets are detected
106
- @id("secrets-block-reads-and-tools")
107
- @name("Block file reads and tool calls with secrets")
108
- @description("Prevent file reads and tool execution when secrets or credentials are detected in content")
109
- @severity("high")
110
- @tags("secrets,file-access,tools,credentials,nist-sc-28")
111
- forbid (
112
- principal,
113
- action in [Overwatch::Action::"read_file", Overwatch::Action::"call_tool"],
114
- resource
115
- )
116
- when {
117
- context has contains_secrets && context.contains_secrets == true
118
- };
119
-
120
- // ---------------------------------------------------------------------------
121
- // Section 2: Sensitive File Path Protection
122
- // ---------------------------------------------------------------------------
123
-
124
- // Block .env file access across all operations
125
- @id("secrets-block-env-files")
126
- @name("Block .env file access")
127
- @description("Block access to .env files that commonly contain secrets, API keys, and database credentials")
128
- @severity("high")
129
- @tags("secrets,env-files,config,nist-sc-28,mitre-t1552")
130
- forbid (
131
- principal,
132
- action in [Overwatch::Action::"read_file", Overwatch::Action::"write_file", Overwatch::Action::"call_tool"],
133
- resource
134
- )
135
- when {
136
- context has path && context.path like "*.env*"
137
- };
138
-
139
- // ---------------------------------------------------------------------------
140
- // Section 3: Response Content Pattern Matching
141
- // Scans AI responses for known credential formats as defense-in-depth.
142
- // ---------------------------------------------------------------------------
143
-
144
- // Block responses containing AWS access keys (AKIA prefix)
145
- @id("secrets-block-aws-keys")
146
- @name("Block AWS access keys in responses")
147
- @description("Detect and block AWS access key IDs (AKIA prefix) in AI responses to prevent credential exfiltration")
148
- @severity("critical")
149
- @tags("secrets,aws,credentials,response-scan,nist-ia-5,mitre-t1552")
150
- forbid (
151
- principal,
152
- action,
153
- resource
154
- )
155
- when {
156
- context has response_content &&
157
- context.response_content like "*AKIA*"
158
- };
159
-
160
- // Block responses containing AWS secret keys
161
- @id("secrets-block-aws-secrets")
162
- @name("Block AWS secret keys in responses")
163
- @description("Detect and block AWS secret access keys in AI responses")
164
- @severity("critical")
165
- @tags("secrets,aws,credentials,response-scan,nist-ia-5")
166
- forbid (
167
- principal,
168
- action,
169
- resource
170
- )
171
- when {
172
- context has response_content &&
173
- (context.response_content like "*AWS_SECRET_ACCESS_KEY*" ||
174
- context.response_content like "*aws_secret_access_key*")
175
- };
176
-
177
- // Block responses containing GitHub tokens
178
- @id("secrets-block-github-tokens")
179
- @name("Block GitHub tokens in responses")
180
- @description("Detect and block GitHub personal access tokens (ghp_), fine-grained tokens (github_pat_), and app tokens (ghs_)")
181
- @severity("critical")
182
- @tags("secrets,github,tokens,response-scan,mitre-t1552")
183
- forbid (
184
- principal,
185
- action,
186
- resource
187
- )
188
- when {
189
- context has response_content &&
190
- (context.response_content like "*ghp_*" ||
191
- context.response_content like "*github_pat_*" ||
192
- context.response_content like "*ghs_*")
193
- };
194
-
195
- // Block responses containing SSH/RSA private keys
196
- @id("secrets-block-private-keys")
197
- @name("Block private keys in responses")
198
- @description("Detect and block SSH, RSA, and OpenSSH private keys in AI responses")
199
- @severity("critical")
200
- @tags("secrets,ssh,private-keys,response-scan,nist-sc-28,mitre-t1552")
201
- forbid (
202
- principal,
203
- action,
204
- resource
205
- )
206
- when {
207
- context has response_content &&
208
- (context.response_content like "*-----BEGIN PRIVATE KEY-----*" ||
209
- context.response_content like "*-----BEGIN RSA PRIVATE KEY-----*" ||
210
- context.response_content like "*-----BEGIN OPENSSH PRIVATE KEY-----*")
211
- };
212
-
213
- // ---------------------------------------------------------------------------
214
- // Section 4: YARA Credential Pattern Detection
215
- // Catches credential types identified by YARA rule scanning.
216
- // ---------------------------------------------------------------------------
217
-
218
- // Block YARA-detected credential and token patterns
219
- @id("secrets-block-yara-credentials")
220
- @name("Block YARA-detected credential patterns")
221
- @description("Block content flagged by YARA rules for credential exposure, API key leaks, JWT tokens, and bearer tokens")
222
- @severity("critical")
223
- @tags("secrets,yara,credentials,jwt,bearer,nist-ia-5")
224
- forbid (
225
- principal,
226
- action,
227
- resource
228
- )
229
- when {
230
- context has yara_threats &&
231
- (context.yara_threats.contains("secret_exposure") ||
232
- context.yara_threats.contains("credential_leak") ||
233
- context.yara_threats.contains("api_key_exposure") ||
234
- context.yara_threats.contains("jwt_token_exposure") ||
235
- context.yara_threats.contains("bearer_token_leak"))
236
- };
237
- `;
238
-
239
- const OVERWATCH_PII_DEFAULT_CEDAR = `// =============================================================================
240
- // PII Detection Policy (Default)
241
- // =============================================================================
242
- // Detects and blocks personally identifiable information including credit card
243
- // numbers, Social Security Numbers, and other PII patterns across prompts
244
- // and tool calls.
245
- //
246
- // Compliance: PCI DSS 3.4, 4.1 | NIST 800-53 SI-4 | GDPR Art. 32
247
- // Category: pii
248
- // Namespace: Overwatch
249
- // =============================================================================
250
-
251
- // Block prompts containing credit card patterns
252
- @id("pii-block-credit-cards")
253
- @name("Block credit card numbers")
254
- @description("Detect and block content containing credit card number patterns (PCI DSS compliance)")
255
- @severity("critical")
256
- @tags("pci,credit-card,payment,compliance,pci-dss-3.4")
257
- forbid (
258
- principal,
259
- action == Overwatch::Action::"process_prompt",
260
- resource
261
- )
262
- when {
263
- context has yara_threats && context.yara_threats.contains("credit_card")
264
- };
265
-
266
- // Block prompts containing SSN patterns
267
- @id("pii-block-ssn")
268
- @name("Block Social Security Numbers")
269
- @description("Detect and block content containing SSN patterns (XXX-XX-XXXX format)")
270
- @severity("critical")
271
- @tags("ssn,identity,privacy,compliance")
272
- forbid (
273
- principal,
274
- action == Overwatch::Action::"process_prompt",
275
- resource
276
- )
277
- when {
278
- context has yara_threats && context.yara_threats.contains("ssn")
279
- };
280
-
281
- // Block prompts with generic PII threats detected
282
- @id("pii-block-generic")
283
- @name("Block detected PII content")
284
- @description("Block content when PII-related threat categories are detected by YARA or Javelin scanners")
285
- @severity("high")
286
- @tags("pii,privacy,data-protection,gdpr")
287
- forbid (
288
- principal,
289
- action == Overwatch::Action::"process_prompt",
290
- resource
291
- )
292
- when {
293
- context has threat_categories && context.threat_categories.contains("pii")
294
- };
295
-
296
- // Block PII leakage via tool calls
297
- @id("pii-block-tool-calls")
298
- @name("Block tool calls with PII")
299
- @description("Prevent tool execution when PII patterns are detected in content")
300
- @severity("high")
301
- @tags("pii,tools,data-protection")
302
- forbid (
303
- principal,
304
- action == Overwatch::Action::"call_tool",
305
- resource
306
- )
307
- when {
308
- context has threat_categories && context.threat_categories.contains("pii")
309
- };
310
- `;
311
-
312
- const OVERWATCH_SEMANTIC_DEFAULT_CEDAR = `// =============================================================================
313
- // Semantic Threat Detection Policy (Default)
314
- // =============================================================================
315
- // Detects and blocks prompt injection, jailbreak attempts, and high-severity
316
- // AI security threats using YARA and Javelin scanner results. Provides
317
- // defense-in-depth across both prompts and tool calls.
318
- //
319
- // Compliance: NIST 800-53 SI-3, SI-4 | OWASP LLM Top 10: LLM01, LLM02
320
- // MITRE ATLAS: AML.T0051 (LLM Prompt Injection)
321
- // Category: semantic
322
- // Namespace: Overwatch
323
- // =============================================================================
324
-
325
- // Block prompts with prompt injection detected by YARA
326
- @id("semantic-block-injection")
327
- @name("Block prompt injection")
328
- @description("Detect and block prompt injection patterns in user input via YARA scanning (OWASP LLM01)")
329
- @severity("critical")
330
- @tags("injection,security,llm,owasp-llm01,baseline")
331
- forbid (
332
- principal,
333
- action == Overwatch::Action::"process_prompt",
334
- resource
335
- )
336
- when {
337
- context has yara_threats && context.yara_threats.contains("prompt_injection")
338
- };
339
-
340
- // Block prompts with jailbreak attempts
341
- @id("semantic-block-jailbreak")
342
- @name("Block jailbreak attempts")
343
- @description("Detect and block jailbreak and bypass attempts against AI agents (OWASP LLM02)")
344
- @severity("critical")
345
- @tags("jailbreak,bypass,security,owasp-llm02,baseline")
346
- forbid (
347
- principal,
348
- action == Overwatch::Action::"process_prompt",
349
- resource
350
- )
351
- when {
352
- context has yara_threats && context.yara_threats.contains("jailbreak")
353
- };
354
-
355
- // Block prompts with high severity semantic threats
356
- @id("semantic-block-high-severity")
357
- @name("Block high severity threats")
358
- @description("Block prompts when semantic threat scanners detect high severity issues (severity >= 3)")
359
- @severity("high")
360
- @tags("semantic,severity,security")
361
- forbid (
362
- principal,
363
- action == Overwatch::Action::"process_prompt",
364
- resource
365
- )
366
- when {
367
- context has threat_categories && context has max_threat_severity &&
368
- context.threat_categories.contains("semantic") &&
369
- context.max_threat_severity >= 3
370
- };
371
-
372
- // Block prompts with critical threat level
373
- @id("semantic-block-critical")
374
- @name("Block critical threats")
375
- @description("Block all content when any scanner detects critical severity threats")
376
- @severity("critical")
377
- @tags("critical,baseline,security")
378
- forbid (
379
- principal,
380
- action == Overwatch::Action::"process_prompt",
381
- resource
382
- )
383
- when {
384
- context has highest_severity && context.highest_severity == "critical"
385
- };
386
-
387
- // Block tool calls with prompt injection detected
388
- @id("semantic-block-tool-injection")
389
- @name("Block tool calls with injection")
390
- @description("Prevent tool execution when prompt injection patterns are detected in content")
391
- @severity("critical")
392
- @tags("injection,tools,security,owasp-llm01")
393
- forbid (
394
- principal,
395
- action == Overwatch::Action::"call_tool",
396
- resource
397
- )
398
- when {
399
- context has yara_threats && context.yara_threats.contains("prompt_injection")
400
- };
401
- `;
402
-
403
- const OVERWATCH_TOOLS_DEFAULT_CEDAR = `// =============================================================================
404
- // Tool Permissioning Policy (Default)
405
- // =============================================================================
406
- // Controls access to IDE tools, shell execution, file system paths, and MCP
407
- // operations. Blocks dangerous command execution tools and restricts access
408
- // to sensitive system directories and credential files.
409
- //
410
- // Compliance: NIST 800-53 AC-3, AC-6, CM-7 | OWASP A01, A03
411
- // MITRE ATT&CK T1059 (Command/Scripting Interpreter)
412
- // MITRE ATT&CK T1005 (Data from Local System)
413
- // Category: tools
414
- // Namespace: Overwatch
415
- // =============================================================================
416
-
417
- // ---------------------------------------------------------------------------
418
- // Section 1: Dangerous Tool Blocking
419
- // ---------------------------------------------------------------------------
420
-
421
- // Block shell and command execution tools
422
- @id("tools-block-shell-execution")
423
- @name("Block shell and command execution")
424
- @description("Block direct shell, bash, and command execution tools to prevent command injection (MITRE T1059)")
425
- @severity("critical")
426
- @tags("shell,command-injection,execution,nist-cm-7,mitre-t1059,baseline")
427
- forbid (
428
- principal,
429
- action == Overwatch::Action::"call_tool",
430
- resource
431
- )
432
- when {
433
- context has tool_name &&
434
- (context.tool_name == "shell" ||
435
- context.tool_name == "bash" ||
436
- context.tool_name == "sh" ||
437
- context.tool_name == "terminal" ||
438
- context.tool_name == "system.exec" ||
439
- context.tool_name == "process.spawn")
440
- };
441
-
442
- // Block destructive file operations
443
- @id("tools-block-destructive-ops")
444
- @name("Block destructive file operations")
445
- @description("Block file deletion and other destructive tool operations to prevent data loss")
446
- @severity("high")
447
- @tags("file,delete,destructive,nist-ac-3")
448
- forbid (
449
- principal,
450
- action == Overwatch::Action::"call_tool",
451
- resource
452
- )
453
- when {
454
- context has tool_name &&
455
- (context.tool_name == "fs.delete" ||
456
- context.tool_name == "fs.rmdir" ||
457
- context.tool_name == "fs.unlink")
458
- };
459
-
460
- // ---------------------------------------------------------------------------
461
- // Section 2: Sensitive Path Blocking
462
- // ---------------------------------------------------------------------------
463
-
464
- // Block access to sensitive system paths and credential files
465
- @id("tools-block-sensitive-paths")
466
- @name("Block access to sensitive system paths")
467
- @description("Prevent access to system directories, credential files, SSH keys, and cloud config (MITRE T1005, T1552.001)")
468
- @severity("high")
469
- @tags("file,path,system,security,nist-ac-6,mitre-t1005")
470
- forbid (
471
- principal,
472
- action in [Overwatch::Action::"read_file", Overwatch::Action::"write_file", Overwatch::Action::"call_tool"],
473
- resource
474
- )
475
- when {
476
- context has path &&
477
- (context.path like "/etc/*" ||
478
- context.path like "/var/*" ||
479
- context.path like "/proc/*" ||
480
- context.path like "/sys/*" ||
481
- context.path like "/root/*" ||
482
- context.path like "*/.ssh/*" ||
483
- context.path like "*/.aws/*" ||
484
- context.path like "*/.gnupg/*" ||
485
- context.path like "*.pem" ||
486
- context.path like "*/id_rsa*" ||
487
- context.path like "*/id_ed25519*")
488
- };
489
-
490
- // ---------------------------------------------------------------------------
491
- // Section 3: Threat-Based Tool Blocking
492
- // ---------------------------------------------------------------------------
493
-
494
- // Block tool calls with high severity threats detected
495
- @id("tools-block-high-severity-threats")
496
- @name("Block tool calls with high severity threats")
497
- @description("Prevent tool execution when high or critical severity threats are detected in content")
498
- @severity("high")
499
- @tags("tools,threats,severity,security")
500
- forbid (
501
- principal,
502
- action == Overwatch::Action::"call_tool",
503
- resource
504
- )
505
- when {
506
- context has threat_count && context has max_threat_severity &&
507
- context.threat_count > 0 && context.max_threat_severity >= 3
508
- };
509
- `;
510
-
511
- const OVERWATCH_TOOLS_MCP_ALLOWLIST_CEDAR = `// MCP Server Allowlist Template
512
- // Only allow specific MCP servers to be used
513
- // Category: tools
514
- //
515
- // NOTE: Users should customize the mcp_server values in the permit rule
516
- // to match their allowed servers before deploying this template.
517
-
518
- @id("mcp-allowlist-permit")
519
- @name("Allow specific MCP servers")
520
- @description("Only allow connections to pre-approved MCP servers (customize the list)")
521
- @severity("medium")
522
- @tags("mcp,allowlist,server,governance")
523
- permit (
524
- principal,
525
- action == Overwatch::Action::"connect_server",
526
- resource
527
- )
528
- when {
529
- context.mcp_server == "filesystem" ||
530
- context.mcp_server == "playwright"
531
- };
532
-
533
- @id("mcp-allowlist-deny")
534
- @name("Deny unallowed MCP servers")
535
- @description("Block all MCP server connections not in the allowlist")
536
- @severity("medium")
537
- @tags("mcp,deny-default,server")
538
- forbid (
539
- principal,
540
- action == Overwatch::Action::"connect_server",
541
- resource
542
- );
543
- `;
544
-
545
- const OVERWATCH_ORG_DEFAULT_DENY_CEDAR = `// Default Deny All Template
546
- // Organization-wide baseline: deny all unless explicitly permitted
547
- // Category: organization
548
-
549
- @id("org-deny-all")
550
- @name("Deny all actions by default")
551
- @description("Block all actions unless explicitly permitted by other policies - use as organization baseline")
552
- @severity("high")
553
- @tags("baseline,security,deny-by-default,organization")
554
- forbid (
555
- principal,
556
- action,
557
- resource
558
- );
559
- `;
560
-
561
- const OVERWATCH_ORG_AUDIT_ALL_CEDAR = `// Audit All Actions Template
562
- // Log all agent actions for compliance and monitoring
563
- // Category: organization
564
-
565
- @id("org-audit-all")
566
- @name("Audit all actions")
567
- @description("Permit and log all agent actions for compliance auditing and monitoring")
568
- @severity("low")
569
- @tags("audit,compliance,logging,organization")
570
- permit (
571
- principal,
572
- action,
573
- resource
574
- );
575
- `;
576
-
577
- const OVERWATCH_ORG_TEAM_PERMISSIONS_CEDAR = `// Team-Based Permissions (ReBAC)
578
- // Grant IDE access based on team membership using entity hierarchy
579
- // Category: organization
580
- // Namespace: Overwatch
581
- //
582
- // Entity hierarchy required:
583
- // Organization::"acme-corp"
584
- // └── Team::"dev-team" (in Organization)
585
- // │ └── Agent::"claude" (in Team)
586
- // └── Team::"support-team" (in Organization)
587
- // └── Agent::"claude-support" (in Team)
588
-
589
- // Dev Team: Full IDE access - all actions permitted
590
- @id("team-dev-full-access")
591
- @name("Dev team full IDE access")
592
- @description("Grant development team agents full IDE access including tools, prompts, file operations, and server connections")
593
- @severity("medium")
594
- @tags("rebac,team,dev,permissions,organization")
595
- permit (
596
- principal in Overwatch::Team::"dev-team",
597
- action,
598
- resource
599
- );
600
-
601
- // Support Team: Read-only access - process prompts and read files only
602
- @id("team-support-read-only")
603
- @name("Support team read-only access")
604
- @description("Grant support team agents read-only access limited to prompt processing and file reading")
605
- @severity("medium")
606
- @tags("rebac,team,support,read-only,organization")
607
- permit (
608
- principal in Overwatch::Team::"support-team",
609
- action in [Overwatch::Action::"process_prompt", Overwatch::Action::"read_file"],
610
- resource
611
- );
612
- `;
613
-
614
- const OVERWATCH_ORG_AGENT_GUARDRAILS_CEDAR = `// Agent-Specific Guardrails
615
- // Apply per-agent security policies based on agent identity
616
- // Category: organization
617
- // Namespace: Overwatch
618
- //
619
- // Different agents have different risk profiles:
620
- // Claude Code → prompt injection detection
621
- // Cursor → PII leakage detection
622
-
623
- // Claude Code: Block prompt injection attempts
624
- @id("agent-claude-block-injection")
625
- @name("Claude Code injection guardrail")
626
- @description("Block prompt injection attempts specifically for Claude Code agent")
627
- @severity("critical")
628
- @tags("rebac,agent,claude,injection,guardrail,organization")
629
- forbid (
630
- principal == Overwatch::Agent::"claude",
631
- action == Overwatch::Action::"process_prompt",
632
- resource
633
- )
634
- when {
635
- context.yara_threats.contains("prompt_injection")
636
- };
637
-
638
- // Cursor: Block PII leakage
639
- @id("agent-cursor-block-pii")
640
- @name("Cursor PII guardrail")
641
- @description("Block PII content in Cursor agent prompts to prevent data leakage")
642
- @severity("critical")
643
- @tags("rebac,agent,cursor,pii,guardrail,organization")
644
- forbid (
645
- principal == Overwatch::Agent::"cursor",
646
- action == Overwatch::Action::"process_prompt",
647
- resource
648
- )
649
- when {
650
- context.threat_categories.contains("pii")
651
- };
652
- `;
653
-
654
- // =============================================================================
655
- // CATEGORIES
656
- // =============================================================================
657
-
658
- export const OVERWATCH_CATEGORIES: OverwatchCategoryInfo[] = [
659
- { id: 'secrets', name: 'Secrets Detection', description: 'Detect and block credentials, tokens, API keys, and sensitive key patterns in prompts, tool calls, and AI responses' },
660
- { id: 'pii', name: 'PII Detection', description: 'Detect and block personally identifiable information (PII) such as credit card numbers, SSNs, and other sensitive data' },
661
- { id: 'semantic', name: 'Semantic Threat Detection', description: 'Detect and block prompt injection, jailbreak attempts, and high-severity AI security threats' },
662
- { id: 'tools', name: 'Tool Permissioning', description: 'Control access to shell execution, file operations, MCP servers, and sensitive system paths' },
663
- { id: 'organization', name: 'Organization Rules', description: 'Apply organization-wide policy baselines, team permissions, and agent-specific guardrails' },
664
- ];
665
-
666
- // =============================================================================
667
- // DEFAULT POLICIES
668
- // =============================================================================
669
-
670
- export const OVERWATCH_DEFAULTS: OverwatchDefaultPolicy[] = [
671
- {
672
- id: 'secrets-default',
673
- name: 'Secrets Detection',
674
- description: 'Detect and block credential leakage across prompts, tool calls, file operations, and AI response content',
675
- category: 'secrets',
676
- cedarText: OVERWATCH_SECRETS_DEFAULT_CEDAR,
677
- severity: 'critical',
678
- tags: ['api-keys', 'tokens', 'credentials', 'aws', 'github', 'ssh', 'baseline'],
679
- isActive: true,
680
- },
681
- {
682
- id: 'pii-default',
683
- name: 'PII Detection',
684
- description: 'Detect and block credit card numbers, SSN, and other sensitive personal information in prompts and tool calls',
685
- category: 'pii',
686
- cedarText: OVERWATCH_PII_DEFAULT_CEDAR,
687
- severity: 'critical',
688
- tags: ['pii', 'privacy', 'compliance', 'pci-dss', 'gdpr', 'baseline'],
689
- isActive: true,
690
- },
691
- {
692
- id: 'semantic-default',
693
- name: 'Semantic Threat Detection',
694
- description: 'Detect and block prompt injection, jailbreak attempts, and high-severity AI security threats',
695
- category: 'semantic',
696
- cedarText: OVERWATCH_SEMANTIC_DEFAULT_CEDAR,
697
- severity: 'critical',
698
- tags: ['prompt-injection', 'jailbreak', 'owasp-llm01', 'security', 'baseline'],
699
- isActive: true,
700
- },
701
- {
702
- id: 'tools-default',
703
- name: 'Tool Permissioning',
704
- description: 'Block dangerous shell execution, restrict sensitive file paths, and enforce threat-based tool access controls',
705
- category: 'tools',
706
- cedarText: OVERWATCH_TOOLS_DEFAULT_CEDAR,
707
- severity: 'critical',
708
- tags: ['shell', 'command-injection', 'file-access', 'mitre-t1059', 'baseline'],
709
- isActive: false,
710
- },
711
- ];
712
-
713
- // =============================================================================
714
- // ALL TEMPLATES
715
- // =============================================================================
716
-
717
- export const OVERWATCH_TEMPLATES: OverwatchTemplate[] = [
718
- {
719
- id: 'tools-mcp-allowlist',
720
- name: 'MCP Server Allowlist',
721
- description: 'Only allow specific MCP servers to be used',
722
- category: 'tools',
723
- cedarText: OVERWATCH_TOOLS_MCP_ALLOWLIST_CEDAR,
724
- severity: 'medium',
725
- tags: ['mcp', 'allowlist', 'whitelist'],
726
- },
727
- {
728
- id: 'org-default-deny',
729
- name: 'Default Deny All',
730
- description: 'Organization-wide baseline: deny all unless explicitly permitted',
731
- category: 'organization',
732
- cedarText: OVERWATCH_ORG_DEFAULT_DENY_CEDAR,
733
- severity: 'high',
734
- tags: ['baseline', 'security', 'deny-by-default'],
735
- },
736
- {
737
- id: 'org-audit-all',
738
- name: 'Audit All Actions',
739
- description: 'Log all agent actions for compliance and monitoring',
740
- category: 'organization',
741
- cedarText: OVERWATCH_ORG_AUDIT_ALL_CEDAR,
742
- severity: 'low',
743
- tags: ['audit', 'compliance', 'logging'],
744
- },
745
- {
746
- id: 'org-team-permissions',
747
- name: 'Team-Based Permissions (ReBAC)',
748
- description: 'Grant IDE access based on team membership using entity hierarchy - supports dev team full access and support team read-only',
749
- category: 'organization',
750
- cedarText: OVERWATCH_ORG_TEAM_PERMISSIONS_CEDAR,
751
- severity: 'medium',
752
- tags: ['rebac', 'team', 'permissions', 'hierarchy'],
753
- },
754
- {
755
- id: 'org-agent-guardrails',
756
- name: 'Agent-Specific Guardrails',
757
- description: 'Apply per-agent security guardrails - injection blocking for Claude, PII blocking for Cursor',
758
- category: 'organization',
759
- cedarText: OVERWATCH_ORG_AGENT_GUARDRAILS_CEDAR,
760
- severity: 'critical',
761
- tags: ['rebac', 'agent', 'guardrails', 'per-agent'],
762
- },
763
- ];
764
-
765
- // =============================================================================
766
- // TEMPLATES METADATA
767
- // =============================================================================
768
-
769
- /** Raw templates.json metadata for the Overwatch service. */
770
- export const OVERWATCH_TEMPLATES_JSON: string = `{
771
- "service": "overwatch",
772
- "version": "2.0.0",
773
- "description": "Overwatch policy templates for IDE security",
774
- "categories": [
775
- {
776
- "id": "secrets",
777
- "name": "Secrets Detection",
778
- "description": "Detect and block credentials, tokens, API keys, and sensitive key patterns in prompts, tool calls, and AI responses"
779
- },
780
- {
781
- "id": "pii",
782
- "name": "PII Detection",
783
- "description": "Detect and block personally identifiable information (PII) such as credit card numbers, SSNs, and other sensitive data"
784
- },
785
- {
786
- "id": "semantic",
787
- "name": "Semantic Threat Detection",
788
- "description": "Detect and block prompt injection, jailbreak attempts, and high-severity AI security threats"
789
- },
790
- {
791
- "id": "tools",
792
- "name": "Tool Permissioning",
793
- "description": "Control access to shell execution, file operations, MCP servers, and sensitive system paths"
794
- },
795
- {
796
- "id": "organization",
797
- "name": "Organization Rules",
798
- "description": "Apply organization-wide policy baselines, team permissions, and agent-specific guardrails"
799
- }
800
- ],
801
- "defaults": [
802
- {
803
- "id": "secrets-default",
804
- "name": "Secrets Detection",
805
- "description": "Detect and block credential leakage across prompts, tool calls, file operations, and AI response content",
806
- "category": "secrets",
807
- "file": "defaults/secrets.cedar",
808
- "severity": "critical",
809
- "tags": ["api-keys", "tokens", "credentials", "aws", "github", "ssh", "baseline"],
810
- "is_active": true
811
- },
812
- {
813
- "id": "pii-default",
814
- "name": "PII Detection",
815
- "description": "Detect and block credit card numbers, SSN, and other sensitive personal information in prompts and tool calls",
816
- "category": "pii",
817
- "file": "defaults/pii.cedar",
818
- "severity": "critical",
819
- "tags": ["pii", "privacy", "compliance", "pci-dss", "gdpr", "baseline"],
820
- "is_active": true
821
- },
822
- {
823
- "id": "semantic-default",
824
- "name": "Semantic Threat Detection",
825
- "description": "Detect and block prompt injection, jailbreak attempts, and high-severity AI security threats",
826
- "category": "semantic",
827
- "file": "defaults/semantic.cedar",
828
- "severity": "critical",
829
- "tags": ["prompt-injection", "jailbreak", "owasp-llm01", "security", "baseline"],
830
- "is_active": true
831
- },
832
- {
833
- "id": "tools-default",
834
- "name": "Tool Permissioning",
835
- "description": "Block dangerous shell execution, restrict sensitive file paths, and enforce threat-based tool access controls",
836
- "category": "tools",
837
- "file": "defaults/tools.cedar",
838
- "severity": "critical",
839
- "tags": ["shell", "command-injection", "file-access", "mitre-t1059", "baseline"],
840
- "is_active": false
841
- }
842
- ],
843
- "templates": [
844
- {
845
- "id": "tools-mcp-allowlist",
846
- "name": "MCP Server Allowlist",
847
- "description": "Only allow specific MCP servers to be used",
848
- "category": "tools",
849
- "file": "mcp_server_allowlist.cedar",
850
- "severity": "medium",
851
- "tags": ["mcp", "allowlist", "whitelist"]
852
- },
853
- {
854
- "id": "org-default-deny",
855
- "name": "Default Deny All",
856
- "description": "Organization-wide baseline: deny all unless explicitly permitted",
857
- "category": "organization",
858
- "file": "default_deny_all.cedar",
859
- "severity": "high",
860
- "tags": ["baseline", "security", "deny-by-default"]
861
- },
862
- {
863
- "id": "org-audit-all",
864
- "name": "Audit All Actions",
865
- "description": "Log all agent actions for compliance and monitoring",
866
- "category": "organization",
867
- "file": "audit_all_actions.cedar",
868
- "severity": "low",
869
- "tags": ["audit", "compliance", "logging"]
870
- },
871
- {
872
- "id": "org-team-permissions",
873
- "name": "Team-Based Permissions (ReBAC)",
874
- "description": "Grant IDE access based on team membership using entity hierarchy - supports dev team full access and support team read-only",
875
- "category": "organization",
876
- "file": "team_permissions.cedar",
877
- "severity": "medium",
878
- "tags": ["rebac", "team", "permissions", "hierarchy"]
879
- },
880
- {
881
- "id": "org-agent-guardrails",
882
- "name": "Agent-Specific Guardrails",
883
- "description": "Apply per-agent security guardrails - injection blocking for Claude, PII blocking for Cursor",
884
- "category": "organization",
885
- "file": "agent_guardrails.cedar",
886
- "severity": "critical",
887
- "tags": ["rebac", "agent", "guardrails", "per-agent"]
888
- }
889
- ]
890
- }
891
- `;
892
-
893
- // =============================================================================
894
- // HELPER FUNCTIONS
895
- // =============================================================================
896
-
897
- export function getOverwatchDefaultsByCategory(category: OverwatchCategory): OverwatchDefaultPolicy[] {
898
- return OVERWATCH_DEFAULTS.filter(d => d.category === category);
899
- }
900
-
901
- export function getOverwatchTemplatesByCategory(category: OverwatchCategory): OverwatchTemplate[] {
902
- return OVERWATCH_TEMPLATES.filter(t => t.category === category);
903
- }
904
-
905
- export function getOverwatchTemplateById(id: string): OverwatchTemplate | undefined {
906
- return OVERWATCH_TEMPLATES.find(t => t.id === id);
907
- }