@highflame/policy 2.2.37 → 2.2.38
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/dist/engine.d.ts +10 -0
- package/dist/engine.js +25 -1
- package/package.json +1 -1
- package/_schemas/mcp_gateway/context.json +0 -655
- package/_schemas/mcp_gateway/schema.cedarschema +0 -342
- package/_schemas/mcp_gateway/templates/defaults/agent_security.cedar +0 -140
- package/_schemas/mcp_gateway/templates/defaults/baseline.cedar +0 -23
- package/_schemas/mcp_gateway/templates/defaults/semantic.cedar +0 -105
- package/_schemas/mcp_gateway/templates/defaults/tools.cedar +0 -92
- package/_schemas/mcp_gateway/templates/mcp_server_allowlist.cedar +0 -33
- package/_schemas/mcp_gateway/templates/mcp_tool_permissions.cedar +0 -77
- package/_schemas/mcp_gateway/templates/templates.json +0 -89
- package/dist/mcp_gateway-context.gen.d.ts +0 -51
- package/dist/mcp_gateway-context.gen.js +0 -52
- package/dist/mcp_gateway-defaults.gen.d.ts +0 -61
- package/dist/mcp_gateway-defaults.gen.js +0 -668
- package/dist/mcp_gateway-entities.gen.d.ts +0 -11
- package/dist/mcp_gateway-entities.gen.js +0 -37
package/dist/engine.d.ts
CHANGED
|
@@ -80,6 +80,16 @@ export interface EvaluateRequest {
|
|
|
80
80
|
resource: EntityUID;
|
|
81
81
|
context?: Record<string, unknown>;
|
|
82
82
|
entities?: Entity[];
|
|
83
|
+
/**
|
|
84
|
+
* Narrows evaluation to the policies this predicate accepts, keyed by policy
|
|
85
|
+
* id. Cedar evaluates everything it is handed, so selecting the relevant
|
|
86
|
+
* subset is the caller's job.
|
|
87
|
+
*
|
|
88
|
+
* Omit to evaluate everything. That is also the correct fallback when a
|
|
89
|
+
* caller cannot resolve a subset: a predicate matching nothing leaves Cedar
|
|
90
|
+
* with no policies, and Cedar is default-deny.
|
|
91
|
+
*/
|
|
92
|
+
policyFilter?: (policyId: string) => boolean;
|
|
83
93
|
}
|
|
84
94
|
/**
|
|
85
95
|
* PolicyEngine wraps cedar-wasm with Highflame schema types.
|
package/dist/engine.js
CHANGED
|
@@ -186,6 +186,30 @@ function extractPolicies(policyText) {
|
|
|
186
186
|
}
|
|
187
187
|
return { policySet: policyMap, annotations: annotationsMap };
|
|
188
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Narrow a policy set to the ids `keep` accepts. Returns the set unchanged when
|
|
191
|
+
* no predicate is given, so the unfiltered path is untouched.
|
|
192
|
+
*
|
|
193
|
+
* Throws on a string-form set, which cannot be split by id. Returning it whole
|
|
194
|
+
* would silently evaluate every policy while the caller believed it had asked
|
|
195
|
+
* for a subset — the one behaviour the filter contract must never have.
|
|
196
|
+
*/
|
|
197
|
+
function filterPolicySet(set, keep) {
|
|
198
|
+
if (!keep) {
|
|
199
|
+
return set;
|
|
200
|
+
}
|
|
201
|
+
if (typeof set === "string") {
|
|
202
|
+
throw new Error("policyFilter cannot be applied: policies are loaded in string form, " +
|
|
203
|
+
"which has no per-policy ids. Load via loadPoliciesWithIds().");
|
|
204
|
+
}
|
|
205
|
+
const out = {};
|
|
206
|
+
for (const [id, policy] of Object.entries(set)) {
|
|
207
|
+
if (keep(id)) {
|
|
208
|
+
out[id] = policy;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return out;
|
|
212
|
+
}
|
|
189
213
|
/**
|
|
190
214
|
* PolicyEngine wraps cedar-wasm with Highflame schema types.
|
|
191
215
|
*/
|
|
@@ -346,7 +370,7 @@ export class PolicyEngine {
|
|
|
346
370
|
action,
|
|
347
371
|
resource,
|
|
348
372
|
context,
|
|
349
|
-
policies: { staticPolicies: this.policySet },
|
|
373
|
+
policies: { staticPolicies: filterPolicySet(this.policySet, req.policyFilter) },
|
|
350
374
|
entities,
|
|
351
375
|
};
|
|
352
376
|
// Add schema if available
|