@glassbox-ai/engine 0.0.0-stage → 0.1.1
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 +201 -0
- package/README.md +33 -2
- package/dist/action/acc.d.ts +48 -0
- package/dist/action/acc.js +117 -0
- package/dist/action/builtin-tools.d.ts +5 -0
- package/dist/action/builtin-tools.js +74 -0
- package/dist/action/inline.d.ts +14 -0
- package/dist/action/inline.js +54 -0
- package/dist/action/paths.d.ts +71 -0
- package/dist/action/paths.js +398 -0
- package/dist/action/powershell.d.ts +9 -0
- package/dist/action/powershell.js +848 -0
- package/dist/action/protected-write.d.ts +11 -0
- package/dist/action/protected-write.js +113 -0
- package/dist/action/schedule.d.ts +43 -0
- package/dist/action/schedule.js +213 -0
- package/dist/action/shell/analyze.d.ts +28 -0
- package/dist/action/shell/analyze.js +2057 -0
- package/dist/action/shell/parse.d.ts +74 -0
- package/dist/action/shell/parse.js +1037 -0
- package/dist/action/shell/view.d.ts +6 -0
- package/dist/action/shell/view.js +89 -0
- package/dist/action/sql.d.ts +3 -0
- package/dist/action/sql.js +259 -0
- package/dist/action/tools.d.ts +20 -0
- package/dist/action/tools.js +305 -0
- package/dist/action/upload.d.ts +17 -0
- package/dist/action/upload.js +72 -0
- package/dist/analysis/fields.d.ts +14 -0
- package/dist/analysis/fields.js +136 -0
- package/dist/analysis/findings.d.ts +25 -0
- package/dist/analysis/findings.js +82 -0
- package/dist/analysis/gate.d.ts +16 -0
- package/dist/analysis/gate.js +662 -0
- package/dist/analysis/manifest.d.ts +3 -0
- package/dist/analysis/manifest.js +369 -0
- package/dist/analysis/match.d.ts +54 -0
- package/dist/analysis/match.js +352 -0
- package/dist/analysis/scan.d.ts +17 -0
- package/dist/analysis/scan.js +97 -0
- package/dist/canon/confusables.generated.d.ts +3 -0
- package/dist/canon/confusables.generated.js +6 -0
- package/dist/canon/decode.d.ts +11 -0
- package/dist/canon/decode.js +147 -0
- package/dist/canon/views.d.ts +36 -0
- package/dist/canon/views.js +283 -0
- package/dist/evidence/evidence.d.ts +12 -0
- package/dist/evidence/evidence.js +149 -0
- package/dist/fingerprint/diff.d.ts +3 -0
- package/dist/fingerprint/diff.js +273 -0
- package/dist/fingerprint/fingerprint.d.ts +4 -0
- package/dist/fingerprint/fingerprint.js +77 -0
- package/dist/grade/score.d.ts +19 -0
- package/dist/grade/score.js +89 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +152 -0
- package/dist/intake/json.d.ts +17 -0
- package/dist/intake/json.js +284 -0
- package/dist/intake/snapshot.d.ts +14 -0
- package/dist/intake/snapshot.js +130 -0
- package/dist/limits.d.ts +4 -0
- package/dist/limits.js +30 -0
- package/dist/policy/decide.d.ts +32 -0
- package/dist/policy/decide.js +105 -0
- package/dist/rules/ids.d.ts +2 -0
- package/dist/rules/ids.js +99 -0
- package/dist/ruleset/baseline-tests.generated.d.ts +6 -0
- package/dist/ruleset/baseline-tests.generated.js +2935 -0
- package/dist/ruleset/baseline.d.ts +3 -0
- package/dist/ruleset/baseline.generated.d.ts +3 -0
- package/dist/ruleset/baseline.generated.js +5 -0
- package/dist/ruleset/baseline.js +44 -0
- package/dist/ruleset/fakes.d.ts +3 -0
- package/dist/ruleset/fakes.js +26 -0
- package/dist/ruleset/load.d.ts +13 -0
- package/dist/ruleset/load.js +187 -0
- package/dist/ruleset/schema.d.ts +120 -0
- package/dist/ruleset/schema.js +54 -0
- package/dist/ruleset/selftest.d.ts +18 -0
- package/dist/ruleset/selftest.js +42 -0
- package/dist/ruleset-entry.d.ts +5 -0
- package/dist/ruleset-entry.js +7 -0
- package/dist/secrets/detect.d.ts +17 -0
- package/dist/secrets/detect.js +236 -0
- package/dist/secrets/redact.d.ts +19 -0
- package/dist/secrets/redact.js +116 -0
- package/dist/types.d.ts +455 -0
- package/dist/types.js +10 -0
- package/dist/util/hash.d.ts +4 -0
- package/dist/util/hash.js +16 -0
- package/dist/util/initclock.d.ts +3 -0
- package/dist/util/initclock.js +17 -0
- package/dist/util/jcs.d.ts +4 -0
- package/dist/util/jcs.js +91 -0
- package/dist/util/misc.d.ts +17 -0
- package/dist/util/misc.js +77 -0
- package/dist/util/re.d.ts +14 -0
- package/dist/util/re.js +47 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/package.json +57 -4
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { get, getString, isRecord } from "../util/misc.js";
|
|
2
|
+
import { Acc } from "./acc.js";
|
|
3
|
+
import { coversProtectedRead, globCoversProtectedRead, isProtected, isProtectedRead, normalizePath, persistenceHit, sensitiveLabel, } from "./paths.js";
|
|
4
|
+
import { builtinCategory } from "./builtin-tools.js";
|
|
5
|
+
import { analyzePowerShell } from "./powershell.js";
|
|
6
|
+
import { isProtectedWrite } from "./protected-write.js";
|
|
7
|
+
import { analyzeShellCommand } from "./shell/analyze.js";
|
|
8
|
+
import { analyzeSql } from "./sql.js";
|
|
9
|
+
const READ_TOOLS = new Set(["read", "glob", "grep", "ls", "lsp", "websearch", "todowrite", "todoread", "askuserquestion", "exitplanmode", "notebookread", "bashoutput", "taskoutput", "listmcpresourcestool", "readmcpresourcetool", "toolsearch"]);
|
|
10
|
+
const WRITE_TOOLS = new Set(["write", "edit", "multiedit", "notebookedit"]);
|
|
11
|
+
export function writePath(path, acc, t) {
|
|
12
|
+
const np = normalizePath(path, t.pctx);
|
|
13
|
+
if (isProtectedWrite(np, t.pctx))
|
|
14
|
+
acc.protect("CP-SELF-001", "changes a file that controls the agent or Glassbox");
|
|
15
|
+
acc.persist(persistenceHit(np, t.pctx), "changes", np.path);
|
|
16
|
+
acc.wrote(np.path);
|
|
17
|
+
const p = (np.path ?? np.suffix ?? "").toLowerCase();
|
|
18
|
+
if (p.includes("/.git/hooks/") || p.endsWith("/.git/config") || p.includes("/.husky/") || p.endsWith("/.envrc") || p.endsWith("/.bashrc") || p.endsWith("/.zshrc") || p.endsWith("/.profile") || p.endsWith("/.bash_profile") || p.endsWith("/.pre-commit-config.yaml") || p.endsWith("profile.ps1") || p.includes("/library/launchagents/") || p.includes("/.config/systemd/user/")) {
|
|
19
|
+
acc.tag("high-risk", "config.agent");
|
|
20
|
+
acc.reason("writes a file that runs commands later");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function readPath(path, acc, t, recursive) {
|
|
24
|
+
const np = normalizePath(path, t.pctx);
|
|
25
|
+
if (recursive ? coversProtectedRead(np, t.pctx) : isProtectedRead(np, t.pctx)) {
|
|
26
|
+
acc.protect("CP-SELF-002", "reads a Glassbox credential file");
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const label = sensitiveLabel(np, t.pctx);
|
|
30
|
+
if (label) {
|
|
31
|
+
acc.tags.add("fs.read.sensitive");
|
|
32
|
+
acc.sensitive.push(label);
|
|
33
|
+
acc.sensitiveArgs = true;
|
|
34
|
+
acc.find("CP-EXFIL-040", label);
|
|
35
|
+
acc.reason(`reads a sensitive file (${label})`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export function hostOf(url) {
|
|
39
|
+
const m = /^[a-z][a-z0-9+.-]*:\/\/([^/?#@\s]*@)?(\[[^\]]*\]|[^/?#:\s]+)/i.exec(url.slice(0, 2048));
|
|
40
|
+
return m ? m[2].toLowerCase() : null;
|
|
41
|
+
}
|
|
42
|
+
export function classifyBuiltin(toolName, args, t) {
|
|
43
|
+
const acc = new Acc();
|
|
44
|
+
const name = toolName.toLowerCase();
|
|
45
|
+
const str = (k) => getString(args, k);
|
|
46
|
+
if (name === "bash") {
|
|
47
|
+
const cmd = str("command");
|
|
48
|
+
if (cmd === undefined) {
|
|
49
|
+
acc.unanalyzable("Bash call without a command string");
|
|
50
|
+
return acc;
|
|
51
|
+
}
|
|
52
|
+
return analyzeShellCommand(cmd, { pctx: t.pctx, depth: 0, maxBytes: t.maxCommandBytes });
|
|
53
|
+
}
|
|
54
|
+
if (name === "powershell") {
|
|
55
|
+
const cmd = str("command");
|
|
56
|
+
if (cmd === undefined) {
|
|
57
|
+
acc.unanalyzable("PowerShell call without a command string");
|
|
58
|
+
return acc;
|
|
59
|
+
}
|
|
60
|
+
return analyzePowerShell(cmd, { pctx: t.pctx, depth: 0, maxBytes: t.maxCommandBytes });
|
|
61
|
+
}
|
|
62
|
+
if (WRITE_TOOLS.has(name)) {
|
|
63
|
+
acc.tag("write-reversible", "fs.write");
|
|
64
|
+
const p = str("file_path") ?? str("notebook_path") ?? str("path");
|
|
65
|
+
if (p === undefined) {
|
|
66
|
+
acc.unanalyzable("write tool without a file path");
|
|
67
|
+
return acc;
|
|
68
|
+
}
|
|
69
|
+
writePath(p, acc, t);
|
|
70
|
+
return acc;
|
|
71
|
+
}
|
|
72
|
+
if (name === "monitor") {
|
|
73
|
+
// Monitor runs a background shell command (or watches a WebSocket) and streams its output
|
|
74
|
+
// to the agent. The command gets the full shell analysis, like Bash.
|
|
75
|
+
const cmd = str("command");
|
|
76
|
+
let out = cmd !== undefined ? analyzeShellCommand(cmd, { pctx: t.pctx, depth: 0, maxBytes: t.maxCommandBytes }) : null;
|
|
77
|
+
const wsUrl = getString(get(args, "ws"), "url");
|
|
78
|
+
if (wsUrl !== undefined) {
|
|
79
|
+
const a = out ?? acc;
|
|
80
|
+
a.tag("high-risk", "net.egress");
|
|
81
|
+
a.network = true;
|
|
82
|
+
const h = hostOf(wsUrl);
|
|
83
|
+
a.reason(h ? `watches a WebSocket on ${h}` : "watches a WebSocket on an unknown host");
|
|
84
|
+
out = a;
|
|
85
|
+
}
|
|
86
|
+
if (out === null) {
|
|
87
|
+
acc.unanalyzable("Monitor call without a command string");
|
|
88
|
+
return acc;
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
if (name === "webfetch") {
|
|
93
|
+
acc.tag("high-risk", "net.egress");
|
|
94
|
+
acc.network = true;
|
|
95
|
+
const h = hostOf(str("url") ?? "");
|
|
96
|
+
acc.reason(h ? `destination host: ${h}` : "destination host unknown");
|
|
97
|
+
return acc;
|
|
98
|
+
}
|
|
99
|
+
if (name === "enterworktree") {
|
|
100
|
+
acc.tag("write-reversible", "fs.write");
|
|
101
|
+
const p = str("path");
|
|
102
|
+
if (p !== undefined)
|
|
103
|
+
writePath(p, acc, t);
|
|
104
|
+
acc.reason("creates or enters a git worktree");
|
|
105
|
+
return acc;
|
|
106
|
+
}
|
|
107
|
+
if (name === "exitworktree") {
|
|
108
|
+
acc.tag("write-reversible", "fs.write");
|
|
109
|
+
acc.reason("leaves a git worktree");
|
|
110
|
+
return acc;
|
|
111
|
+
}
|
|
112
|
+
if (READ_TOOLS.has(name)) {
|
|
113
|
+
if (name === "read" || name === "notebookread" || name === "lsp") {
|
|
114
|
+
const p = str("file_path") ?? str("filePath") ?? str("path") ?? str("notebook_path");
|
|
115
|
+
if (p !== undefined)
|
|
116
|
+
readPath(p, acc, t, false);
|
|
117
|
+
}
|
|
118
|
+
if (name === "grep") {
|
|
119
|
+
const p = str("path") ?? (t.pctx.cwd ?? ".");
|
|
120
|
+
readPath(p, acc, t, true);
|
|
121
|
+
const g = str("glob");
|
|
122
|
+
if (g && globCoversProtectedRead(g, p, t.pctx))
|
|
123
|
+
acc.protect("CP-SELF-002", "searches Glassbox credential files");
|
|
124
|
+
}
|
|
125
|
+
if (name === "glob") {
|
|
126
|
+
const pattern = str("pattern") ?? "";
|
|
127
|
+
if (globCoversProtectedRead(pattern, str("path") ?? null, t.pctx))
|
|
128
|
+
acc.protect("CP-SELF-002", "lists Glassbox credential files");
|
|
129
|
+
}
|
|
130
|
+
return acc;
|
|
131
|
+
}
|
|
132
|
+
const label = toolName.slice(0, 40);
|
|
133
|
+
switch (builtinCategory(toolName)) {
|
|
134
|
+
case "network":
|
|
135
|
+
// Artifact, ShareOnboardingGuide: publish local content to a hosted page.
|
|
136
|
+
acc.tag("high-risk", "net.egress");
|
|
137
|
+
acc.network = true;
|
|
138
|
+
acc.reason(`sends content off the machine (${label})`);
|
|
139
|
+
return acc;
|
|
140
|
+
case "agent":
|
|
141
|
+
if (name === "remotetrigger") {
|
|
142
|
+
acc.tag("high-risk", "exec.nested-agent");
|
|
143
|
+
acc.reason("creates or runs a scheduled agent in the cloud, where these checks don't run");
|
|
144
|
+
return acc;
|
|
145
|
+
}
|
|
146
|
+
// Agent, Workflow, Skill, SendMessage, CronCreate, ScheduleWakeup: the work they start runs
|
|
147
|
+
// as ordinary tool calls in this Claude Code, and each of those is checked.
|
|
148
|
+
acc.raise("write-reversible");
|
|
149
|
+
acc.reason(`starts agent work (${label}); its tool calls are checked one by one`);
|
|
150
|
+
return acc;
|
|
151
|
+
case "other":
|
|
152
|
+
acc.raise("write-reversible");
|
|
153
|
+
acc.reason(`acts inside the session (${label})`);
|
|
154
|
+
return acc;
|
|
155
|
+
case "read":
|
|
156
|
+
return acc;
|
|
157
|
+
case "command":
|
|
158
|
+
case "write":
|
|
159
|
+
case undefined:
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
// A built-in tool this engine doesn't know: it may run commands or write files, and nothing
|
|
163
|
+
// here can tell. Unanalyzable (ask; deny in autopilot), never "harmless".
|
|
164
|
+
acc.unanalyzable(`unknown agent tool ${label}`);
|
|
165
|
+
return acc;
|
|
166
|
+
}
|
|
167
|
+
// ── MCP tools ────────────────────────────────────────────────────────────
|
|
168
|
+
const HIGH_VERBS = new Set(["delete", "remove", "destroy", "drop", "truncate", "deploy", "publish", "post", "send", "transfer", "pay", "refund", "charge", "merge", "push", "grant", "revoke", "invite", "archive", "execute", "exec", "run", "purge", "wipe", "kill", "terminate", "erase", "unpublish", "release", "approve", "submit", "tweet", "email", "notify", "broadcast", "withdraw", "sell", "buy", "order", "book", "cancel", "reset", "overwrite", "shutdown", "restart", "reboot", "ban", "kick", "suspend", "disable", "uninstall"]);
|
|
169
|
+
const WRITE_VERBS = new Set(["create", "update", "set", "add", "edit", "write", "upload", "modify", "put", "patch", "save", "insert", "rename", "move", "copy", "upsert", "append", "make", "new", "change", "assign", "label", "tag", "comment", "reply", "star", "fork", "open", "close", "enable", "install", "configure", "register", "import", "sync", "store", "commit", "mark", "pin", "schedule", "generate", "build", "convert", "format", "translate"]);
|
|
170
|
+
const READ_VERBS = new Set(["get", "list", "read", "search", "fetch", "query", "describe", "show", "find", "view", "count", "lookup", "check", "status", "retrieve", "download", "browse", "inspect", "explain", "summarize", "analyze", "lint", "validate", "preview", "diff", "compare", "resolve", "info", "whoami", "ping", "echo", "calculate", "compute", "time", "weather", "forecast", "now"]);
|
|
171
|
+
export function nameWords(name) {
|
|
172
|
+
return name.replace(/([a-z0-9])([A-Z])/g, "$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
173
|
+
}
|
|
174
|
+
function verbTags(words) {
|
|
175
|
+
const has = (...xs) => xs.some((x) => words.includes(x));
|
|
176
|
+
const tags = [];
|
|
177
|
+
if (has("send", "email", "notify", "broadcast", "tweet", "dm") && has("email", "mail", "message", "messages", "sms", "slack", "chat", "notification", "tweet", "dm", "text", "post"))
|
|
178
|
+
tags.push("message.send");
|
|
179
|
+
if (has("transfer", "pay", "refund", "charge", "payment", "invoice", "withdraw", "payout", "sell", "buy", "order"))
|
|
180
|
+
tags.push("payment");
|
|
181
|
+
if (has("publish", "post", "tweet", "release", "unpublish"))
|
|
182
|
+
tags.push("publish.public");
|
|
183
|
+
if (has("deploy"))
|
|
184
|
+
tags.push(has("prod", "production") ? "deploy.prod" : "deploy.other");
|
|
185
|
+
if (has("merge", "push"))
|
|
186
|
+
tags.push("vcs.push");
|
|
187
|
+
if (has("grant", "revoke", "invite", "ban", "kick", "suspend"))
|
|
188
|
+
tags.push("perm.change");
|
|
189
|
+
if (has("delete", "remove", "destroy", "drop", "truncate", "purge", "wipe", "erase", "archive", "overwrite"))
|
|
190
|
+
tags.push(has("table", "database", "db", "row", "rows", "record", "records", "collection") ? "db.delete" : "fs.delete");
|
|
191
|
+
if (has("execute", "exec", "run", "kill", "terminate", "shutdown", "restart", "reboot"))
|
|
192
|
+
tags.push("exec.unknown");
|
|
193
|
+
return tags;
|
|
194
|
+
}
|
|
195
|
+
/** Vocabulary + annotation profile of an MCP tool (no arguments). */
|
|
196
|
+
export function profileMcpTool(name, descriptor) {
|
|
197
|
+
const acc = new Acc();
|
|
198
|
+
const desc = typeof descriptor?.description === "string" ? descriptor.description : "";
|
|
199
|
+
const firstSentence = desc.split(/[.\n]/)[0]?.slice(0, 300) ?? "";
|
|
200
|
+
const words = nameWords(name);
|
|
201
|
+
const descWords = nameWords(firstSentence).slice(0, 3);
|
|
202
|
+
const all = [...words, ...descWords];
|
|
203
|
+
// Tool names are verb-first (get_release_by_tag): after a read or write verb, a "high" word is
|
|
204
|
+
// a noun. A high verb counts when it leads the name, or when the name has no read/write verb.
|
|
205
|
+
const plainVerb = words.some((w) => READ_VERBS.has(w) || WRITE_VERBS.has(w));
|
|
206
|
+
const high = HIGH_VERBS.has(words[0] ?? "") || (!plainVerb && words.some((w) => HIGH_VERBS.has(w))) || (words.length > 0 && !plainVerb && descWords.some((w) => HIGH_VERBS.has(w)));
|
|
207
|
+
const write = all.some((w) => WRITE_VERBS.has(w));
|
|
208
|
+
const read = words.some((w) => READ_VERBS.has(w)) || (!high && !write && descWords.some((w) => READ_VERBS.has(w)));
|
|
209
|
+
if (high) {
|
|
210
|
+
acc.raise("high-risk");
|
|
211
|
+
const tags = verbTags(all);
|
|
212
|
+
for (const tg of tags)
|
|
213
|
+
acc.tags.add(tg);
|
|
214
|
+
if (tags.length === 0)
|
|
215
|
+
acc.tags.add("exec.unknown");
|
|
216
|
+
}
|
|
217
|
+
else if (write)
|
|
218
|
+
acc.tag("write-reversible", "fs.write");
|
|
219
|
+
else if (read)
|
|
220
|
+
acc.raise("read");
|
|
221
|
+
else
|
|
222
|
+
acc.tag("write-reversible", "exec.unknown");
|
|
223
|
+
const ann = isRecord(descriptor?.annotations) ? descriptor?.annotations : undefined;
|
|
224
|
+
let contradiction = false;
|
|
225
|
+
if (ann && get(ann, "destructiveHint") === true) {
|
|
226
|
+
acc.raise("high-risk");
|
|
227
|
+
if (acc.tags.size === 0)
|
|
228
|
+
acc.tags.add("fs.delete");
|
|
229
|
+
}
|
|
230
|
+
if (ann && get(ann, "readOnlyHint") === true && high)
|
|
231
|
+
contradiction = true;
|
|
232
|
+
if (ann && get(ann, "openWorldHint") === true && acc.level !== "read")
|
|
233
|
+
acc.tags.add("net.egress");
|
|
234
|
+
return { acc, contradiction };
|
|
235
|
+
}
|
|
236
|
+
const COMMAND_KEYS = new Set(["command", "cmd", "script", "shell", "bash", "commandline", "command_line"]);
|
|
237
|
+
const SQL_KEYS = new Set(["sql", "query", "statement", "stmt", "q"]);
|
|
238
|
+
const PATH_KEYS = new Set(["path", "file", "filename", "file_path", "filepath", "target", "destination", "dest", "dir", "directory", "output", "outfile", "output_path"]);
|
|
239
|
+
export function classifyMcp(name, args, descriptor, t) {
|
|
240
|
+
const prof = profileMcpTool(name, descriptor);
|
|
241
|
+
const acc = prof.acc;
|
|
242
|
+
const words = nameWords(name);
|
|
243
|
+
const sqlLike = words.some((w) => ["sql", "query", "execute", "exec", "db", "database", "postgres", "mysql", "sqlite", "select"].includes(w));
|
|
244
|
+
const isRead = acc.level === "read";
|
|
245
|
+
if (!isRecord(args))
|
|
246
|
+
return prof;
|
|
247
|
+
let sqlSeen = false;
|
|
248
|
+
const sqlAcc = new Acc();
|
|
249
|
+
for (const k of Object.keys(args)) {
|
|
250
|
+
const v = args[k];
|
|
251
|
+
if (typeof v !== "string")
|
|
252
|
+
continue;
|
|
253
|
+
const key = k.toLowerCase();
|
|
254
|
+
if (COMMAND_KEYS.has(key))
|
|
255
|
+
acc.merge(analyzeShellCommand(v, { pctx: t.pctx, depth: 0, maxBytes: t.maxCommandBytes }));
|
|
256
|
+
if (SQL_KEYS.has(key) && sqlLike) {
|
|
257
|
+
sqlSeen = true;
|
|
258
|
+
sqlAcc.merge(analyzeSql(v, t.maxSqlBytes));
|
|
259
|
+
}
|
|
260
|
+
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(v.slice(0, 20)) && /^https?:|^wss?:|^ftp:/i.test(v) && !isRead) {
|
|
261
|
+
acc.tag("high-risk", "net.egress");
|
|
262
|
+
acc.network = true;
|
|
263
|
+
}
|
|
264
|
+
if (PATH_KEYS.has(key)) {
|
|
265
|
+
const np = normalizePath(v, t.pctx);
|
|
266
|
+
if (isProtectedRead(np, t.pctx))
|
|
267
|
+
acc.protect("CP-SELF-002", "reads a Glassbox credential file");
|
|
268
|
+
else if (!isRead && isProtected(np, t.pctx))
|
|
269
|
+
acc.protect("CP-SELF-001", "changes a file that controls the agent or Glassbox");
|
|
270
|
+
else if (!isRead && persistenceHit(np, t.pctx))
|
|
271
|
+
acc.persist(persistenceHit(np, t.pctx), "changes", np.path);
|
|
272
|
+
if (!isRead)
|
|
273
|
+
acc.wrote(np.path);
|
|
274
|
+
else if (isRead) {
|
|
275
|
+
const label = sensitiveLabel(np, t.pctx);
|
|
276
|
+
if (label) {
|
|
277
|
+
acc.tags.add("fs.read.sensitive");
|
|
278
|
+
acc.sensitive.push(label);
|
|
279
|
+
acc.sensitiveArgs = true;
|
|
280
|
+
acc.find("CP-EXFIL-040", label);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (sqlSeen) {
|
|
286
|
+
// The statement decides, not the tool's verb.
|
|
287
|
+
const keep = new Acc();
|
|
288
|
+
keep.merge(sqlAcc);
|
|
289
|
+
for (const f of acc.findings)
|
|
290
|
+
keep.find(f.ruleId, f.note);
|
|
291
|
+
if (acc.selfProtection)
|
|
292
|
+
keep.selfProtection = true;
|
|
293
|
+
for (const tg of acc.tags)
|
|
294
|
+
if (tg === "net.egress" || tg === "self-protection")
|
|
295
|
+
keep.tags.add(tg);
|
|
296
|
+
for (const r of acc.unanalyzableReasons)
|
|
297
|
+
keep.unanalyzable(r);
|
|
298
|
+
const ann = isRecord(descriptor?.annotations) ? descriptor?.annotations : undefined;
|
|
299
|
+
if (ann && get(ann, "destructiveHint") === true)
|
|
300
|
+
keep.raise("high-risk");
|
|
301
|
+
return { acc: keep, contradiction: prof.contradiction };
|
|
302
|
+
}
|
|
303
|
+
return prof;
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Acc } from "./acc.js";
|
|
2
|
+
import { type NormPath, type PathCtx } from "./paths.js";
|
|
3
|
+
export type UploadKind = "sensitive" | "outside" | "project";
|
|
4
|
+
/** True for loopback host names and addresses. */
|
|
5
|
+
export declare function isLoopbackHost(host: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The host of a URL, a bare host[:port][/path], or user@host:path. Null when there is none
|
|
8
|
+
* (for example a value with no host-like start). String code only.
|
|
9
|
+
*/
|
|
10
|
+
export declare function hostOf(v: string): string | null;
|
|
11
|
+
/** Destinations are known and all on this machine. */
|
|
12
|
+
export declare function allLoopback(destinations: readonly (string | null)[]): boolean;
|
|
13
|
+
/** Classifies an uploaded file. `projectDir` is the session's project directory. */
|
|
14
|
+
export declare function classifyUpload(np: NormPath | null, pctx: PathCtx, projectDir: string | null): UploadKind;
|
|
15
|
+
/** Records one uploaded file (the caller has checked the destination isn't loopback). */
|
|
16
|
+
export declare function recordUpload(acc: Acc, kind: UploadKind, what: string): void;
|
|
17
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { isProtectedRead, sensitiveLabel } from "./paths.js";
|
|
2
|
+
/** True for loopback host names and addresses. */
|
|
3
|
+
export function isLoopbackHost(host) {
|
|
4
|
+
const h = host.toLowerCase().replace(/^\[|\]$/g, "");
|
|
5
|
+
if (h === "localhost" || h.endsWith(".localhost") || h === "::1" || h === "0.0.0.0")
|
|
6
|
+
return true;
|
|
7
|
+
const parts = h.split(".");
|
|
8
|
+
return parts.length === 4 && parts[0] === "127" && parts.every((p) => /^\d{1,3}$/.test(p) && Number(p) <= 255);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The host of a URL, a bare host[:port][/path], or user@host:path. Null when there is none
|
|
12
|
+
* (for example a value with no host-like start). String code only.
|
|
13
|
+
*/
|
|
14
|
+
export function hostOf(v) {
|
|
15
|
+
let s = v.trim();
|
|
16
|
+
const scheme = s.indexOf("://");
|
|
17
|
+
if (scheme > 0)
|
|
18
|
+
s = s.slice(scheme + 3);
|
|
19
|
+
const at = s.indexOf("@");
|
|
20
|
+
const slash = s.indexOf("/");
|
|
21
|
+
if (at >= 0 && (slash < 0 || at < slash))
|
|
22
|
+
s = s.slice(at + 1);
|
|
23
|
+
if (s.startsWith("[")) {
|
|
24
|
+
const end = s.indexOf("]");
|
|
25
|
+
return end > 0 ? s.slice(0, end + 1) : null;
|
|
26
|
+
}
|
|
27
|
+
let end = s.length;
|
|
28
|
+
for (const ch of [":", "/", "?", "#"]) {
|
|
29
|
+
const i = s.indexOf(ch);
|
|
30
|
+
if (i >= 0 && i < end)
|
|
31
|
+
end = i;
|
|
32
|
+
}
|
|
33
|
+
const host = s.slice(0, end);
|
|
34
|
+
return host.length > 0 ? host : null;
|
|
35
|
+
}
|
|
36
|
+
/** Destinations are known and all on this machine. */
|
|
37
|
+
export function allLoopback(destinations) {
|
|
38
|
+
if (destinations.length === 0)
|
|
39
|
+
return false;
|
|
40
|
+
return destinations.every((d) => d !== null && (() => { const h = hostOf(d); return h !== null && isLoopbackHost(h); })());
|
|
41
|
+
}
|
|
42
|
+
/** Classifies an uploaded file. `projectDir` is the session's project directory. */
|
|
43
|
+
export function classifyUpload(np, pctx, projectDir) {
|
|
44
|
+
if (np === null || np.path === null) {
|
|
45
|
+
if (np !== null && sensitiveLabel(np, pctx))
|
|
46
|
+
return "sensitive";
|
|
47
|
+
return "outside"; // not known statically: it can't be shown to be a project file
|
|
48
|
+
}
|
|
49
|
+
if (isProtectedRead(np, pctx) || sensitiveLabel(np, pctx))
|
|
50
|
+
return "sensitive";
|
|
51
|
+
if (projectDir === null)
|
|
52
|
+
return "outside";
|
|
53
|
+
const fold = (s) => (pctx.caseInsensitive ? s.toLowerCase() : s);
|
|
54
|
+
const root = fold(projectDir.endsWith("/") ? projectDir.slice(0, -1) : projectDir);
|
|
55
|
+
const p = fold(np.path);
|
|
56
|
+
return p === root || p.startsWith(root + "/") ? "project" : "outside";
|
|
57
|
+
}
|
|
58
|
+
/** Records one uploaded file (the caller has checked the destination isn't loopback). */
|
|
59
|
+
export function recordUpload(acc, kind, what) {
|
|
60
|
+
acc.uploads.push(kind);
|
|
61
|
+
acc.tag("high-risk", "net.egress");
|
|
62
|
+
acc.network = true;
|
|
63
|
+
if (kind === "sensitive") {
|
|
64
|
+
acc.sensitiveArgs = true;
|
|
65
|
+
acc.find("CP-EXFIL-030", `uploads a sensitive file (${what})`);
|
|
66
|
+
}
|
|
67
|
+
else if (kind === "outside") {
|
|
68
|
+
acc.find("CP-EXFIL-035", `uploads a file from outside the project, or one that isn't known statically (${what})`);
|
|
69
|
+
}
|
|
70
|
+
acc.reason(`uploads a local file (${what})`);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=upload.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface Field {
|
|
2
|
+
pointer: string;
|
|
3
|
+
kind: "string" | "key";
|
|
4
|
+
role: string;
|
|
5
|
+
text: string;
|
|
6
|
+
/** JSON key the string sits under (for key-name-sensitive detectors). */
|
|
7
|
+
keyName: string | undefined;
|
|
8
|
+
/** Index of the tool this field belongs to (manifest only). */
|
|
9
|
+
toolIndex?: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function manifestFields(m: unknown, maxTools: number): Field[];
|
|
12
|
+
export declare function genericFields(root: unknown, base: string, role: string, keyRole: string): Field[];
|
|
13
|
+
export declare function roleMatches(patterns: readonly string[] | undefined, role: string): boolean;
|
|
14
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// C3: field enumeration with roles, per surface. Iterative.
|
|
2
|
+
import { jcs } from "../util/jcs.js";
|
|
3
|
+
import { isRecord, ptrSeg } from "../util/misc.js";
|
|
4
|
+
function walk(root, base, emit, maxNodes = 200_000) {
|
|
5
|
+
const stack = [{ v: root, pointer: base, path: [], key: undefined }];
|
|
6
|
+
let n = 0;
|
|
7
|
+
while (stack.length > 0 && n++ < maxNodes) {
|
|
8
|
+
const w = stack.pop();
|
|
9
|
+
const v = w.v;
|
|
10
|
+
if (typeof v === "string")
|
|
11
|
+
emit(w, false);
|
|
12
|
+
else if (Array.isArray(v)) {
|
|
13
|
+
for (let i = v.length - 1; i >= 0; i--)
|
|
14
|
+
stack.push({ v: v[i], pointer: `${w.pointer}/${i}`, path: [...w.path, String(i)], key: w.key });
|
|
15
|
+
}
|
|
16
|
+
else if (isRecord(v)) {
|
|
17
|
+
const keys = Object.keys(v);
|
|
18
|
+
for (let i = keys.length - 1; i >= 0; i--) {
|
|
19
|
+
const k = keys[i];
|
|
20
|
+
const child = { v: v[k], pointer: `${w.pointer}/${ptrSeg(k)}`, path: [...w.path, k], key: k };
|
|
21
|
+
stack.push(child);
|
|
22
|
+
}
|
|
23
|
+
// Keys are fields too (emitted in document order before values).
|
|
24
|
+
for (const k of keys)
|
|
25
|
+
emit({ v: k, pointer: `${w.pointer}/${ptrSeg(k)}`, path: [...w.path, k], key: k }, true);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function schemaRole(path, isKey) {
|
|
30
|
+
// path inside inputSchema/outputSchema
|
|
31
|
+
const last = path[path.length - 1] ?? "";
|
|
32
|
+
const parent = path[path.length - 2] ?? "";
|
|
33
|
+
if (isKey)
|
|
34
|
+
return parent === "properties" ? "tool.schema.key" : "tool.schema.other";
|
|
35
|
+
if (path.includes("enum"))
|
|
36
|
+
return "tool.schema.enum";
|
|
37
|
+
if (path.includes("examples"))
|
|
38
|
+
return "tool.schema.examples";
|
|
39
|
+
if (last === "default" || path.includes("default"))
|
|
40
|
+
return "tool.schema.default";
|
|
41
|
+
if (last === "const")
|
|
42
|
+
return "tool.schema.const";
|
|
43
|
+
if (last === "description")
|
|
44
|
+
return "tool.schema.description";
|
|
45
|
+
if (last === "title")
|
|
46
|
+
return "tool.schema.title";
|
|
47
|
+
return "tool.schema.other";
|
|
48
|
+
}
|
|
49
|
+
export function manifestFields(m, maxTools) {
|
|
50
|
+
const out = [];
|
|
51
|
+
walk(m, "", (w, isKey) => {
|
|
52
|
+
// "key~dupN" takes the role of "key".
|
|
53
|
+
const p = w.path.map((seg) => seg.replace(/~dup\d+$/, ""));
|
|
54
|
+
let role = "manifest.other";
|
|
55
|
+
let toolIndex;
|
|
56
|
+
if (p[0] === "initialize") {
|
|
57
|
+
if (p[1] === "instructions" && !isKey)
|
|
58
|
+
role = "server.instructions";
|
|
59
|
+
else if (p[1] === "serverInfo")
|
|
60
|
+
role = "server.info";
|
|
61
|
+
}
|
|
62
|
+
else if (p[0] === "tools" && p.length >= 2) {
|
|
63
|
+
toolIndex = Number(p[1]);
|
|
64
|
+
if (toolIndex >= maxTools)
|
|
65
|
+
return;
|
|
66
|
+
const f = p[2];
|
|
67
|
+
if (p.length === 3 && !isKey && (f === "name" || f === "title" || f === "description"))
|
|
68
|
+
role = `tool.${f}`;
|
|
69
|
+
else if (f === "annotations")
|
|
70
|
+
role = "tool.annotation";
|
|
71
|
+
else if ((f === "inputSchema" || f === "outputSchema") && p.length > 3)
|
|
72
|
+
role = schemaRole(p.slice(3), isKey);
|
|
73
|
+
else if (isKey && p.length === 3)
|
|
74
|
+
role = "tool.key";
|
|
75
|
+
else
|
|
76
|
+
role = "tool.other";
|
|
77
|
+
}
|
|
78
|
+
else if (p[0] === "prompts")
|
|
79
|
+
role = p[2] === "name" && p.length === 3 ? "prompt.name" : "prompt.text";
|
|
80
|
+
else if (p[0] === "resources" || p[0] === "resourceTemplates")
|
|
81
|
+
role = "resource.text";
|
|
82
|
+
// Ordinary structural keys are not interesting text.
|
|
83
|
+
if (isKey && (role === "manifest.other" || role === "tool.key" || role === "tool.other" || role === "tool.annotation" || role === "server.info" || role === "prompt.text" || role === "resource.text"))
|
|
84
|
+
return;
|
|
85
|
+
out.push({ pointer: w.pointer, kind: isKey ? "key" : "string", role, text: String(w.v), keyName: w.key, ...(toolIndex !== undefined ? { toolIndex } : {}) });
|
|
86
|
+
});
|
|
87
|
+
// Non-string enum/default/const values are scanned in JCS form.
|
|
88
|
+
const tools = isRecord(m) && Array.isArray(m["tools"]) ? m["tools"] : [];
|
|
89
|
+
tools.slice(0, maxTools).forEach((t, ti) => {
|
|
90
|
+
for (const s of ["inputSchema", "outputSchema"]) {
|
|
91
|
+
const sch = isRecord(t) ? t[s] : undefined;
|
|
92
|
+
walkNonString(sch, `/tools/${ti}/${s}`, (pointer, value, role) => out.push({ pointer, kind: "string", role, text: value, keyName: undefined, toolIndex: ti }));
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
function walkNonString(root, base, emit) {
|
|
98
|
+
const stack = [{ v: root, pointer: base }];
|
|
99
|
+
let n = 0;
|
|
100
|
+
while (stack.length > 0 && n++ < 50_000) {
|
|
101
|
+
const { v, pointer } = stack.pop();
|
|
102
|
+
if (Array.isArray(v))
|
|
103
|
+
v.forEach((x, i) => stack.push({ v: x, pointer: `${pointer}/${i}` }));
|
|
104
|
+
else if (isRecord(v)) {
|
|
105
|
+
for (const k of Object.keys(v)) {
|
|
106
|
+
const x = v[k];
|
|
107
|
+
if ((k === "default" || k === "const") && x !== null && typeof x === "object") {
|
|
108
|
+
try {
|
|
109
|
+
emit(`${pointer}/${ptrSeg(k)}`, jcs(x), k === "default" ? "tool.schema.default" : "tool.schema.const");
|
|
110
|
+
}
|
|
111
|
+
catch { /* skip */ }
|
|
112
|
+
}
|
|
113
|
+
stack.push({ v: x, pointer: `${pointer}/${ptrSeg(k)}` });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export function genericFields(root, base, role, keyRole) {
|
|
119
|
+
const out = [];
|
|
120
|
+
walk(root, base, (w, isKey) => {
|
|
121
|
+
out.push({ pointer: w.pointer, kind: isKey ? "key" : "string", role: isKey ? keyRole : role, text: String(w.v), keyName: w.key });
|
|
122
|
+
});
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
export function roleMatches(patterns, role) {
|
|
126
|
+
if (!patterns || patterns.length === 0)
|
|
127
|
+
return true;
|
|
128
|
+
for (const p of patterns) {
|
|
129
|
+
if (p === "*" || p === role)
|
|
130
|
+
return true;
|
|
131
|
+
if (p.endsWith(".*") && role.startsWith(p.slice(0, -1)))
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=fields.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Finding, LoadedRuleset, RuleDef, Severity, ViaKind } from "../types.js";
|
|
2
|
+
export declare class FindingFactory {
|
|
3
|
+
readonly evidenceMode: "snippet" | "none";
|
|
4
|
+
private byId;
|
|
5
|
+
constructor(ruleset: LoadedRuleset, evidenceMode: "snippet" | "none");
|
|
6
|
+
rule(id: string): RuleDef | undefined;
|
|
7
|
+
has(id: string): boolean;
|
|
8
|
+
make(args: {
|
|
9
|
+
ruleId: string;
|
|
10
|
+
location: string;
|
|
11
|
+
text?: string;
|
|
12
|
+
start?: number;
|
|
13
|
+
end?: number;
|
|
14
|
+
via?: ViaKind[];
|
|
15
|
+
severity?: Severity;
|
|
16
|
+
confidence?: number;
|
|
17
|
+
related?: string[];
|
|
18
|
+
explanation?: string;
|
|
19
|
+
}): Finding | null;
|
|
20
|
+
}
|
|
21
|
+
export declare const sevRank: (s: Severity) => number;
|
|
22
|
+
export declare function sortFindings(fs: Finding[]): Finding[];
|
|
23
|
+
/** One finding per (rule, location): keep the most severe. */
|
|
24
|
+
export declare function dedupe(fs: (Finding | null)[]): Finding[];
|
|
25
|
+
//# sourceMappingURL=findings.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Finding construction and the rule-metadata lookup.
|
|
2
|
+
import { makeEvidence } from "../evidence/evidence.js";
|
|
3
|
+
import { sha256Hex } from "../util/hash.js";
|
|
4
|
+
/** Minimal metadata for engine-emitted rules, used only if a ruleset lacks the rule. */
|
|
5
|
+
const FALLBACK = {
|
|
6
|
+
"CP-ACTION-001": ["dangerous-action", "critical"], "CP-FLOW-002": ["toxic-flow", "critical"], "CP-SRVREQ-002": ["server-request", "critical"],
|
|
7
|
+
"CP-SRVREQ-010": ["server-request", "critical"], "CP-SELF-001": ["self-protection", "high"], "CP-SELF-002": ["self-protection", "high"],
|
|
8
|
+
"CP-SELF-003": ["self-protection", "high"], "CP-SHELL-001": ["obfuscation", "medium"],
|
|
9
|
+
};
|
|
10
|
+
export class FindingFactory {
|
|
11
|
+
evidenceMode;
|
|
12
|
+
byId = new Map();
|
|
13
|
+
constructor(ruleset, evidenceMode) {
|
|
14
|
+
this.evidenceMode = evidenceMode;
|
|
15
|
+
for (const r of ruleset.rules)
|
|
16
|
+
this.byId.set(r.id, r);
|
|
17
|
+
}
|
|
18
|
+
rule(id) {
|
|
19
|
+
return this.byId.get(id);
|
|
20
|
+
}
|
|
21
|
+
has(id) {
|
|
22
|
+
return this.byId.has(id);
|
|
23
|
+
}
|
|
24
|
+
make(args) {
|
|
25
|
+
const r = this.byId.get(args.ruleId);
|
|
26
|
+
const fb = FALLBACK[args.ruleId];
|
|
27
|
+
if (!r && !fb)
|
|
28
|
+
return null;
|
|
29
|
+
const via = args.via ?? [];
|
|
30
|
+
const text = args.text ?? "";
|
|
31
|
+
const start = Math.max(0, Math.min(args.start ?? 0, text.length));
|
|
32
|
+
const end = Math.max(start, Math.min(args.end ?? Math.min(text.length, start + 80), text.length));
|
|
33
|
+
const f = {
|
|
34
|
+
id: sha256Hex(`${args.ruleId}\u0000${args.location}\u0000${via.join(",")}`).slice(0, 16),
|
|
35
|
+
ruleId: args.ruleId,
|
|
36
|
+
ruleSource: args.ruleId.startsWith("PV-") ? "private" : "baseline",
|
|
37
|
+
category: r?.category ?? fb[0],
|
|
38
|
+
severity: args.severity ?? r?.severity ?? fb[1],
|
|
39
|
+
confidence: Math.round((args.confidence ?? r?.confidence ?? 1) * 100) / 100,
|
|
40
|
+
location: args.location,
|
|
41
|
+
evidence: text.length > 0 ? makeEvidence(text, start, end, this.evidenceMode) : this.evidenceMode === "none" ? "[evidence withheld by policy]" : '""',
|
|
42
|
+
explanation: args.explanation ?? r?.explanation ?? `Glassbox rule ${args.ruleId} matched.`,
|
|
43
|
+
remediation: r?.remediation ?? "Review this action.",
|
|
44
|
+
};
|
|
45
|
+
if (text.length > 0)
|
|
46
|
+
f.span = { start: cpOffset(text, start), end: cpOffset(text, end) };
|
|
47
|
+
if (via.length > 0)
|
|
48
|
+
f.via = via;
|
|
49
|
+
if (args.related && args.related.length > 0)
|
|
50
|
+
f.related = args.related;
|
|
51
|
+
return f;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function cpOffset(s, utf16) {
|
|
55
|
+
let n = 0;
|
|
56
|
+
for (let i = 0; i < utf16 && i < s.length; i++) {
|
|
57
|
+
const c = s.charCodeAt(i);
|
|
58
|
+
if (c >= 0xd800 && c <= 0xdbff && i + 1 < utf16)
|
|
59
|
+
i++;
|
|
60
|
+
n++;
|
|
61
|
+
}
|
|
62
|
+
return n;
|
|
63
|
+
}
|
|
64
|
+
const SEV = ["info", "low", "medium", "high", "critical"];
|
|
65
|
+
export const sevRank = (s) => SEV.indexOf(s);
|
|
66
|
+
export function sortFindings(fs) {
|
|
67
|
+
return fs.sort((a, b) => sevRank(b.severity) - sevRank(a.severity) || (a.ruleId < b.ruleId ? -1 : a.ruleId > b.ruleId ? 1 : 0) || (a.location < b.location ? -1 : a.location > b.location ? 1 : 0));
|
|
68
|
+
}
|
|
69
|
+
/** One finding per (rule, location): keep the most severe. */
|
|
70
|
+
export function dedupe(fs) {
|
|
71
|
+
const m = new Map();
|
|
72
|
+
for (const f of fs) {
|
|
73
|
+
if (!f)
|
|
74
|
+
continue;
|
|
75
|
+
const k = f.ruleId + "\u0000" + f.location;
|
|
76
|
+
const prev = m.get(k);
|
|
77
|
+
if (!prev || sevRank(f.severity) > sevRank(prev.severity))
|
|
78
|
+
m.set(k, f);
|
|
79
|
+
}
|
|
80
|
+
return [...m.values()];
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=findings.js.map
|