@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
package/src/errors.ts DELETED
@@ -1,195 +0,0 @@
1
- /**
2
- * Parser error types and codes for highflame-policy.
3
- *
4
- * This module provides standardized error codes that are consistent
5
- * across all language implementations (Rust, Go, TypeScript, Python).
6
- */
7
-
8
- /**
9
- * Error codes for parser errors.
10
- *
11
- * These codes are stable and consistent across all language implementations.
12
- * Format: HFP-<CATEGORY>-<NUMBER>
13
- * - HFP = HighFlame Policy
14
- * - CATEGORY = SCOPE | ACTION | COND | PARSE
15
- * - NUMBER = 3-digit incremental
16
- */
17
- export const ErrorCodes = {
18
- // Scope constraint errors (HFP-SCOPE-xxx)
19
- /** Scope constraint is missing an entity (for == operator) */
20
- SCOPE_MISSING_ENTITY: "HFP-SCOPE-001",
21
- /** Scope constraint is missing an entity type (for is operator) */
22
- SCOPE_MISSING_ENTITY_TYPE: "HFP-SCOPE-002",
23
- /** Scope constraint is missing entity list (for in operator) */
24
- SCOPE_MISSING_ENTITY_LIST: "HFP-SCOPE-003",
25
- /** Slot constraints are not supported in PolicyRule */
26
- SCOPE_SLOT_NOT_SUPPORTED: "HFP-SCOPE-004",
27
- /** Unsupported scope operator */
28
- SCOPE_UNSUPPORTED_OP: "HFP-SCOPE-005",
29
-
30
- // Action constraint errors (HFP-ACTION-xxx)
31
- /** Action constraint is missing an entity (for == operator) */
32
- ACTION_MISSING_ENTITY: "HFP-ACTION-001",
33
- /** Action constraint is missing entities (for in operator) */
34
- ACTION_MISSING_ENTITIES: "HFP-ACTION-002",
35
- /** Unsupported action operator */
36
- ACTION_UNSUPPORTED_OP: "HFP-ACTION-003",
37
- /** Action scope is null/nil */
38
- ACTION_SCOPE_NIL: "HFP-ACTION-004",
39
-
40
- // Condition errors (HFP-COND-xxx)
41
- /** Unless clauses are not supported in PolicyRule */
42
- COND_UNLESS_NOT_SUPPORTED: "HFP-COND-001",
43
- /** Complex condition cannot be parsed */
44
- COND_COMPLEX_EXPRESSION: "HFP-COND-002",
45
-
46
- // Parse errors (HFP-PARSE-xxx)
47
- /** Invalid Cedar syntax */
48
- PARSE_INVALID_SYNTAX: "HFP-PARSE-001",
49
- /** Failed to convert policy to JSON */
50
- PARSE_JSON_CONVERSION: "HFP-PARSE-002",
51
- /** Failed to parse Cedar JSON structure */
52
- PARSE_JSON_STRUCTURE: "HFP-PARSE-003",
53
- /** Unknown policy effect (not permit or forbid) */
54
- PARSE_UNKNOWN_EFFECT: "HFP-PARSE-004",
55
- /** Duplicate policy ID found */
56
- PARSE_DUPLICATE_ID: "HFP-PARSE-005",
57
- } as const;
58
-
59
- export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
60
-
61
- /**
62
- * Context information for parser errors.
63
- */
64
- export interface ErrorContext {
65
- /** The operator that caused the error (e.g., "==", "in", "is") */
66
- operator?: string;
67
- /** The field that caused the error (e.g., "principal", "action", "resource") */
68
- field?: string;
69
- /** The policy ID if available */
70
- policyId?: string;
71
- }
72
-
73
- /**
74
- * A structured parser error with code, message, and optional context.
75
- */
76
- export class ParserError extends Error {
77
- /** Machine-readable error code (e.g., "HFP-SCOPE-001") */
78
- public readonly code: ErrorCode;
79
- /** Optional context for debugging */
80
- public readonly context?: ErrorContext;
81
-
82
- constructor(code: ErrorCode, message: string, context?: ErrorContext) {
83
- super(message);
84
- this.name = "ParserError";
85
- this.code = code;
86
- this.context = context;
87
-
88
- // Maintains proper stack trace for where our error was thrown (only available on V8)
89
- const ErrorWithCapture = Error as typeof Error & { captureStackTrace?: (err: Error, constructor: Function) => void };
90
- if (ErrorWithCapture.captureStackTrace) {
91
- ErrorWithCapture.captureStackTrace(this, ParserError);
92
- }
93
- }
94
-
95
- /**
96
- * Returns a string representation including the error code.
97
- */
98
- override toString(): string {
99
- return `[${this.code}] ${this.message}`;
100
- }
101
-
102
- /**
103
- * Serializes the error to a plain object for JSON serialization.
104
- */
105
- toJSON(): { code: string; message: string; context?: ErrorContext } {
106
- return {
107
- code: this.code,
108
- message: this.message,
109
- ...(this.context && { context: this.context }),
110
- };
111
- }
112
-
113
- // Convenience static factory methods for common errors
114
-
115
- /** Scope constraint is missing an entity */
116
- static scopeMissingEntity(operator: string, field: string): ParserError {
117
- return new ParserError(
118
- ErrorCodes.SCOPE_MISSING_ENTITY,
119
- `'${operator}' constraint is missing an entity`,
120
- { operator, field }
121
- );
122
- }
123
-
124
- /** Scope constraint is missing an entity type */
125
- static scopeMissingEntityType(field: string): ParserError {
126
- return new ParserError(
127
- ErrorCodes.SCOPE_MISSING_ENTITY_TYPE,
128
- "'is' constraint is missing an entity_type",
129
- { operator: "is", field }
130
- );
131
- }
132
-
133
- /** Scope constraint is missing entity list */
134
- static scopeMissingEntityList(field: string): ParserError {
135
- return new ParserError(
136
- ErrorCodes.SCOPE_MISSING_ENTITY_LIST,
137
- "'in' constraint is missing an entity",
138
- { operator: "in", field }
139
- );
140
- }
141
-
142
- /** Slot constraints are not supported */
143
- static scopeSlotNotSupported(operator: string, field: string): ParserError {
144
- return new ParserError(
145
- ErrorCodes.SCOPE_SLOT_NOT_SUPPORTED,
146
- `'${operator}' constraint with slot cannot be represented`,
147
- { operator, field }
148
- );
149
- }
150
-
151
- /** Unsupported scope operator */
152
- static scopeUnsupportedOp(operator: string, field: string): ParserError {
153
- return new ParserError(
154
- ErrorCodes.SCOPE_UNSUPPORTED_OP,
155
- `Unsupported scope operator: ${operator}`,
156
- { operator, field }
157
- );
158
- }
159
-
160
- /** Action constraint is missing an entity */
161
- static actionMissingEntity(operator: string): ParserError {
162
- return new ParserError(
163
- ErrorCodes.ACTION_MISSING_ENTITY,
164
- `Action '${operator}' constraint is missing an entity`,
165
- { operator, field: "action" }
166
- );
167
- }
168
-
169
- /** Action constraint is missing entities */
170
- static actionMissingEntities(): ParserError {
171
- return new ParserError(
172
- ErrorCodes.ACTION_MISSING_ENTITIES,
173
- "Action 'in' constraint is missing entities",
174
- { operator: "in", field: "action" }
175
- );
176
- }
177
-
178
- /** Unsupported action operator */
179
- static actionUnsupportedOp(operator: string): ParserError {
180
- return new ParserError(
181
- ErrorCodes.ACTION_UNSUPPORTED_OP,
182
- `Unsupported action operator: ${operator}`,
183
- { operator, field: "action" }
184
- );
185
- }
186
-
187
- /** Action scope is nil */
188
- static actionScopeNil(): ParserError {
189
- return new ParserError(
190
- ErrorCodes.ACTION_SCOPE_NIL,
191
- "Action scope is nil",
192
- { field: "action" }
193
- );
194
- }
195
- }
package/src/index.ts DELETED
@@ -1,62 +0,0 @@
1
- // Code generated by highflame-policy-codegen. DO NOT EDIT.
2
- // Source: schema/highflame.cedarschema
3
- //
4
- // NOTE: This module requires Node.js (uses @cedar-policy/cedar-wasm).
5
- // For browser usage, import from '@highflame/policy/types' instead.
6
-
7
- export * from './entities.gen.js';
8
- export * from './actions.gen.js';
9
- export * from './context.gen.js';
10
- export * from './schema.gen.js';
11
-
12
- // Non-generated modules (require Node.js)
13
- export * from './engine.js';
14
- export * from './builder.js';
15
- export * from './parser.js';
16
- export * from './errors.js';
17
- export * from './annotations.js';
18
-
19
- // Service-specific schemas and context (inlined)
20
- export {
21
- OVERWATCH_SCHEMA,
22
- OVERWATCH_CONTEXT,
23
- PALISADE_SCHEMA,
24
- PALISADE_CONTEXT,
25
- } from './service-schemas.gen.js';
26
- export type {
27
- ContextAttribute,
28
- ActionContext,
29
- ServiceContext,
30
- } from './service-schemas.gen.js';
31
-
32
- // Service-specific context key enums
33
- export { OverwatchContextKey } from './overwatch-context.gen.js';
34
- export { PalisadeContextKey } from './palisade-context.gen.js';
35
-
36
- // Service-specific entity metadata (for UI - principals, resources, actions)
37
- export {
38
- OVERWATCH_ENTITIES,
39
- OVERWATCH_ACTION_ENTITIES,
40
- } from './overwatch-entities.gen.js';
41
- export {
42
- PALISADE_ENTITIES,
43
- PALISADE_ACTION_ENTITIES,
44
- } from './palisade-entities.gen.js';
45
- export type { ServiceEntityMetadata, ActionEntityMetadata } from './entity-metadata-types.gen.js';
46
-
47
- // Service-specific default policies, templates, and categories
48
- export {
49
- OVERWATCH_DEFAULTS,
50
- OVERWATCH_TEMPLATES,
51
- OVERWATCH_CATEGORIES,
52
- OVERWATCH_TEMPLATES_JSON,
53
- getOverwatchDefaultsByCategory,
54
- getOverwatchTemplatesByCategory,
55
- getOverwatchTemplateById,
56
- } from './overwatch-defaults.gen.js';
57
- export type {
58
- OverwatchCategory,
59
- OverwatchCategoryInfo,
60
- OverwatchDefaultPolicy,
61
- OverwatchTemplate,
62
- } from './overwatch-defaults.gen.js';
@@ -1,32 +0,0 @@
1
- // Code generated by highflame-policy-codegen. DO NOT EDIT.
2
- // Source: schemas/overwatch/context.json
3
-
4
- /**
5
- * Context attribute keys for Overwatch Overwatch (Guardian) IDE security & policy enforcement.
6
- *
7
- * These constants correspond to the context attributes defined in the
8
- * Overwatch Cedar schema and are used at policy evaluation time.
9
- */
10
- export const OverwatchContextKey = {
11
- ContainsSecrets: 'contains_secrets',
12
- Content: 'content',
13
- Cwd: 'cwd',
14
- Event: 'event',
15
- HighestSeverity: 'highest_severity',
16
- MaxThreatSeverity: 'max_threat_severity',
17
- McpServer: 'mcp_server',
18
- McpTool: 'mcp_tool',
19
- Path: 'path',
20
- PromptText: 'prompt_text',
21
- ResponseContent: 'response_content',
22
- Source: 'source',
23
- ThreatCategories: 'threat_categories',
24
- ThreatCount: 'threat_count',
25
- ThreatTypes: 'threat_types',
26
- ToolName: 'tool_name',
27
- UserEmail: 'user_email',
28
- WorkspaceRoot: 'workspace_root',
29
- YaraThreats: 'yara_threats',
30
- } as const;
31
-
32
- export type OverwatchContextKey = (typeof OverwatchContextKey)[keyof typeof OverwatchContextKey];