protect-mcp 0.3.2 → 0.4.0
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/LICENSE +21 -0
- package/README.md +42 -2
- package/dist/chunk-UW2SGWCJ.mjs +143 -0
- package/dist/{chunk-GV7N53QE.mjs → chunk-XMZWJOC3.mjs} +39 -135
- package/dist/cli.js +3906 -3663
- package/dist/cli.mjs +16 -4
- package/dist/http-transport-S7YXXMD3.mjs +131 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +38 -0
- package/dist/index.mjs +10 -8
- package/package.json +13 -3
- package/policies/claude-code-hooks.json +18 -0
- package/policies/clinejection.json +45 -0
- package/policies/data-exfiltration.json +52 -0
- package/policies/financial-safe.json +49 -0
- package/policies/github-mcp-hijack.json +54 -0
- package/policies/terraform-destroy.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tom Farley / ScopeBlind
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -210,8 +210,48 @@ Use `createAuditBundle()` around your own collected signed receipts.
|
|
|
210
210
|
- **Keep the claims tight.** The default CLI path does not yet do everything the long-term architecture will support.
|
|
211
211
|
- **Layer on top of existing auth.** Don't rip out your stack just to add control and evidence.
|
|
212
212
|
|
|
213
|
+
## Incident-Anchored Policy Packs
|
|
214
|
+
|
|
215
|
+
Ship with protect-mcp — each prevents a real attack:
|
|
216
|
+
|
|
217
|
+
| Policy | Incident | OWASP Categories |
|
|
218
|
+
|--------|----------|-----------------|
|
|
219
|
+
| `clinejection.json` | CVE-2025-6514: MCP OAuth proxy hijack (437K environments) | A01, A03 |
|
|
220
|
+
| `terraform-destroy.json` | Autonomous Terraform agent destroys production | A05, A06 |
|
|
221
|
+
| `github-mcp-hijack.json` | Prompt injection via crafted GitHub issue | A01, A02, A03 |
|
|
222
|
+
| `data-exfiltration.json` | Agent data theft via outbound tool abuse | A02, A04 |
|
|
223
|
+
| `financial-safe.json` | Unauthorized financial transaction | A05, A06 |
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npx protect-mcp --policy node_modules/protect-mcp/policies/clinejection.json -- node server.js
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Full OWASP Agentic Top 10 mapping: [scopeblind.com/docs/owasp](https://scopeblind.com/docs/owasp)
|
|
230
|
+
|
|
231
|
+
## BYOPE: External Policy Engines
|
|
232
|
+
|
|
233
|
+
Supports OPA, Cerbos, Cedar (AWS AgentCore), and generic HTTP endpoints:
|
|
234
|
+
|
|
235
|
+
```json
|
|
236
|
+
{
|
|
237
|
+
"policy_engine": "hybrid",
|
|
238
|
+
"external": {
|
|
239
|
+
"endpoint": "http://localhost:8181/v1/data/mcp/allow",
|
|
240
|
+
"format": "cedar",
|
|
241
|
+
"timeout_ms": 200,
|
|
242
|
+
"fallback": "deny"
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Standards & IP
|
|
248
|
+
|
|
249
|
+
- **IETF Internet-Draft**: [draft-farley-acta-signed-receipts-00](https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/) — Signed Decision Receipts for Machine-to-Machine Access Control
|
|
250
|
+
- **Patent Status**: 4 Australian provisional patents pending (2025-2026) covering decision receipts with configurable disclosure, tool-calling gateway, agent manifests, and portable identity
|
|
251
|
+
- **Verification**: MIT-licensed — `npx @veritasacta/verify --self-test`
|
|
252
|
+
|
|
213
253
|
## License
|
|
214
254
|
|
|
215
|
-
|
|
255
|
+
MIT — free to use, modify, distribute, and build upon without restriction.
|
|
216
256
|
|
|
217
|
-
[scopeblind.com](https://scopeblind.com) · [npm](https://www.npmjs.com/package/protect-mcp) · [GitHub](https://github.com/tomjwxf/scopeblind-gateway)
|
|
257
|
+
[scopeblind.com](https://scopeblind.com) · [npm](https://www.npmjs.com/package/protect-mcp) · [GitHub](https://github.com/tomjwxf/scopeblind-gateway) · [IETF Draft](https://datatracker.ietf.org/doc/draft-farley-acta-signed-receipts/)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkRateLimit,
|
|
3
|
+
getToolPolicy,
|
|
4
|
+
meetsMinTier,
|
|
5
|
+
parseRateLimit
|
|
6
|
+
} from "./chunk-XMZWJOC3.mjs";
|
|
7
|
+
|
|
8
|
+
// src/simulate.ts
|
|
9
|
+
import { readFileSync } from "fs";
|
|
10
|
+
function parseLogFile(path) {
|
|
11
|
+
const raw = readFileSync(path, "utf-8");
|
|
12
|
+
const entries = [];
|
|
13
|
+
for (const line of raw.split("\n")) {
|
|
14
|
+
const trimmed = line.trim();
|
|
15
|
+
if (!trimmed) continue;
|
|
16
|
+
const jsonStr = trimmed.replace(/^\[PROTECT_MCP\]\s*/, "");
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(jsonStr);
|
|
19
|
+
if (parsed.tool && parsed.decision) {
|
|
20
|
+
entries.push(parsed);
|
|
21
|
+
}
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return entries;
|
|
26
|
+
}
|
|
27
|
+
function simulate(entries, policy, tier = "unknown") {
|
|
28
|
+
const rateLimitStore = /* @__PURE__ */ new Map();
|
|
29
|
+
const toolResults = /* @__PURE__ */ new Map();
|
|
30
|
+
const totals = {
|
|
31
|
+
allow: 0,
|
|
32
|
+
block: 0,
|
|
33
|
+
rate_limited: 0,
|
|
34
|
+
require_approval: 0,
|
|
35
|
+
tier_insufficient: 0
|
|
36
|
+
};
|
|
37
|
+
const originalTotals = { allow: 0, deny: 0 };
|
|
38
|
+
const changes = [];
|
|
39
|
+
for (const entry of entries) {
|
|
40
|
+
const toolName = entry.tool;
|
|
41
|
+
const toolPolicy = getToolPolicy(toolName, policy);
|
|
42
|
+
if (entry.decision === "allow") {
|
|
43
|
+
originalTotals.allow++;
|
|
44
|
+
} else {
|
|
45
|
+
originalTotals.deny++;
|
|
46
|
+
}
|
|
47
|
+
let newDecision;
|
|
48
|
+
if (toolPolicy.block) {
|
|
49
|
+
newDecision = "block";
|
|
50
|
+
} else if (toolPolicy.min_tier && !meetsMinTier(tier, toolPolicy.min_tier)) {
|
|
51
|
+
newDecision = "tier_insufficient";
|
|
52
|
+
} else if (toolPolicy.require_approval) {
|
|
53
|
+
newDecision = "require_approval";
|
|
54
|
+
} else if (toolPolicy.rate_limit) {
|
|
55
|
+
const limit = parseRateLimit(toolPolicy.rate_limit);
|
|
56
|
+
const result = checkRateLimit(toolName, limit, rateLimitStore);
|
|
57
|
+
newDecision = result.allowed ? "allow" : "rate_limited";
|
|
58
|
+
} else {
|
|
59
|
+
newDecision = "allow";
|
|
60
|
+
}
|
|
61
|
+
totals[newDecision]++;
|
|
62
|
+
if (!toolResults.has(toolName)) {
|
|
63
|
+
toolResults.set(toolName, {
|
|
64
|
+
tool: toolName,
|
|
65
|
+
calls: 0,
|
|
66
|
+
results: { allow: 0, block: 0, rate_limited: 0, require_approval: 0, tier_insufficient: 0 },
|
|
67
|
+
original: { allow: 0, deny: 0 }
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const tr = toolResults.get(toolName);
|
|
71
|
+
tr.calls++;
|
|
72
|
+
tr.results[newDecision]++;
|
|
73
|
+
if (entry.decision === "allow") {
|
|
74
|
+
tr.original.allow++;
|
|
75
|
+
} else {
|
|
76
|
+
tr.original.deny++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const [tool, result] of toolResults) {
|
|
80
|
+
const wasAllBlocked = result.original.allow === 0;
|
|
81
|
+
const nowAllBlocked = result.results.allow === 0;
|
|
82
|
+
const wasAllAllowed = result.original.deny === 0;
|
|
83
|
+
if (wasAllAllowed && result.results.block > 0) {
|
|
84
|
+
changes.push(`${tool}: ${result.results.block} calls would be blocked (was: all allowed)`);
|
|
85
|
+
}
|
|
86
|
+
if (wasAllAllowed && result.results.rate_limited > 0) {
|
|
87
|
+
changes.push(`${tool}: ${result.results.rate_limited} calls would be rate-limited (was: all allowed)`);
|
|
88
|
+
}
|
|
89
|
+
if (wasAllAllowed && result.results.require_approval > 0) {
|
|
90
|
+
changes.push(`${tool}: ${result.results.require_approval} calls would require approval (was: all allowed)`);
|
|
91
|
+
}
|
|
92
|
+
if (wasAllAllowed && result.results.tier_insufficient > 0) {
|
|
93
|
+
changes.push(`${tool}: ${result.results.tier_insufficient} calls would fail tier check (was: all allowed)`);
|
|
94
|
+
}
|
|
95
|
+
if (wasAllBlocked && result.results.allow > 0 && !nowAllBlocked) {
|
|
96
|
+
changes.push(`${tool}: ${result.results.allow} calls would now be allowed (was: all blocked)`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
policy_file: "",
|
|
101
|
+
log_file: "",
|
|
102
|
+
total_calls: entries.length,
|
|
103
|
+
results: totals,
|
|
104
|
+
original: originalTotals,
|
|
105
|
+
tool_breakdown: Array.from(toolResults.values()).sort((a, b) => b.calls - a.calls),
|
|
106
|
+
changes
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function formatSimulation(summary) {
|
|
110
|
+
const lines = [];
|
|
111
|
+
lines.push(`Simulating ${summary.policy_file} against ${summary.total_calls} recorded tool calls:
|
|
112
|
+
`);
|
|
113
|
+
const maxToolLen = Math.max(...summary.tool_breakdown.map((t) => t.tool.length), 4);
|
|
114
|
+
for (const tr of summary.tool_breakdown) {
|
|
115
|
+
const parts = [];
|
|
116
|
+
if (tr.results.allow > 0) parts.push(`${tr.results.allow} allow`);
|
|
117
|
+
if (tr.results.block > 0) parts.push(`\x1B[31m${tr.results.block} blocked\x1B[0m`);
|
|
118
|
+
if (tr.results.rate_limited > 0) parts.push(`\x1B[33m${tr.results.rate_limited} rate_limited\x1B[0m`);
|
|
119
|
+
if (tr.results.require_approval > 0) parts.push(`\x1B[36m${tr.results.require_approval} require_approval\x1B[0m`);
|
|
120
|
+
if (tr.results.tier_insufficient > 0) parts.push(`\x1B[35m${tr.results.tier_insufficient} tier_insufficient\x1B[0m`);
|
|
121
|
+
const originalParts = [];
|
|
122
|
+
if (tr.original.allow > 0) originalParts.push(`${tr.original.allow} allow`);
|
|
123
|
+
if (tr.original.deny > 0) originalParts.push(`${tr.original.deny} deny`);
|
|
124
|
+
lines.push(` ${tr.tool.padEnd(maxToolLen)} \xD7 ${String(tr.calls).padStart(3)} \u2192 ${parts.join(", ")} (was: ${originalParts.join(", ")})`);
|
|
125
|
+
}
|
|
126
|
+
lines.push("");
|
|
127
|
+
lines.push(`Summary: ${summary.results.allow} allow, ${summary.results.block} blocked, ${summary.results.rate_limited} rate_limited, ${summary.results.require_approval} require_approval, ${summary.results.tier_insufficient} tier_insufficient`);
|
|
128
|
+
lines.push(` vs original: ${summary.original.allow} allow, ${summary.original.deny} deny`);
|
|
129
|
+
if (summary.changes.length > 0) {
|
|
130
|
+
lines.push("");
|
|
131
|
+
lines.push("Changes:");
|
|
132
|
+
for (const change of summary.changes) {
|
|
133
|
+
lines.push(` \u2022 ${change}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return lines.join("\n");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
parseLogFile,
|
|
141
|
+
simulate,
|
|
142
|
+
formatSimulation
|
|
143
|
+
};
|
|
@@ -460,6 +460,28 @@ function formatRequest(context, format) {
|
|
|
460
460
|
},
|
|
461
461
|
actions: [context.action.operation || "call"]
|
|
462
462
|
};
|
|
463
|
+
case "cedar":
|
|
464
|
+
return {
|
|
465
|
+
principal: {
|
|
466
|
+
type: "Agent",
|
|
467
|
+
id: context.actor.id || "unknown"
|
|
468
|
+
},
|
|
469
|
+
action: {
|
|
470
|
+
type: "Action",
|
|
471
|
+
id: `MCP::Tool::${context.action.operation || "call"}`
|
|
472
|
+
},
|
|
473
|
+
resource: {
|
|
474
|
+
type: "Tool",
|
|
475
|
+
id: context.action.tool
|
|
476
|
+
},
|
|
477
|
+
context: {
|
|
478
|
+
tier: context.actor.tier,
|
|
479
|
+
manifest_hash: context.actor.manifest_hash || null,
|
|
480
|
+
service: context.target.service || "default",
|
|
481
|
+
mode: context.mode,
|
|
482
|
+
credential_ref: context.credential_ref || null
|
|
483
|
+
}
|
|
484
|
+
};
|
|
463
485
|
case "generic":
|
|
464
486
|
default:
|
|
465
487
|
return context;
|
|
@@ -489,6 +511,22 @@ function parseResponse(result, format) {
|
|
|
489
511
|
}
|
|
490
512
|
}
|
|
491
513
|
return { allowed: false, reason: "unrecognized Cerbos response" };
|
|
514
|
+
case "cedar":
|
|
515
|
+
if (typeof result.decision === "string") {
|
|
516
|
+
return {
|
|
517
|
+
allowed: result.decision === "Allow",
|
|
518
|
+
reason: result.decision === "Deny" ? `cedar_deny${result.diagnostics ? ": " + JSON.stringify(result.diagnostics) : ""}` : void 0,
|
|
519
|
+
metadata: result.diagnostics
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
if (Array.isArray(result.results) && result.results.length > 0) {
|
|
523
|
+
const first = result.results[0];
|
|
524
|
+
return {
|
|
525
|
+
allowed: first.decision === "Allow",
|
|
526
|
+
reason: first.decision === "Deny" ? "cedar_deny" : void 0
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
return { allowed: false, reason: "unrecognized Cedar response" };
|
|
492
530
|
case "generic":
|
|
493
531
|
default:
|
|
494
532
|
return {
|
|
@@ -1112,137 +1150,6 @@ var ProtectGateway = class {
|
|
|
1112
1150
|
}
|
|
1113
1151
|
};
|
|
1114
1152
|
|
|
1115
|
-
// src/simulate.ts
|
|
1116
|
-
import { readFileSync as readFileSync5 } from "fs";
|
|
1117
|
-
function parseLogFile(path) {
|
|
1118
|
-
const raw = readFileSync5(path, "utf-8");
|
|
1119
|
-
const entries = [];
|
|
1120
|
-
for (const line of raw.split("\n")) {
|
|
1121
|
-
const trimmed = line.trim();
|
|
1122
|
-
if (!trimmed) continue;
|
|
1123
|
-
const jsonStr = trimmed.replace(/^\[PROTECT_MCP\]\s*/, "");
|
|
1124
|
-
try {
|
|
1125
|
-
const parsed = JSON.parse(jsonStr);
|
|
1126
|
-
if (parsed.tool && parsed.decision) {
|
|
1127
|
-
entries.push(parsed);
|
|
1128
|
-
}
|
|
1129
|
-
} catch {
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
return entries;
|
|
1133
|
-
}
|
|
1134
|
-
function simulate(entries, policy, tier = "unknown") {
|
|
1135
|
-
const rateLimitStore = /* @__PURE__ */ new Map();
|
|
1136
|
-
const toolResults = /* @__PURE__ */ new Map();
|
|
1137
|
-
const totals = {
|
|
1138
|
-
allow: 0,
|
|
1139
|
-
block: 0,
|
|
1140
|
-
rate_limited: 0,
|
|
1141
|
-
require_approval: 0,
|
|
1142
|
-
tier_insufficient: 0
|
|
1143
|
-
};
|
|
1144
|
-
const originalTotals = { allow: 0, deny: 0 };
|
|
1145
|
-
const changes = [];
|
|
1146
|
-
for (const entry of entries) {
|
|
1147
|
-
const toolName = entry.tool;
|
|
1148
|
-
const toolPolicy = getToolPolicy(toolName, policy);
|
|
1149
|
-
if (entry.decision === "allow") {
|
|
1150
|
-
originalTotals.allow++;
|
|
1151
|
-
} else {
|
|
1152
|
-
originalTotals.deny++;
|
|
1153
|
-
}
|
|
1154
|
-
let newDecision;
|
|
1155
|
-
if (toolPolicy.block) {
|
|
1156
|
-
newDecision = "block";
|
|
1157
|
-
} else if (toolPolicy.min_tier && !meetsMinTier(tier, toolPolicy.min_tier)) {
|
|
1158
|
-
newDecision = "tier_insufficient";
|
|
1159
|
-
} else if (toolPolicy.require_approval) {
|
|
1160
|
-
newDecision = "require_approval";
|
|
1161
|
-
} else if (toolPolicy.rate_limit) {
|
|
1162
|
-
const limit = parseRateLimit(toolPolicy.rate_limit);
|
|
1163
|
-
const result = checkRateLimit(toolName, limit, rateLimitStore);
|
|
1164
|
-
newDecision = result.allowed ? "allow" : "rate_limited";
|
|
1165
|
-
} else {
|
|
1166
|
-
newDecision = "allow";
|
|
1167
|
-
}
|
|
1168
|
-
totals[newDecision]++;
|
|
1169
|
-
if (!toolResults.has(toolName)) {
|
|
1170
|
-
toolResults.set(toolName, {
|
|
1171
|
-
tool: toolName,
|
|
1172
|
-
calls: 0,
|
|
1173
|
-
results: { allow: 0, block: 0, rate_limited: 0, require_approval: 0, tier_insufficient: 0 },
|
|
1174
|
-
original: { allow: 0, deny: 0 }
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
const tr = toolResults.get(toolName);
|
|
1178
|
-
tr.calls++;
|
|
1179
|
-
tr.results[newDecision]++;
|
|
1180
|
-
if (entry.decision === "allow") {
|
|
1181
|
-
tr.original.allow++;
|
|
1182
|
-
} else {
|
|
1183
|
-
tr.original.deny++;
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
for (const [tool, result] of toolResults) {
|
|
1187
|
-
const wasAllBlocked = result.original.allow === 0;
|
|
1188
|
-
const nowAllBlocked = result.results.allow === 0;
|
|
1189
|
-
const wasAllAllowed = result.original.deny === 0;
|
|
1190
|
-
if (wasAllAllowed && result.results.block > 0) {
|
|
1191
|
-
changes.push(`${tool}: ${result.results.block} calls would be blocked (was: all allowed)`);
|
|
1192
|
-
}
|
|
1193
|
-
if (wasAllAllowed && result.results.rate_limited > 0) {
|
|
1194
|
-
changes.push(`${tool}: ${result.results.rate_limited} calls would be rate-limited (was: all allowed)`);
|
|
1195
|
-
}
|
|
1196
|
-
if (wasAllAllowed && result.results.require_approval > 0) {
|
|
1197
|
-
changes.push(`${tool}: ${result.results.require_approval} calls would require approval (was: all allowed)`);
|
|
1198
|
-
}
|
|
1199
|
-
if (wasAllAllowed && result.results.tier_insufficient > 0) {
|
|
1200
|
-
changes.push(`${tool}: ${result.results.tier_insufficient} calls would fail tier check (was: all allowed)`);
|
|
1201
|
-
}
|
|
1202
|
-
if (wasAllBlocked && result.results.allow > 0 && !nowAllBlocked) {
|
|
1203
|
-
changes.push(`${tool}: ${result.results.allow} calls would now be allowed (was: all blocked)`);
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
return {
|
|
1207
|
-
policy_file: "",
|
|
1208
|
-
log_file: "",
|
|
1209
|
-
total_calls: entries.length,
|
|
1210
|
-
results: totals,
|
|
1211
|
-
original: originalTotals,
|
|
1212
|
-
tool_breakdown: Array.from(toolResults.values()).sort((a, b) => b.calls - a.calls),
|
|
1213
|
-
changes
|
|
1214
|
-
};
|
|
1215
|
-
}
|
|
1216
|
-
function formatSimulation(summary) {
|
|
1217
|
-
const lines = [];
|
|
1218
|
-
lines.push(`Simulating ${summary.policy_file} against ${summary.total_calls} recorded tool calls:
|
|
1219
|
-
`);
|
|
1220
|
-
const maxToolLen = Math.max(...summary.tool_breakdown.map((t) => t.tool.length), 4);
|
|
1221
|
-
for (const tr of summary.tool_breakdown) {
|
|
1222
|
-
const parts = [];
|
|
1223
|
-
if (tr.results.allow > 0) parts.push(`${tr.results.allow} allow`);
|
|
1224
|
-
if (tr.results.block > 0) parts.push(`\x1B[31m${tr.results.block} blocked\x1B[0m`);
|
|
1225
|
-
if (tr.results.rate_limited > 0) parts.push(`\x1B[33m${tr.results.rate_limited} rate_limited\x1B[0m`);
|
|
1226
|
-
if (tr.results.require_approval > 0) parts.push(`\x1B[36m${tr.results.require_approval} require_approval\x1B[0m`);
|
|
1227
|
-
if (tr.results.tier_insufficient > 0) parts.push(`\x1B[35m${tr.results.tier_insufficient} tier_insufficient\x1B[0m`);
|
|
1228
|
-
const originalParts = [];
|
|
1229
|
-
if (tr.original.allow > 0) originalParts.push(`${tr.original.allow} allow`);
|
|
1230
|
-
if (tr.original.deny > 0) originalParts.push(`${tr.original.deny} deny`);
|
|
1231
|
-
lines.push(` ${tr.tool.padEnd(maxToolLen)} \xD7 ${String(tr.calls).padStart(3)} \u2192 ${parts.join(", ")} (was: ${originalParts.join(", ")})`);
|
|
1232
|
-
}
|
|
1233
|
-
lines.push("");
|
|
1234
|
-
lines.push(`Summary: ${summary.results.allow} allow, ${summary.results.block} blocked, ${summary.results.rate_limited} rate_limited, ${summary.results.require_approval} require_approval, ${summary.results.tier_insufficient} tier_insufficient`);
|
|
1235
|
-
lines.push(` vs original: ${summary.original.allow} allow, ${summary.original.deny} deny`);
|
|
1236
|
-
if (summary.changes.length > 0) {
|
|
1237
|
-
lines.push("");
|
|
1238
|
-
lines.push("Changes:");
|
|
1239
|
-
for (const change of summary.changes) {
|
|
1240
|
-
lines.push(` \u2022 ${change}`);
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
return lines.join("\n");
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
1153
|
export {
|
|
1247
1154
|
loadPolicy,
|
|
1248
1155
|
getToolPolicy,
|
|
@@ -1259,8 +1166,5 @@ export {
|
|
|
1259
1166
|
isSigningEnabled,
|
|
1260
1167
|
queryExternalPDP,
|
|
1261
1168
|
buildDecisionContext,
|
|
1262
|
-
ProtectGateway
|
|
1263
|
-
parseLogFile,
|
|
1264
|
-
simulate,
|
|
1265
|
-
formatSimulation
|
|
1169
|
+
ProtectGateway
|
|
1266
1170
|
};
|