@highflame/policy 2.0.6 → 2.0.8
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.
- package/_schemas/overwatch/context.json +163 -1
- package/_schemas/overwatch/schema.cedarschema +45 -0
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +13 -4
- package/dist/builder.js.map +1 -1
- package/dist/overwatch-context.gen.d.ts +13 -0
- package/dist/overwatch-context.gen.d.ts.map +1 -1
- package/dist/overwatch-context.gen.js +13 -0
- package/dist/overwatch-context.gen.js.map +1 -1
- package/dist/overwatch-defaults.gen.d.ts +1 -1
- package/dist/overwatch-defaults.gen.d.ts.map +1 -1
- package/dist/overwatch-defaults.gen.js +346 -1
- package/dist/overwatch-defaults.gen.js.map +1 -1
- package/dist/overwatch-defaults.test.js +5 -5
- package/dist/overwatch-defaults.test.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +60 -12
- package/dist/parser.js.map +1 -1
- package/dist/parser.test.js +76 -7
- package/dist/parser.test.js.map +1 -1
- package/dist/schemas.test.js +32 -0
- package/dist/schemas.test.js.map +1 -1
- package/package.json +1 -1
- package/src/builder.ts +11 -4
- package/src/overwatch-context.gen.ts +13 -0
- package/src/overwatch-defaults.gen.ts +350 -2
- package/src/overwatch-defaults.test.ts +5 -5
- package/src/parser.test.ts +89 -7
- package/src/parser.ts +66 -12
- package/src/schemas.test.ts +32 -0
|
@@ -7,6 +7,31 @@
|
|
|
7
7
|
// =============================================================================
|
|
8
8
|
// EMBEDDED CEDAR POLICY TEXT
|
|
9
9
|
// =============================================================================
|
|
10
|
+
const OVERWATCH_BASELINE_DEFAULT_CEDAR = `// =============================================================================
|
|
11
|
+
// Baseline Permit Policy (Default)
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// Permits all actions by default. Threat-specific forbid policies override
|
|
14
|
+
// this to block when YARA, Javelin, or other scanners detect issues.
|
|
15
|
+
//
|
|
16
|
+
// Cedar is default-deny: without at least one permit rule, every request
|
|
17
|
+
// is denied regardless of forbid rules. This baseline ensures the system
|
|
18
|
+
// is "allow unless blocked" rather than "block everything".
|
|
19
|
+
//
|
|
20
|
+
// Category: organization
|
|
21
|
+
// Namespace: Overwatch
|
|
22
|
+
// =============================================================================
|
|
23
|
+
|
|
24
|
+
@id("baseline-permit-all")
|
|
25
|
+
@name("Permit all actions by default")
|
|
26
|
+
@description("Baseline permit for all actions — threat-specific forbid policies override this when threats are detected")
|
|
27
|
+
@severity("low")
|
|
28
|
+
@tags("baseline,permit-default,organization")
|
|
29
|
+
permit (
|
|
30
|
+
principal,
|
|
31
|
+
action,
|
|
32
|
+
resource
|
|
33
|
+
);
|
|
34
|
+
`;
|
|
10
35
|
const OVERWATCH_SECRETS_DEFAULT_CEDAR = `// =============================================================================
|
|
11
36
|
// Secrets Detection Policy (Default)
|
|
12
37
|
// =============================================================================
|
|
@@ -233,6 +258,22 @@ when {
|
|
|
233
258
|
context has threat_categories && context.threat_categories.contains("pii")
|
|
234
259
|
};
|
|
235
260
|
|
|
261
|
+
// Block prompts with high PII confidence score
|
|
262
|
+
@id("pii-block-high-confidence")
|
|
263
|
+
@name("Block high-confidence PII")
|
|
264
|
+
@description("Block content when PII classifier confidence exceeds threshold (80/100)")
|
|
265
|
+
@severity("critical")
|
|
266
|
+
@tags("pii,confidence,privacy,compliance")
|
|
267
|
+
@reject_message("Your content was blocked because personally identifiable information was detected with high confidence.")
|
|
268
|
+
forbid (
|
|
269
|
+
principal,
|
|
270
|
+
action == Overwatch::Action::"process_prompt",
|
|
271
|
+
resource
|
|
272
|
+
)
|
|
273
|
+
when {
|
|
274
|
+
context has pii_confidence && context.pii_confidence >= 80
|
|
275
|
+
};
|
|
276
|
+
|
|
236
277
|
// Block PII leakage via tool calls
|
|
237
278
|
@id("pii-block-tool-calls")
|
|
238
279
|
@name("Block tool calls with PII")
|
|
@@ -276,6 +317,22 @@ when {
|
|
|
276
317
|
context has yara_threats && context.yara_threats.contains("prompt_injection")
|
|
277
318
|
};
|
|
278
319
|
|
|
320
|
+
// Block prompts with high injection confidence score
|
|
321
|
+
@id("semantic-block-injection-score")
|
|
322
|
+
@name("Block high-confidence injection")
|
|
323
|
+
@description("Block content when injection classifier confidence exceeds threshold (75/100)")
|
|
324
|
+
@severity("critical")
|
|
325
|
+
@tags("injection,confidence,security,owasp-llm01")
|
|
326
|
+
@reject_message("Your prompt was blocked because a high-confidence prompt injection pattern was detected.")
|
|
327
|
+
forbid (
|
|
328
|
+
principal,
|
|
329
|
+
action in [Overwatch::Action::"process_prompt", Overwatch::Action::"call_tool"],
|
|
330
|
+
resource
|
|
331
|
+
)
|
|
332
|
+
when {
|
|
333
|
+
context has injection_confidence && context.injection_confidence >= 75
|
|
334
|
+
};
|
|
335
|
+
|
|
279
336
|
// Block prompts with jailbreak attempts
|
|
280
337
|
@id("semantic-block-jailbreak")
|
|
281
338
|
@name("Block jailbreak attempts")
|
|
@@ -291,6 +348,22 @@ when {
|
|
|
291
348
|
context has yara_threats && context.yara_threats.contains("jailbreak")
|
|
292
349
|
};
|
|
293
350
|
|
|
351
|
+
// Block prompts with high jailbreak confidence score
|
|
352
|
+
@id("semantic-block-jailbreak-score")
|
|
353
|
+
@name("Block high-confidence jailbreak")
|
|
354
|
+
@description("Block content when jailbreak classifier confidence exceeds threshold (75/100)")
|
|
355
|
+
@severity("critical")
|
|
356
|
+
@tags("jailbreak,confidence,security,owasp-llm02")
|
|
357
|
+
@reject_message("Your prompt was blocked because a high-confidence jailbreak attempt was detected.")
|
|
358
|
+
forbid (
|
|
359
|
+
principal,
|
|
360
|
+
action in [Overwatch::Action::"process_prompt", Overwatch::Action::"call_tool"],
|
|
361
|
+
resource
|
|
362
|
+
)
|
|
363
|
+
when {
|
|
364
|
+
context has jailbreak_confidence && context.jailbreak_confidence >= 75
|
|
365
|
+
};
|
|
366
|
+
|
|
294
367
|
// Block prompts with high severity semantic threats
|
|
295
368
|
@id("semantic-block-high-severity")
|
|
296
369
|
@name("Block high severity threats")
|
|
@@ -445,6 +518,206 @@ when {
|
|
|
445
518
|
context.threat_count > 0 && context.max_threat_severity >= 3
|
|
446
519
|
};
|
|
447
520
|
`;
|
|
521
|
+
const OVERWATCH_TRUST_SAFETY_DEFAULT_CEDAR = `// =============================================================================
|
|
522
|
+
// Content Safety Policy (Default)
|
|
523
|
+
// =============================================================================
|
|
524
|
+
// Detects and blocks violent, harmful, hateful, sexual, and profane content
|
|
525
|
+
// using trust/safety classification scores from Javelin/Lakera/LlamaGuard.
|
|
526
|
+
//
|
|
527
|
+
// Compliance: NIST 800-53 SI-4 | EU AI Act Art. 52
|
|
528
|
+
// Category: trust_safety
|
|
529
|
+
// Namespace: Overwatch
|
|
530
|
+
// =============================================================================
|
|
531
|
+
|
|
532
|
+
// Block prompts with high violence score
|
|
533
|
+
@id("ts-block-violence")
|
|
534
|
+
@name("Block violent content")
|
|
535
|
+
@description("Block content when violence detection score exceeds threshold (80/100)")
|
|
536
|
+
@severity("critical")
|
|
537
|
+
@tags("violence,content-safety,trust-safety,nist-si-4")
|
|
538
|
+
@reject_message("Your prompt was blocked because it contains violent content. Please rephrase without violence-related language.")
|
|
539
|
+
forbid (
|
|
540
|
+
principal,
|
|
541
|
+
action in [Overwatch::Action::"process_prompt", Overwatch::Action::"call_tool"],
|
|
542
|
+
resource
|
|
543
|
+
)
|
|
544
|
+
when {
|
|
545
|
+
context has violence_score && context.violence_score >= 80
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
// Block prompts with weapons content
|
|
549
|
+
@id("ts-block-weapons")
|
|
550
|
+
@name("Block weapons content")
|
|
551
|
+
@description("Block content when weapons detection score exceeds threshold (80/100)")
|
|
552
|
+
@severity("critical")
|
|
553
|
+
@tags("weapons,content-safety,trust-safety,nist-si-4")
|
|
554
|
+
@reject_message("Your prompt was blocked because it contains weapons-related content. Please rephrase without weapons references.")
|
|
555
|
+
forbid (
|
|
556
|
+
principal,
|
|
557
|
+
action in [Overwatch::Action::"process_prompt", Overwatch::Action::"call_tool"],
|
|
558
|
+
resource
|
|
559
|
+
)
|
|
560
|
+
when {
|
|
561
|
+
context has weapons_score && context.weapons_score >= 80
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
// Block prompts with hate speech
|
|
565
|
+
@id("ts-block-hate-speech")
|
|
566
|
+
@name("Block hate speech")
|
|
567
|
+
@description("Block content when hate speech detection score exceeds threshold (75/100)")
|
|
568
|
+
@severity("critical")
|
|
569
|
+
@tags("hate-speech,content-safety,trust-safety,nist-si-4")
|
|
570
|
+
@reject_message("Your prompt was blocked because it contains hate speech. Please rephrase without hateful or discriminatory language.")
|
|
571
|
+
forbid (
|
|
572
|
+
principal,
|
|
573
|
+
action in [Overwatch::Action::"process_prompt", Overwatch::Action::"call_tool"],
|
|
574
|
+
resource
|
|
575
|
+
)
|
|
576
|
+
when {
|
|
577
|
+
context has hate_speech_score && context.hate_speech_score >= 75
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
// Block prompts with criminal content
|
|
581
|
+
@id("ts-block-crime")
|
|
582
|
+
@name("Block criminal content")
|
|
583
|
+
@description("Block content when criminal activity detection score exceeds threshold (80/100)")
|
|
584
|
+
@severity("high")
|
|
585
|
+
@tags("crime,content-safety,trust-safety,nist-si-4")
|
|
586
|
+
@reject_message("Your prompt was blocked because it contains content related to criminal activity.")
|
|
587
|
+
forbid (
|
|
588
|
+
principal,
|
|
589
|
+
action in [Overwatch::Action::"process_prompt", Overwatch::Action::"call_tool"],
|
|
590
|
+
resource
|
|
591
|
+
)
|
|
592
|
+
when {
|
|
593
|
+
context has crime_score && context.crime_score >= 80
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
// Block prompts with sexual content
|
|
597
|
+
@id("ts-block-sexual")
|
|
598
|
+
@name("Block sexual content")
|
|
599
|
+
@description("Block content when sexual content detection score exceeds threshold (80/100)")
|
|
600
|
+
@severity("high")
|
|
601
|
+
@tags("sexual,content-safety,trust-safety,eu-ai-act")
|
|
602
|
+
@reject_message("Your prompt was blocked because it contains sexual content.")
|
|
603
|
+
forbid (
|
|
604
|
+
principal,
|
|
605
|
+
action in [Overwatch::Action::"process_prompt", Overwatch::Action::"call_tool"],
|
|
606
|
+
resource
|
|
607
|
+
)
|
|
608
|
+
when {
|
|
609
|
+
context has sexual_score && context.sexual_score >= 80
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
// Block prompts with excessive profanity
|
|
613
|
+
@id("ts-block-profanity")
|
|
614
|
+
@name("Block profanity")
|
|
615
|
+
@description("Block content when profanity detection score exceeds threshold (90/100)")
|
|
616
|
+
@severity("medium")
|
|
617
|
+
@tags("profanity,content-safety,trust-safety")
|
|
618
|
+
@reject_message("Your prompt was blocked due to excessive profanity. Please rephrase in a professional manner.")
|
|
619
|
+
forbid (
|
|
620
|
+
principal,
|
|
621
|
+
action in [Overwatch::Action::"process_prompt", Overwatch::Action::"call_tool"],
|
|
622
|
+
resource
|
|
623
|
+
)
|
|
624
|
+
when {
|
|
625
|
+
context has profanity_score && context.profanity_score >= 90
|
|
626
|
+
};
|
|
627
|
+
`;
|
|
628
|
+
const OVERWATCH_AGENT_SECURITY_DEFAULT_CEDAR = `// =============================================================================
|
|
629
|
+
// Agent Security Policy (Default)
|
|
630
|
+
// =============================================================================
|
|
631
|
+
// Detects and blocks tool poisoning, rug pull attacks, and indirect prompt
|
|
632
|
+
// injection targeting AI coding agents. These are agentic AI-specific attack
|
|
633
|
+
// vectors where tool descriptions or server responses manipulate agent behavior.
|
|
634
|
+
//
|
|
635
|
+
// Compliance: OWASP LLM09 (Improper Output Handling) | MITRE ATLAS AML.T0054
|
|
636
|
+
// Category: agent_security
|
|
637
|
+
// Namespace: Overwatch
|
|
638
|
+
// =============================================================================
|
|
639
|
+
|
|
640
|
+
// Block tool calls with high tool poisoning risk
|
|
641
|
+
@id("as-block-tool-poisoning")
|
|
642
|
+
@name("Block tool poisoning")
|
|
643
|
+
@description("Block tool execution when tool description contains manipulation patterns (score >= 70/100)")
|
|
644
|
+
@severity("critical")
|
|
645
|
+
@tags("tool-poisoning,agent-security,owasp-llm09")
|
|
646
|
+
@reject_message("Tool execution was blocked because the tool description contains manipulation patterns that could compromise agent behavior.")
|
|
647
|
+
forbid (
|
|
648
|
+
principal,
|
|
649
|
+
action == Overwatch::Action::"call_tool",
|
|
650
|
+
resource
|
|
651
|
+
)
|
|
652
|
+
when {
|
|
653
|
+
context has tool_poisoning_score && context.tool_poisoning_score >= 70
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
// Block tool calls with rug pull detection
|
|
657
|
+
@id("as-block-rug-pull")
|
|
658
|
+
@name("Block rug pull attacks")
|
|
659
|
+
@description("Block tool execution when tool behavior diverges from advertised capabilities (score >= 70/100)")
|
|
660
|
+
@severity("critical")
|
|
661
|
+
@tags("rug-pull,agent-security,mcp-security")
|
|
662
|
+
@reject_message("Tool execution was blocked because the tool's actual behavior diverges from its advertised capabilities.")
|
|
663
|
+
forbid (
|
|
664
|
+
principal,
|
|
665
|
+
action in [Overwatch::Action::"call_tool", Overwatch::Action::"connect_server"],
|
|
666
|
+
resource
|
|
667
|
+
)
|
|
668
|
+
when {
|
|
669
|
+
context has rug_pull_score && context.rug_pull_score >= 70
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
// Block MCP server connections with high poisoning risk
|
|
673
|
+
@id("as-block-server-poisoning")
|
|
674
|
+
@name("Block poisoned MCP servers")
|
|
675
|
+
@description("Block connections to MCP servers when tool poisoning patterns are detected (score >= 60/100)")
|
|
676
|
+
@severity("critical")
|
|
677
|
+
@tags("tool-poisoning,mcp-security,agent-security")
|
|
678
|
+
@reject_message("Connection to this MCP server was blocked because tool poisoning patterns were detected in its tool descriptions.")
|
|
679
|
+
forbid (
|
|
680
|
+
principal,
|
|
681
|
+
action == Overwatch::Action::"connect_server",
|
|
682
|
+
resource
|
|
683
|
+
)
|
|
684
|
+
when {
|
|
685
|
+
context has tool_poisoning_score && context.tool_poisoning_score >= 60
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
// Block prompts with indirect injection patterns
|
|
689
|
+
@id("as-block-indirect-injection")
|
|
690
|
+
@name("Block indirect prompt injection")
|
|
691
|
+
@description("Block content when indirect prompt injection is detected in tool outputs or retrieved documents (score >= 70/100)")
|
|
692
|
+
@severity("critical")
|
|
693
|
+
@tags("indirect-injection,agent-security,owasp-llm01")
|
|
694
|
+
@reject_message("This content was blocked because indirect prompt injection patterns were detected in tool outputs or retrieved documents.")
|
|
695
|
+
forbid (
|
|
696
|
+
principal,
|
|
697
|
+
action in [Overwatch::Action::"process_prompt", Overwatch::Action::"call_tool", Overwatch::Action::"connect_server"],
|
|
698
|
+
resource
|
|
699
|
+
)
|
|
700
|
+
when {
|
|
701
|
+
context has indirect_injection_score && context.indirect_injection_score >= 70
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
// Block unverified MCP server tool calls with any detected threats
|
|
705
|
+
@id("as-block-unverified-threats")
|
|
706
|
+
@name("Block unverified server threats")
|
|
707
|
+
@description("Block tool calls from unverified MCP servers when any threat is detected")
|
|
708
|
+
@severity("high")
|
|
709
|
+
@tags("mcp-trust,agent-security,unverified")
|
|
710
|
+
@reject_message("Tool execution was blocked because the MCP server is unverified and threats were detected in the content.")
|
|
711
|
+
forbid (
|
|
712
|
+
principal,
|
|
713
|
+
action == Overwatch::Action::"call_tool",
|
|
714
|
+
resource
|
|
715
|
+
)
|
|
716
|
+
when {
|
|
717
|
+
context has mcp_server_verified && context.mcp_server_verified == false &&
|
|
718
|
+
context has threat_count && context.threat_count > 0
|
|
719
|
+
};
|
|
720
|
+
`;
|
|
448
721
|
const OVERWATCH_TOOLS_MCP_ALLOWLIST_CEDAR = `// MCP Server Allowlist Template
|
|
449
722
|
// Only allow specific MCP servers to be used
|
|
450
723
|
// Category: tools
|
|
@@ -592,11 +865,23 @@ export const OVERWATCH_CATEGORIES = [
|
|
|
592
865
|
{ id: 'semantic', name: 'Semantic Threat Detection', description: 'Detect and block prompt injection, jailbreak attempts, and high-severity AI security threats' },
|
|
593
866
|
{ id: 'tools', name: 'Tool Permissioning', description: 'Control access to shell execution, file operations, MCP servers, and sensitive system paths' },
|
|
594
867
|
{ id: 'organization', name: 'Organization Rules', description: 'Apply organization-wide policy baselines, team permissions, and agent-specific guardrails' },
|
|
868
|
+
{ id: 'trust_safety', name: 'Content Safety', description: 'Detect and control violent, harmful, hateful, sexual, and profane content using trust/safety classification scores' },
|
|
869
|
+
{ id: 'agent_security', name: 'Agent Security', description: 'Detect tool poisoning, rug pull attacks, and indirect prompt injection targeting AI agents' },
|
|
595
870
|
];
|
|
596
871
|
// =============================================================================
|
|
597
872
|
// DEFAULT POLICIES
|
|
598
873
|
// =============================================================================
|
|
599
874
|
export const OVERWATCH_DEFAULTS = [
|
|
875
|
+
{
|
|
876
|
+
id: 'baseline-default',
|
|
877
|
+
name: 'Baseline Permit',
|
|
878
|
+
description: 'Permits all actions by default — threat-specific forbid policies override this when threats are detected',
|
|
879
|
+
category: 'organization',
|
|
880
|
+
cedarText: OVERWATCH_BASELINE_DEFAULT_CEDAR,
|
|
881
|
+
severity: 'low',
|
|
882
|
+
tags: ['baseline', 'permit-default', 'organization'],
|
|
883
|
+
isActive: true,
|
|
884
|
+
},
|
|
600
885
|
{
|
|
601
886
|
id: 'secrets-default',
|
|
602
887
|
name: 'Secrets Detection',
|
|
@@ -637,6 +922,26 @@ export const OVERWATCH_DEFAULTS = [
|
|
|
637
922
|
tags: ['shell', 'command-injection', 'file-access', 'mitre-t1059', 'baseline'],
|
|
638
923
|
isActive: false,
|
|
639
924
|
},
|
|
925
|
+
{
|
|
926
|
+
id: 'trust-safety-default',
|
|
927
|
+
name: 'Content Safety',
|
|
928
|
+
description: 'Detect and block violent, harmful, hateful, sexual, and profane content using classification scores',
|
|
929
|
+
category: 'trust_safety',
|
|
930
|
+
cedarText: OVERWATCH_TRUST_SAFETY_DEFAULT_CEDAR,
|
|
931
|
+
severity: 'critical',
|
|
932
|
+
tags: ['violence', 'weapons', 'hate-speech', 'crime', 'sexual', 'profanity', 'content-safety', 'baseline'],
|
|
933
|
+
isActive: true,
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
id: 'agent-security-default',
|
|
937
|
+
name: 'Agent Security',
|
|
938
|
+
description: 'Detect and block tool poisoning, rug pull attacks, and indirect prompt injection targeting AI agents',
|
|
939
|
+
category: 'agent_security',
|
|
940
|
+
cedarText: OVERWATCH_AGENT_SECURITY_DEFAULT_CEDAR,
|
|
941
|
+
severity: 'critical',
|
|
942
|
+
tags: ['tool-poisoning', 'rug-pull', 'indirect-injection', 'mcp-security', 'agent-security', 'baseline'],
|
|
943
|
+
isActive: true,
|
|
944
|
+
},
|
|
640
945
|
];
|
|
641
946
|
// =============================================================================
|
|
642
947
|
// ALL TEMPLATES
|
|
@@ -694,7 +999,7 @@ export const OVERWATCH_TEMPLATES = [
|
|
|
694
999
|
/** Raw templates.json metadata for the Overwatch service. */
|
|
695
1000
|
export const OVERWATCH_TEMPLATES_JSON = `{
|
|
696
1001
|
"service": "overwatch",
|
|
697
|
-
"version": "
|
|
1002
|
+
"version": "3.0.0",
|
|
698
1003
|
"description": "Overwatch policy templates for IDE security",
|
|
699
1004
|
"categories": [
|
|
700
1005
|
{
|
|
@@ -721,9 +1026,29 @@ export const OVERWATCH_TEMPLATES_JSON = `{
|
|
|
721
1026
|
"id": "organization",
|
|
722
1027
|
"name": "Organization Rules",
|
|
723
1028
|
"description": "Apply organization-wide policy baselines, team permissions, and agent-specific guardrails"
|
|
1029
|
+
},
|
|
1030
|
+
{
|
|
1031
|
+
"id": "trust_safety",
|
|
1032
|
+
"name": "Content Safety",
|
|
1033
|
+
"description": "Detect and control violent, harmful, hateful, sexual, and profane content using trust/safety classification scores"
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
"id": "agent_security",
|
|
1037
|
+
"name": "Agent Security",
|
|
1038
|
+
"description": "Detect tool poisoning, rug pull attacks, and indirect prompt injection targeting AI agents"
|
|
724
1039
|
}
|
|
725
1040
|
],
|
|
726
1041
|
"defaults": [
|
|
1042
|
+
{
|
|
1043
|
+
"id": "baseline-default",
|
|
1044
|
+
"name": "Baseline Permit",
|
|
1045
|
+
"description": "Permits all actions by default — threat-specific forbid policies override this when threats are detected",
|
|
1046
|
+
"category": "organization",
|
|
1047
|
+
"file": "defaults/baseline.cedar",
|
|
1048
|
+
"severity": "low",
|
|
1049
|
+
"tags": ["baseline", "permit-default", "organization"],
|
|
1050
|
+
"is_active": true
|
|
1051
|
+
},
|
|
727
1052
|
{
|
|
728
1053
|
"id": "secrets-default",
|
|
729
1054
|
"name": "Secrets Detection",
|
|
@@ -763,6 +1088,26 @@ export const OVERWATCH_TEMPLATES_JSON = `{
|
|
|
763
1088
|
"severity": "critical",
|
|
764
1089
|
"tags": ["shell", "command-injection", "file-access", "mitre-t1059", "baseline"],
|
|
765
1090
|
"is_active": false
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
"id": "trust-safety-default",
|
|
1094
|
+
"name": "Content Safety",
|
|
1095
|
+
"description": "Detect and block violent, harmful, hateful, sexual, and profane content using classification scores",
|
|
1096
|
+
"category": "trust_safety",
|
|
1097
|
+
"file": "defaults/trust_safety.cedar",
|
|
1098
|
+
"severity": "critical",
|
|
1099
|
+
"tags": ["violence", "weapons", "hate-speech", "crime", "sexual", "profanity", "content-safety", "baseline"],
|
|
1100
|
+
"is_active": true
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
"id": "agent-security-default",
|
|
1104
|
+
"name": "Agent Security",
|
|
1105
|
+
"description": "Detect and block tool poisoning, rug pull attacks, and indirect prompt injection targeting AI agents",
|
|
1106
|
+
"category": "agent_security",
|
|
1107
|
+
"file": "defaults/agent_security.cedar",
|
|
1108
|
+
"severity": "critical",
|
|
1109
|
+
"tags": ["tool-poisoning", "rug-pull", "indirect-injection", "mcp-security", "agent-security", "baseline"],
|
|
1110
|
+
"is_active": true
|
|
766
1111
|
}
|
|
767
1112
|
],
|
|
768
1113
|
"templates": [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overwatch-defaults.gen.js","sourceRoot":"","sources":["../src/overwatch-defaults.gen.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,qDAAqD;AACrD,EAAE;AACF,4CAA4C;AAC5C,8EAA8E;AAC9E,6BAA6B;AA2D7B,gFAAgF;AAChF,6BAA6B;AAC7B,gFAAgF;AAEhF,MAAM,+BAA+B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwKvC,CAAC;AAEF,MAAM,2BAA2B,GAAG
|
|
1
|
+
{"version":3,"file":"overwatch-defaults.gen.js","sourceRoot":"","sources":["../src/overwatch-defaults.gen.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,qDAAqD;AACrD,EAAE;AACF,4CAA4C;AAC5C,8EAA8E;AAC9E,6BAA6B;AA2D7B,gFAAgF;AAChF,6BAA6B;AAC7B,gFAAgF;AAEhF,MAAM,gCAAgC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBxC,CAAC;AAEF,MAAM,+BAA+B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwKvC,CAAC;AAEF,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuFnC,CAAC;AAEF,MAAM,gCAAgC,GAAG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;QAC3G,QAAQ,EAAE,cAAc;QACxB,SAAS,EAAE,oCAAoC;QAC/C,QAAQ,EAAE,UAAU;QACpB,IAAI,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC;KACpD;CACF,CAAC;AAEF,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF,6DAA6D;AAC7D,MAAM,CAAC,MAAM,wBAAwB,GAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiK/C,CAAC;AAEF,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF,MAAM,UAAU,8BAA8B,CAAC,QAA2B;IACxE,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,QAA2B;IACzE,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,EAAU;IACjD,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -11,13 +11,13 @@ import { OVERWATCH_DEFAULTS, OVERWATCH_TEMPLATES, OVERWATCH_CATEGORIES, getOverw
|
|
|
11
11
|
// DATA STRUCTURE TESTS
|
|
12
12
|
// =============================================================================
|
|
13
13
|
describe("Overwatch defaults data", () => {
|
|
14
|
-
test("should have
|
|
15
|
-
expect(OVERWATCH_CATEGORIES).toHaveLength(
|
|
14
|
+
test("should have 7 categories", () => {
|
|
15
|
+
expect(OVERWATCH_CATEGORIES).toHaveLength(7);
|
|
16
16
|
const ids = OVERWATCH_CATEGORIES.map((c) => c.id);
|
|
17
|
-
expect(ids).toEqual(["secrets", "pii", "semantic", "tools", "organization"]);
|
|
17
|
+
expect(ids).toEqual(["secrets", "pii", "semantic", "tools", "organization", "trust_safety", "agent_security"]);
|
|
18
18
|
});
|
|
19
|
-
test("should have
|
|
20
|
-
expect(OVERWATCH_DEFAULTS).toHaveLength(
|
|
19
|
+
test("should have 7 default policies", () => {
|
|
20
|
+
expect(OVERWATCH_DEFAULTS).toHaveLength(7);
|
|
21
21
|
});
|
|
22
22
|
test("should have 5 templates", () => {
|
|
23
23
|
expect(OVERWATCH_TEMPLATES).toHaveLength(5);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overwatch-defaults.test.js","sourceRoot":"","sources":["../src/overwatch-defaults.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EAEpB,+BAA+B,EAC/B,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AAErC,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,oBAAoB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,GAAG,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,SA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AAE,CAAC;IACpB,iFAAiF;IACjF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,qCAAqC;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAmDD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAkE,MAAM,cAAc,CAAC;AAI/G;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2DAA2D;IAC3D,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,iFAAiF;IACjF,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,qCAAqC;IACrC,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAmDD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,CAoFhE"}
|
package/dist/parser.js
CHANGED
|
@@ -59,7 +59,12 @@ export function parseCedarToRules(cedarText) {
|
|
|
59
59
|
}
|
|
60
60
|
const policy = jsonResult.json;
|
|
61
61
|
const policyId = policy.annotations?.id || `policy${index}`;
|
|
62
|
-
|
|
62
|
+
// Get engine-serialized Cedar text for rawCondition extraction.
|
|
63
|
+
// Using cedar-wasm's policyToText ensures we get the official engine's
|
|
64
|
+
// representation rather than relying on our own text extraction.
|
|
65
|
+
const engineTextResult = cedar.policyToText(jsonResult.json);
|
|
66
|
+
const engineText = engineTextResult.type === "success" ? engineTextResult.text : policyText;
|
|
67
|
+
const conversion = cedarJsonToRule(policy, policyId, index, engineText);
|
|
63
68
|
if (conversion.error) {
|
|
64
69
|
result.errors.push(`Policy ${policyId}: ${conversion.error}`);
|
|
65
70
|
}
|
|
@@ -129,7 +134,7 @@ function cedarJsonToRule(policy, policyId, index, originalText) {
|
|
|
129
134
|
order: index,
|
|
130
135
|
};
|
|
131
136
|
// Map conditions
|
|
132
|
-
const { conditions, rawCondition } = mapConditions(policy.conditions);
|
|
137
|
+
const { conditions, rawCondition } = mapConditions(policy.conditions, originalText);
|
|
133
138
|
rule.conditions = conditions;
|
|
134
139
|
if (rawCondition) {
|
|
135
140
|
rule.rawCondition = rawCondition;
|
|
@@ -236,6 +241,19 @@ function mapScopeToEntity(scope, field) {
|
|
|
236
241
|
*
|
|
237
242
|
* Throws ParserError for malformed constraints to prevent silent misinterpretation.
|
|
238
243
|
*/
|
|
244
|
+
/**
|
|
245
|
+
* Format action entity reference, preserving namespace if present.
|
|
246
|
+
*
|
|
247
|
+
* If entity type is just "Action", returns just the id (e.g., "process_prompt").
|
|
248
|
+
* If entity type has a namespace (e.g., "Overwatch::Action"),
|
|
249
|
+
* returns the fully qualified action string (e.g., 'Overwatch::Action::"process_prompt"').
|
|
250
|
+
*/
|
|
251
|
+
function formatActionEntity(entity) {
|
|
252
|
+
if (entity.type !== "Action") {
|
|
253
|
+
return `${entity.type}::"${entity.id}"`;
|
|
254
|
+
}
|
|
255
|
+
return entity.id;
|
|
256
|
+
}
|
|
239
257
|
function mapActionScope(scope) {
|
|
240
258
|
if (scope.op === "All") {
|
|
241
259
|
return "*";
|
|
@@ -243,29 +261,31 @@ function mapActionScope(scope) {
|
|
|
243
261
|
if (scope.op === "==") {
|
|
244
262
|
if ("entity" in scope) {
|
|
245
263
|
const entity = normalizeEntityRef(scope.entity);
|
|
246
|
-
return entity
|
|
264
|
+
return formatActionEntity(entity);
|
|
247
265
|
}
|
|
248
266
|
throw ParserError.actionMissingEntity("==");
|
|
249
267
|
}
|
|
250
268
|
if (scope.op === "in") {
|
|
251
269
|
if ("entities" in scope) {
|
|
252
|
-
const actions = scope.entities.map(e => normalizeEntityRef(e)
|
|
270
|
+
const actions = scope.entities.map(e => formatActionEntity(normalizeEntityRef(e)));
|
|
253
271
|
return actions.length === 1 ? actions[0] : actions;
|
|
254
272
|
}
|
|
255
273
|
if ("entity" in scope) {
|
|
256
274
|
const entity = normalizeEntityRef(scope.entity);
|
|
257
|
-
return entity
|
|
275
|
+
return formatActionEntity(entity);
|
|
258
276
|
}
|
|
259
277
|
throw ParserError.actionMissingEntities();
|
|
260
278
|
}
|
|
261
279
|
throw ParserError.actionUnsupportedOp(scope.op);
|
|
262
280
|
}
|
|
263
281
|
/**
|
|
264
|
-
* Map Cedar conditions to PolicyCondition array
|
|
282
|
+
* Map Cedar conditions to PolicyCondition array.
|
|
283
|
+
* When conditions can't be mapped to structured format, extract the raw Cedar
|
|
284
|
+
* condition text from the engine-serialized policy text (not JSON AST).
|
|
265
285
|
*/
|
|
266
|
-
function mapConditions(conditions) {
|
|
286
|
+
function mapConditions(conditions, originalText) {
|
|
267
287
|
const result = [];
|
|
268
|
-
|
|
288
|
+
let hasUnmapped = false;
|
|
269
289
|
for (const cond of conditions) {
|
|
270
290
|
if (cond.kind !== "when") {
|
|
271
291
|
continue;
|
|
@@ -275,16 +295,44 @@ function mapConditions(conditions) {
|
|
|
275
295
|
result.push(parsed.condition);
|
|
276
296
|
}
|
|
277
297
|
else if (parsed.raw) {
|
|
278
|
-
|
|
298
|
+
hasUnmapped = true;
|
|
279
299
|
}
|
|
280
300
|
}
|
|
281
|
-
//
|
|
282
|
-
|
|
301
|
+
// Extract readable Cedar condition text instead of storing JSON AST
|
|
302
|
+
let rawCondition;
|
|
303
|
+
if (hasUnmapped && originalText) {
|
|
304
|
+
rawCondition = extractWhenClause(originalText);
|
|
305
|
+
}
|
|
283
306
|
return {
|
|
284
307
|
conditions: result,
|
|
285
|
-
rawCondition:
|
|
308
|
+
rawCondition: rawCondition || undefined,
|
|
286
309
|
};
|
|
287
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* Extract the readable condition text from a Cedar policy's when clause.
|
|
313
|
+
* Given: `forbid (...)\nwhen { context.path like "/etc/*" };`
|
|
314
|
+
* Returns: `context.path like "/etc/*"`
|
|
315
|
+
*/
|
|
316
|
+
function extractWhenClause(cedarText) {
|
|
317
|
+
const whenPrefix = "when {";
|
|
318
|
+
const idx = cedarText.indexOf(whenPrefix);
|
|
319
|
+
if (idx < 0) {
|
|
320
|
+
return "";
|
|
321
|
+
}
|
|
322
|
+
const body = cedarText.substring(idx + whenPrefix.length);
|
|
323
|
+
let depth = 1;
|
|
324
|
+
for (let i = 0; i < body.length; i++) {
|
|
325
|
+
if (body[i] === "{")
|
|
326
|
+
depth++;
|
|
327
|
+
if (body[i] === "}") {
|
|
328
|
+
depth--;
|
|
329
|
+
if (depth === 0) {
|
|
330
|
+
return body.substring(0, i).trim();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return body.trim();
|
|
335
|
+
}
|
|
288
336
|
/**
|
|
289
337
|
* Map a Cedar expression body to PolicyCondition
|
|
290
338
|
*
|