@openai/codex-security 0.8.0 → 0.8.2
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/README.md +16 -10
- package/_bundled_plugin/.codex-plugin/plugin.json +1 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +4 -4
- package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
- package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
- package/_bundled_plugin/references/scan-artifacts.md +1 -1
- package/_bundled_plugin/scripts/finalize_scan_contract.py +37 -1
- package/_bundled_plugin/scripts/servicenow_avit.py +107 -0
- package/_bundled_plugin/scripts/workbench_coverage_receipts.py +0 -17
- package/_bundled_plugin/scripts/workbench_db.py +1 -3
- package/_bundled_plugin/scripts/workbench_saved_results.py +0 -66
- package/_bundled_plugin/scripts/workbench_scan_start.py +4 -1
- package/_bundled_plugin/scripts/workbench_target.py +0 -108
- package/_bundled_plugin/skills/publish-findings/SKILL.md +9 -3
- package/_bundled_plugin/skills/resolve-dependency-alert/SKILL.md +18 -0
- package/_bundled_plugin/skills/resolve-dependency-alert/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/security-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/threat-model-visualize/SKILL.md +83 -0
- package/_bundled_plugin/skills/threat-model-visualize/agents/openai.yaml +4 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-overview.svg +366 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-path.svg +558 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/control-effects.js +85 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.css +17 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.html +38 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.js +372 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/route-paths.js +71 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/source-roles.js +47 -0
- package/_bundled_plugin/skills/threat-model-visualize/assets/svg-layout.js +149 -0
- package/_bundled_plugin/skills/threat-model-visualize/references/context-explorer.md +21 -0
- package/_bundled_plugin/skills/threat-model-visualize/references/view-model.md +49 -0
- package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +563 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +36 -15
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +12 -3
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +30 -10
- package/dist/artifact-export.js.map +1 -1
- package/dist/auth.js +1 -1
- package/dist/auth.js.map +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +1 -0
- package/dist/cli-help.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +72 -50
- package/dist/cli.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +16 -12
- package/dist/contract.js.map +1 -1
- package/dist/custom-validation-prompt.d.ts.map +1 -1
- package/dist/custom-validation-prompt.js +12 -4
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/custom-validation.js +2 -2
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +1 -1
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/records-protocol.d.ts.map +1 -1
- package/dist/deduplication/records-protocol.js +36 -22
- package/dist/deduplication/records-protocol.js.map +1 -1
- package/dist/deduplication/records.d.ts +3 -1
- package/dist/deduplication/records.d.ts.map +1 -1
- package/dist/deduplication/records.js +12 -8
- package/dist/deduplication/records.js.map +1 -1
- package/dist/endor-findings.d.ts.map +1 -1
- package/dist/endor-findings.js +46 -61
- package/dist/endor-findings.js.map +1 -1
- package/dist/external-findings-import.d.ts.map +1 -1
- package/dist/external-findings-import.js +8 -6
- package/dist/external-findings-import.js.map +1 -1
- package/dist/external-findings-local.d.ts +3 -1
- package/dist/external-findings-local.d.ts.map +1 -1
- package/dist/external-findings-local.js +136 -36
- package/dist/external-findings-local.js.map +1 -1
- package/dist/external-findings-publish.d.ts +3 -1
- package/dist/external-findings-publish.d.ts.map +1 -1
- package/dist/external-findings-publish.js +56 -31
- package/dist/external-findings-publish.js.map +1 -1
- package/dist/external-findings-read.d.ts +2 -0
- package/dist/external-findings-read.d.ts.map +1 -1
- package/dist/external-findings-read.js +9 -0
- package/dist/external-findings-read.js.map +1 -1
- package/dist/external-findings.d.ts +11 -0
- package/dist/external-findings.d.ts.map +1 -1
- package/dist/external-findings.js +13 -1
- package/dist/external-findings.js.map +1 -1
- package/dist/external-import-models.d.ts +1 -1
- package/dist/external-import-models.d.ts.map +1 -1
- package/dist/external-import-models.js.map +1 -1
- package/dist/github-advisories.d.ts.map +1 -1
- package/dist/github-advisories.js +5 -5
- package/dist/github-advisories.js.map +1 -1
- package/dist/github-dependabot-findings.d.ts +6 -0
- package/dist/github-dependabot-findings.d.ts.map +1 -0
- package/dist/github-dependabot-findings.js +247 -0
- package/dist/github-dependabot-findings.js.map +1 -0
- package/dist/github-findings.d.ts.map +1 -1
- package/dist/github-findings.js +11 -4
- package/dist/github-findings.js.map +1 -1
- package/dist/github-identifiers.d.ts +4 -0
- package/dist/github-identifiers.d.ts.map +1 -0
- package/dist/github-identifiers.js +9 -0
- package/dist/github-identifiers.js.map +1 -0
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +4 -6
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.d.ts +5 -0
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +27 -3
- package/dist/host-protocol.js.map +1 -1
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +13 -5
- package/dist/hosted-scan.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/inspector-findings.d.ts +9 -0
- package/dist/inspector-findings.d.ts.map +1 -0
- package/dist/inspector-findings.js +517 -0
- package/dist/inspector-findings.js.map +1 -0
- package/dist/patch-tui.d.ts +1 -1
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +4 -1
- package/dist/patch-tui.js.map +1 -1
- package/dist/runtime.d.ts +3 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +15 -5
- package/dist/runtime.js.map +1 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +25 -15
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scanner-import.d.ts +6 -2
- package/dist/scanner-import.d.ts.map +1 -1
- package/dist/scanner-import.js +23 -14
- package/dist/scanner-import.js.map +1 -1
- package/dist/semgrep-findings.d.ts.map +1 -1
- package/dist/semgrep-findings.js +39 -49
- package/dist/semgrep-findings.js.map +1 -1
- package/dist/snyk-findings.d.ts.map +1 -1
- package/dist/snyk-findings.js +78 -88
- package/dist/snyk-findings.js.map +1 -1
- package/docs/cli.md +52 -14
- package/docs/dedupe-records.md +17 -4
- package/docs/hosted-scans.md +14 -0
- package/package.json +5 -5
- package/schemas/external-findings.schema.json +1 -1
package/dist/snyk-findings.js
CHANGED
|
@@ -42,7 +42,7 @@ export function normalizeSnykFindingsExport(input, target = "cloud") {
|
|
|
42
42
|
const collection = record(document["collection"], "Snyk collection");
|
|
43
43
|
const sourceTarget = record(collection["target"], "Snyk target");
|
|
44
44
|
const { findings: _findings, ...context } = document;
|
|
45
|
-
return normalizeRecords(array(document["findings"], "Snyk findings"), (value
|
|
45
|
+
return normalizeRecords(array(document["findings"], "Snyk findings"), (value) => {
|
|
46
46
|
const finding = record(value, "Snyk plugin finding");
|
|
47
47
|
const observation = record(finding["observation"], "Snyk observation");
|
|
48
48
|
if (finding["originatingScanner"] !== "snyk-open-source" ||
|
|
@@ -57,38 +57,34 @@ export function normalizeSnykFindingsExport(input, target = "cloud") {
|
|
|
57
57
|
const remediation = record(finding["remediation"] ?? {}, "Snyk remediation");
|
|
58
58
|
const severity = text(record(finding["severity"], "Snyk severity")["value"])?.toLowerCase();
|
|
59
59
|
const revision = text(sourceTarget["revision"]);
|
|
60
|
-
return {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
...
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
: null,
|
|
89
|
-
source_data: structuredClone({ ...context, finding }),
|
|
90
|
-
}, target),
|
|
91
|
-
};
|
|
60
|
+
return validateExternalEvidence({
|
|
61
|
+
title: requiredText(finding["title"], "Snyk title"),
|
|
62
|
+
description: text(record(finding["description"] ?? {}, "Snyk description")["text"]),
|
|
63
|
+
severity: ["critical", "high", "medium", "low"].includes(severity ?? "")
|
|
64
|
+
? severity
|
|
65
|
+
: "unknown",
|
|
66
|
+
advisory_ids: [
|
|
67
|
+
...new Set([
|
|
68
|
+
requiredText(rule["id"], "Snyk advisory ID"),
|
|
69
|
+
...strings(aliases["cve"]),
|
|
70
|
+
]),
|
|
71
|
+
],
|
|
72
|
+
packages: [
|
|
73
|
+
{
|
|
74
|
+
name: requiredText(pkg["name"], "Snyk package name"),
|
|
75
|
+
ecosystem: text(pkg["ecosystem"]),
|
|
76
|
+
installed_version: text(pkg["version"]),
|
|
77
|
+
// Plugin v1 manifests are target-relative, without a Git-root offset.
|
|
78
|
+
manifest_path: null,
|
|
79
|
+
fixed_versions: strings(remediation["fixedIn"]),
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
locations: [],
|
|
83
|
+
code_revision: sourceTarget["workingTreeDirty"] === false && revision !== "unknown"
|
|
84
|
+
? revision
|
|
85
|
+
: null,
|
|
86
|
+
source_data: structuredClone({ ...context, finding }),
|
|
87
|
+
}, target);
|
|
92
88
|
}, pluginIdentity, target);
|
|
93
89
|
}
|
|
94
90
|
function normalizeGitRepositoryUrl(repository, cloudRepositoryUrl) {
|
|
@@ -195,7 +191,7 @@ export function normalizeSnykSarif(input, target = "cloud") {
|
|
|
195
191
|
documentContext,
|
|
196
192
|
}));
|
|
197
193
|
});
|
|
198
|
-
return normalizeRecords(entries, ({ result: value, rulesById, runContext, driverContext, documentContext }
|
|
194
|
+
return normalizeRecords(entries, ({ result: value, rulesById, runContext, driverContext, documentContext, }) => {
|
|
199
195
|
const result = record(value, "SARIF result");
|
|
200
196
|
const id = requiredText(result["ruleId"], "Snyk advisory ruleId");
|
|
201
197
|
const match = rulesById.get(id);
|
|
@@ -242,31 +238,28 @@ export function normalizeSnykSarif(input, target = "cloud") {
|
|
|
242
238
|
}
|
|
243
239
|
const description = [message, help].join("\n\n");
|
|
244
240
|
// Use the project, advisory group, and literal manifest set within the caller's namespace.
|
|
245
|
-
return {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
...
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}),
|
|
268
|
-
}, target),
|
|
269
|
-
};
|
|
241
|
+
return validateExternalEvidence({
|
|
242
|
+
title,
|
|
243
|
+
description,
|
|
244
|
+
severity,
|
|
245
|
+
advisory_ids: [
|
|
246
|
+
...new Set([
|
|
247
|
+
id,
|
|
248
|
+
...(text(record(rule["fullDescription"] ?? {}, "Full description")["text"])?.match(/\bCVE-\d{4}-\d+\b/gu) ?? []),
|
|
249
|
+
]),
|
|
250
|
+
],
|
|
251
|
+
packages,
|
|
252
|
+
// Snyk emits target-relative paths without a Git-root offset and may
|
|
253
|
+
// synthesize startLine=1. Keep both only in the original evidence.
|
|
254
|
+
locations: [],
|
|
255
|
+
source_data: structuredClone({
|
|
256
|
+
document: documentContext,
|
|
257
|
+
run: sarifRunContextForResult(runContext, result, rule, driverContext, documentContext),
|
|
258
|
+
driver: driverContext,
|
|
259
|
+
rule,
|
|
260
|
+
result,
|
|
261
|
+
}),
|
|
262
|
+
}, target);
|
|
270
263
|
}, ({ result, project }) => snykIdentity(result, project), target);
|
|
271
264
|
}
|
|
272
265
|
/** Import native `snyk test --json` Open Source vulnerability occurrences. */
|
|
@@ -290,40 +283,37 @@ export function normalizeSnykJson(input, target = "cloud") {
|
|
|
290
283
|
manifest,
|
|
291
284
|
}));
|
|
292
285
|
});
|
|
293
|
-
return normalizeRecords(entries, ({ value, context, manager }
|
|
286
|
+
return normalizeRecords(entries, ({ value, context, manager }) => {
|
|
294
287
|
const vulnerability = record(value, "Snyk vulnerability");
|
|
295
288
|
if (vulnerability["type"] === "license")
|
|
296
289
|
throw new Error("Snyk license findings are unsupported; only Open Source SCA vulnerabilities are imported.");
|
|
297
290
|
const identifiers = record(vulnerability["identifiers"] ?? {}, "Snyk identifiers");
|
|
298
291
|
const severity = text(vulnerability["severity"])?.toLowerCase();
|
|
299
|
-
return {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
...
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
source_data: structuredClone({ project: context, vulnerability }),
|
|
325
|
-
}, target),
|
|
326
|
-
};
|
|
292
|
+
return validateExternalEvidence({
|
|
293
|
+
title: requiredText(vulnerability["title"], "Snyk vulnerability title"),
|
|
294
|
+
description: text(vulnerability["description"]),
|
|
295
|
+
severity: ["critical", "high", "medium", "low"].includes(severity ?? "")
|
|
296
|
+
? severity
|
|
297
|
+
: "unknown",
|
|
298
|
+
advisory_ids: [
|
|
299
|
+
...new Set([
|
|
300
|
+
requiredText(vulnerability["id"], "Snyk advisory ID"),
|
|
301
|
+
...strings(identifiers["CVE"]),
|
|
302
|
+
]),
|
|
303
|
+
],
|
|
304
|
+
packages: [
|
|
305
|
+
{
|
|
306
|
+
name: requiredText(vulnerability["name"] ?? vulnerability["packageName"], "Snyk package name"),
|
|
307
|
+
ecosystem: manager,
|
|
308
|
+
installed_version: text(vulnerability["version"]),
|
|
309
|
+
// Native test paths are scan-target-relative, without a Git-root offset.
|
|
310
|
+
manifest_path: null,
|
|
311
|
+
fixed_versions: strings(vulnerability["fixedIn"]),
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
locations: [],
|
|
315
|
+
source_data: structuredClone({ project: context, vulnerability }),
|
|
316
|
+
}, target);
|
|
327
317
|
}, ({ value, manager, manifest }) => {
|
|
328
318
|
const vulnerability = record(value, "Snyk vulnerability");
|
|
329
319
|
return stableId("snyk-json", [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snyk-findings.js","sourceRoot":"","sources":["../src/snyk-findings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,KAAK,EACL,kCAAkC,EAClC,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,YAAY,EACZ,wBAAwB,EACxB,QAAQ,EACR,OAAO,EACP,IAAI,GACL,MAAM,qBAAqB,CAAC;AAE7B,SAAS,YAAY,CAAC,KAAc,EAAE,OAAsB;IAC1D,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,sBAAsB,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,kBAAkB,CAAC;SAC/D,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACb,MAAM,QAAQ,GAAG,MAAM,CACrB,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,kBAAkB,CAAC,IAAI,EAAE,EACnD,mBAAmB,CACpB,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,CACrB,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE,EAClC,mBAAmB,CACpB,CAAC;QACF,IACE,QAAQ,CAAC,OAAO,CAAC,KAAK,SAAS;YAC/B,QAAQ,CAAC,WAAW,CAAC,KAAK,SAAS;YAEnC,MAAM,IAAI,KAAK,CACb,+GAA+G,CAChH,CAAC;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC;SAC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AM,CAAC,CAAC;IAC9C,OAAO,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { validateExternalEvidence } from \"./external-import-contract.js\";\nimport type { ExternalFindings } from \"./external-findings.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n array,\n hasSarifExternalPropertyReferences,\n normalizeRecords,\n readScannerJson,\n record,\n requiredText,\n sarifRunContextForResult,\n stableId,\n strings,\n text,\n} from \"./scanner-import.js\";\n\nfunction snykIdentity(value: unknown, project: string | null): string {\n const result = record(value, \"SARIF result\");\n const id = requiredText(result[\"ruleId\"], \"Snyk advisory ruleId\");\n const paths = array(result[\"locations\"] ?? [], \"Result locations\")\n .map((value) => {\n const physical = record(\n record(value, \"Location\")[\"physicalLocation\"] ?? {},\n \"Physical location\",\n );\n const artifact = record(\n physical[\"artifactLocation\"] ?? {},\n \"Artifact location\",\n );\n if (\n artifact[\"index\"] !== undefined ||\n artifact[\"uriBaseId\"] !== undefined\n )\n throw new Error(\n \"Snyk SARIF artifact references are unsupported; use direct manifest URIs from the Snyk Open Source formatter.\",\n );\n return text(artifact[\"uri\"]);\n })\n .filter((path): path is string => path !== null);\n const fields: unknown[] = [id, [...new Set(paths)].sort()];\n if (project !== null) fields.push(project);\n return stableId(\"snyk-sarif\", fields);\n}\n\nfunction snykSarifProject(run: Record<string, unknown>): string | null {\n const details = run[\"automationDetails\"];\n const id = isRecord(details) ? text(details[\"id\"]) : null;\n // The formatter appends a run index and export timestamp after the project name.\n return /^Snyk\\/Open Source\\/(.+)\\/\\d+\\/[^/]+$/su.exec(id ?? \"\")?.[1] ?? null;\n}\n\nfunction pluginIdentity(value: unknown): string {\n const finding = record(value, \"Snyk plugin finding\");\n const id = record(finding[\"id\"], \"Snyk plugin identity\");\n return stableId(\"snyk-plugin\", [\n requiredText(id[\"kind\"], \"Identity kind\"),\n requiredText(id[\"value\"], \"Finding identity\"),\n ]);\n}\n\n/** Import the official Snyk Codex plugin's documented local SCA bundle. */\nexport function normalizeSnykFindingsExport(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const document = record(input, \"Snyk plugin export\");\n if (\n document[\"format\"] !== \"snyk-findings-export/v1\" ||\n document[\"provider\"] !== \"snyk\"\n )\n throw new Error(\"Expected a snyk-findings-export/v1 bundle from Snyk.\");\n const collection = record(document[\"collection\"], \"Snyk collection\");\n const sourceTarget = record(collection[\"target\"], \"Snyk target\");\n const { findings: _findings, ...context } = document;\n return normalizeRecords(\n array(document[\"findings\"], \"Snyk findings\"),\n (value, sourceFindingId) => {\n const finding = record(value, \"Snyk plugin finding\");\n const observation = record(finding[\"observation\"], \"Snyk observation\");\n if (\n finding[\"originatingScanner\"] !== \"snyk-open-source\" ||\n finding[\"category\"] !== \"dependency_vulnerability\" ||\n observation[\"scan\"] !== \"sca\"\n )\n throw new Error(\n \"Only Snyk Open Source SCA vulnerability findings are supported from plugin bundles.\",\n );\n record(finding[\"nativeRecord\"], \"Snyk native MCP record\");\n const asset = record(finding[\"asset\"], \"Snyk asset\");\n const pkg = record(asset[\"package\"], \"Snyk package\");\n const rule = record(finding[\"rule\"], \"Snyk rule\");\n const aliases = record(rule[\"aliases\"] ?? {}, \"Snyk rule aliases\");\n const remediation = record(\n finding[\"remediation\"] ?? {},\n \"Snyk remediation\",\n );\n const severity = text(\n record(finding[\"severity\"], \"Snyk severity\")[\"value\"],\n )?.toLowerCase();\n const revision = text(sourceTarget[\"revision\"]);\n return {\n source_finding_id: sourceFindingId,\n evidence: validateExternalEvidence(\n {\n title: requiredText(finding[\"title\"], \"Snyk title\"),\n description: text(\n record(finding[\"description\"] ?? {}, \"Snyk description\")[\"text\"],\n ),\n severity: [\"critical\", \"high\", \"medium\", \"low\"].includes(\n severity ?? \"\",\n )\n ? severity\n : \"unknown\",\n advisory_ids: [\n ...new Set([\n requiredText(rule[\"id\"], \"Snyk advisory ID\"),\n ...strings(aliases[\"cve\"]),\n ]),\n ],\n packages: [\n {\n name: requiredText(pkg[\"name\"], \"Snyk package name\"),\n ecosystem: text(pkg[\"ecosystem\"]),\n installed_version: text(pkg[\"version\"]),\n // Plugin v1 manifests are target-relative, without a Git-root offset.\n manifest_path: null,\n fixed_versions: strings(remediation[\"fixedIn\"]),\n },\n ],\n locations: [],\n code_revision:\n sourceTarget[\"workingTreeDirty\"] === false &&\n revision !== \"unknown\"\n ? revision\n : null,\n source_data: structuredClone({ ...context, finding }),\n },\n target,\n ),\n };\n },\n pluginIdentity,\n target,\n );\n}\n\nfunction normalizeGitRepositoryUrl(\n repository: string,\n cloudRepositoryUrl?: string,\n): string {\n // Cloud's selected catalog repository supplies connected GitHub host context;\n // imported evidence alone cannot establish an Enterprise host's SSH aliases.\n const destination = cloudRepositoryUrl\n ? new URL(cloudRepositoryUrl)\n : undefined;\n const connectedHost =\n destination?.protocol === \"https:\"\n ? destination.hostname.toLowerCase()\n : undefined;\n const connectedTenant = /^([^.]+)\\.ghe\\.com$/u.exec(connectedHost ?? \"\")?.[1];\n const isGitHubSshUser = (username: string, hostname: string) =>\n (username === \"git\" &&\n (hostname === \"github.com\" || hostname === connectedHost)) ||\n (username === connectedTenant && hostname === connectedHost);\n const scp = /^([^@/:]+)@([^/:]+):(.+)$/u.exec(repository);\n if (scp && isGitHubSshUser(scp[1]!, scp[2]!.toLowerCase()))\n return `https://${scp[2]}/${scp[3]}`;\n // Compare Git's literal SSH userinfo before URL strips tabs or newlines.\n const ssh = /^ssh:\\/\\/([^/]+)@/u.exec(repository);\n if (ssh) {\n // Git retains these bytes, but URL parsing would erase them from the alias.\n if (/[\\t\\r\\n]/u.test(repository)) return repository;\n const url = new URL(repository);\n const hostname = url.hostname.toLowerCase();\n const githubSsh =\n isGitHubSshUser(ssh[1]!, hostname) &&\n (url.port === \"\" || url.port === \"22\");\n const githubSshOverHttps =\n ssh[1] === \"git\" && hostname === \"ssh.github.com\" && url.port === \"443\";\n if (githubSshOverHttps) return `https://github.com${url.pathname}`;\n if (githubSsh) return `https://${hostname}${url.pathname}`;\n }\n return repository;\n}\n\n/** @internal Repository claims retained in original Snyk evidence. */\nexport function snykRepositoryUrls(\n sourceData: unknown,\n {\n normalizeGitRemote = true,\n cloudRepositoryUrl,\n }: {\n normalizeGitRemote?: boolean;\n /** The selected destination from the authenticated Cloud repository catalog. */\n cloudRepositoryUrl?: string;\n } = {},\n): string[] {\n if (\n !sourceData ||\n typeof sourceData !== \"object\" ||\n Array.isArray(sourceData)\n )\n return [];\n const source = sourceData as Record<string, unknown>;\n if (source[\"format\"] === \"snyk-findings-export/v1\") {\n const collection = record(source[\"collection\"], \"Snyk collection\");\n const target = record(collection[\"target\"], \"Snyk target\");\n const repository = text(target[\"repository\"]);\n if (repository === null || repository === \"unknown\") return [];\n return [\n normalizeGitRemote\n ? normalizeGitRepositoryUrl(repository, cloudRepositoryUrl)\n : repository,\n ];\n }\n // Generic normalized evidence may use these field names for opaque metadata.\n const document = source[\"document\"];\n const driver = source[\"driver\"];\n if (\n !isRecord(document) ||\n document[\"version\"] !== \"2.1.0\" ||\n !isRecord(driver) ||\n driver[\"name\"] !== \"Snyk Open Source\"\n )\n return [];\n const run = source[\"run\"];\n if (run == null) return [];\n return array(\n record(run, \"Snyk run context\")[\"versionControlProvenance\"] ?? [],\n \"Snyk version control provenance\",\n ).map((entry) => {\n const repository = requiredText(\n record(entry, \"Snyk repository provenance\")[\"repositoryUri\"],\n \"Snyk repository URI\",\n );\n return normalizeGitRemote\n ? normalizeGitRepositoryUrl(repository, cloudRepositoryUrl)\n : repository;\n });\n}\n\n/** Snyk Open Source's formatter groups all dependency paths for an advisory in a project. */\nexport function normalizeSnykSarif(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const document = record(input, \"Snyk SARIF\");\n if (document[\"version\"] !== \"2.1.0\")\n throw new Error(\"Expected Snyk Open Source SARIF 2.1.0.\");\n const entries = array(document[\"runs\"], \"SARIF runs\").flatMap((value) => {\n const run = record(value, \"SARIF run\");\n const driver = record(\n record(run[\"tool\"], \"SARIF tool\")[\"driver\"],\n \"SARIF driver\",\n );\n if (driver[\"name\"] !== \"Snyk Open Source\")\n throw new Error(\n \"Only Snyk Open Source SARIF is supported; Code, Container, and IaC need separate mappings.\",\n );\n if (\n hasSarifExternalPropertyReferences(run[\"externalPropertyFileReferences\"])\n )\n throw new Error(\n \"External SARIF property files are unsupported; use a self-contained report.\",\n );\n const rules = array(driver[\"rules\"], \"SARIF rules\").map((rule) =>\n record(rule, \"SARIF rule\"),\n );\n const rulesById = new Map<\n unknown,\n { rule: Record<string, unknown>; index: number } | null\n >();\n rules.forEach((rule, index) => {\n const id = rule[\"id\"];\n rulesById.set(id, rulesById.has(id) ? null : { rule, index });\n });\n const project = snykSarifProject(run);\n const { results: _results, tool: _tool, ...runContext } = run;\n const { rules: _rules, ...driverContext } = driver;\n const { driver: _driver, ...toolContext } = record(\n run[\"tool\"],\n \"SARIF tool\",\n );\n runContext[\"tool\"] = toolContext;\n const { runs: _runs, ...documentContext } = document;\n return array(run[\"results\"], \"SARIF results\").map((result) => ({\n result,\n rulesById,\n project,\n runContext,\n driverContext,\n documentContext,\n }));\n });\n return normalizeRecords(\n entries,\n (\n { result: value, rulesById, runContext, driverContext, documentContext },\n sourceFindingId,\n ) => {\n const result = record(value, \"SARIF result\");\n const id = requiredText(result[\"ruleId\"], \"Snyk advisory ruleId\");\n const match = rulesById.get(id);\n if (!match)\n throw new Error(\"Result must reference exactly one rule in its run.\");\n const { rule, index } = match;\n if (result[\"ruleIndex\"] !== undefined && result[\"ruleIndex\"] !== index)\n throw new Error(\"Result ruleIndex and ruleId disagree.\");\n if (result[\"rule\"] !== undefined) {\n const ref = record(result[\"rule\"], \"Rule reference\");\n if (\n ref[\"toolComponent\"] !== undefined ||\n (ref[\"id\"] !== undefined && ref[\"id\"] !== id) ||\n (ref[\"index\"] !== undefined && ref[\"index\"] !== index) ||\n (ref[\"guid\"] !== undefined && ref[\"guid\"] !== rule[\"guid\"])\n )\n throw new Error(\n \"Result uses an inconsistent or external rule reference.\",\n );\n }\n const help = requiredText(\n record(rule[\"help\"], \"Rule help\")[\"markdown\"],\n \"Rule help markdown\",\n );\n const manager = /^\\* Package Manager: (.+)$/mu.exec(help)?.[1] ?? null;\n if (!manager || !/^\\* Vulnerable module: .+$/mu.test(help))\n throw new Error(\n \"Expected the Snyk Open Source vulnerability profile; license findings are unsupported.\",\n );\n const title = requiredText(\n record(rule[\"shortDescription\"], \"Rule shortDescription\")[\"text\"],\n \"Rule title\",\n );\n const severity =\n /^(Critical|High|Medium|Low) severity - /u\n .exec(title)?.[1]\n ?.toLowerCase() ?? \"unknown\";\n const message = requiredText(\n record(result[\"message\"], \"Result message\")[\"text\"],\n \"Result message text\",\n );\n const locations = array(\n result[\"locations\"] ?? [],\n \"Result locations\",\n ).map((v) => record(v, \"Location\"));\n const packages: {\n name: string;\n ecosystem: string;\n installed_version: string | null;\n manifest_path: string | null;\n fixed_versions: string[];\n }[] = [];\n for (const location of locations) {\n for (const logical of array(\n location[\"logicalLocations\"] ?? [],\n \"Logical locations\",\n )) {\n const coordinate = text(\n record(logical, \"Logical location\")[\"fullyQualifiedName\"],\n );\n if (!coordinate) continue;\n const split = coordinate.lastIndexOf(\"@\");\n if (split <= 0) continue;\n packages.push({\n name: coordinate.slice(0, split),\n ecosystem: manager,\n installed_version: coordinate.slice(split + 1) || null,\n manifest_path: null,\n fixed_versions: [],\n });\n }\n }\n const description = [message, help].join(\"\\n\\n\");\n // Use the project, advisory group, and literal manifest set within the caller's namespace.\n return {\n source_finding_id: sourceFindingId,\n evidence: validateExternalEvidence(\n {\n title,\n description,\n severity,\n advisory_ids: [\n ...new Set([\n id,\n ...(text(\n record(rule[\"fullDescription\"] ?? {}, \"Full description\")[\n \"text\"\n ],\n )?.match(/\\bCVE-\\d{4}-\\d+\\b/gu) ?? []),\n ]),\n ],\n packages,\n // Snyk emits target-relative paths without a Git-root offset and may\n // synthesize startLine=1. Keep both only in the original evidence.\n locations: [],\n source_data: structuredClone({\n document: documentContext,\n run: sarifRunContextForResult(\n runContext,\n result,\n rule,\n driverContext,\n documentContext,\n ),\n driver: driverContext,\n rule,\n result,\n }),\n },\n target,\n ),\n };\n },\n ({ result, project }) => snykIdentity(result, project),\n target,\n );\n}\n\n/** Import native `snyk test --json` Open Source vulnerability occurrences. */\nexport function normalizeSnykJson(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const projects = Array.isArray(input) ? input : [input];\n const entries = projects.flatMap((value) => {\n const project = record(value, \"Snyk Open Source project\");\n if (project[\"error\"])\n throw new Error(`Snyk scan failed: ${String(project[\"error\"])}`);\n if (project[\"docker\"] || project[\"applications\"])\n throw new Error(\n \"Snyk Container JSON is unsupported; use Open Source SCA results.\",\n );\n if (typeof project[\"ok\"] !== \"boolean\")\n throw new Error(\"Expected a completed Snyk Open Source test result.\");\n const manager = requiredText(\n project[\"packageManager\"],\n \"Snyk package manager\",\n );\n const manifest =\n text(project[\"displayTargetFile\"]) ?? text(project[\"targetFile\"]);\n const { vulnerabilities, ...context } = project;\n return array(vulnerabilities, \"Snyk vulnerabilities\").map((value) => ({\n value,\n context,\n manager,\n manifest,\n }));\n });\n return normalizeRecords(\n entries,\n ({ value, context, manager }, sourceFindingId) => {\n const vulnerability = record(value, \"Snyk vulnerability\");\n if (vulnerability[\"type\"] === \"license\")\n throw new Error(\n \"Snyk license findings are unsupported; only Open Source SCA vulnerabilities are imported.\",\n );\n const identifiers = record(\n vulnerability[\"identifiers\"] ?? {},\n \"Snyk identifiers\",\n );\n const severity = text(vulnerability[\"severity\"])?.toLowerCase();\n return {\n source_finding_id: sourceFindingId,\n evidence: validateExternalEvidence(\n {\n title: requiredText(\n vulnerability[\"title\"],\n \"Snyk vulnerability title\",\n ),\n description: text(vulnerability[\"description\"]),\n severity: [\"critical\", \"high\", \"medium\", \"low\"].includes(\n severity ?? \"\",\n )\n ? severity\n : \"unknown\",\n advisory_ids: [\n ...new Set([\n requiredText(vulnerability[\"id\"], \"Snyk advisory ID\"),\n ...strings(identifiers[\"CVE\"]),\n ]),\n ],\n packages: [\n {\n name: requiredText(\n vulnerability[\"name\"] ?? vulnerability[\"packageName\"],\n \"Snyk package name\",\n ),\n ecosystem: manager,\n installed_version: text(vulnerability[\"version\"]),\n // Native test paths are scan-target-relative, without a Git-root offset.\n manifest_path: null,\n fixed_versions: strings(vulnerability[\"fixedIn\"]),\n },\n ],\n locations: [],\n source_data: structuredClone({ project: context, vulnerability }),\n },\n target,\n ),\n };\n },\n ({ value, manager, manifest }) => {\n const vulnerability = record(value, \"Snyk vulnerability\");\n return stableId(\"snyk-json\", [\n manager,\n manifest,\n requiredText(vulnerability[\"id\"], \"Snyk advisory ID\"),\n requiredText(\n vulnerability[\"name\"] ?? vulnerability[\"packageName\"],\n \"Snyk package name\",\n ),\n text(vulnerability[\"version\"]),\n array(vulnerability[\"from\"] ?? [], \"Snyk dependency path\").map((item) =>\n requiredText(item, \"Snyk dependency\"),\n ),\n ]);\n },\n target,\n );\n}\n\nexport async function readSnykFindings(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<ExternalFindings> {\n const input = await readScannerJson(path);\n if (Array.isArray(input)) return normalizeSnykJson(input, target);\n const document = record(input, \"Snyk findings\");\n if (document[\"format\"] === \"snyk-findings-export/v1\")\n return normalizeSnykFindingsExport(document, target);\n if (document[\"version\"] === \"2.1.0\")\n return normalizeSnykSarif(document, target);\n return normalizeSnykJson(document, target);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"snyk-findings.js","sourceRoot":"","sources":["../src/snyk-findings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EACL,KAAK,EACL,kCAAkC,EAClC,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,YAAY,EACZ,wBAAwB,EACxB,Q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,CACtE,YAAY,CAAC,IAAI,EAAE,iBAAiB,CAAC,CACtC;SACF,CAAC,CAAC;IACL,CAAC,EACD,MAAM,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,IAAY,EACZ,MAAM,GAAyB,OAAO;IAEtC,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,iBAAiB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;IAChD,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,yBAAyB;QAClD,OAAO,2BAA2B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACvD,IAAI,QAAQ,CAAC,SAAS,CAAC,KAAK,OAAO;QACjC,OAAO,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC9C,OAAO,iBAAiB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { ExternalImportTarget } from \"./external-import-contract.js\";\nimport { validateExternalEvidence } from \"./external-import-contract.js\";\nimport type { ExternalFindings } from \"./external-findings.js\";\nimport { isRecord } from \"./record.js\";\nimport {\n array,\n hasSarifExternalPropertyReferences,\n normalizeRecords,\n readScannerJson,\n record,\n requiredText,\n sarifRunContextForResult,\n stableId,\n strings,\n text,\n} from \"./scanner-import.js\";\n\nfunction snykIdentity(value: unknown, project: string | null): string {\n const result = record(value, \"SARIF result\");\n const id = requiredText(result[\"ruleId\"], \"Snyk advisory ruleId\");\n const paths = array(result[\"locations\"] ?? [], \"Result locations\")\n .map((value) => {\n const physical = record(\n record(value, \"Location\")[\"physicalLocation\"] ?? {},\n \"Physical location\",\n );\n const artifact = record(\n physical[\"artifactLocation\"] ?? {},\n \"Artifact location\",\n );\n if (\n artifact[\"index\"] !== undefined ||\n artifact[\"uriBaseId\"] !== undefined\n )\n throw new Error(\n \"Snyk SARIF artifact references are unsupported; use direct manifest URIs from the Snyk Open Source formatter.\",\n );\n return text(artifact[\"uri\"]);\n })\n .filter((path): path is string => path !== null);\n const fields: unknown[] = [id, [...new Set(paths)].sort()];\n if (project !== null) fields.push(project);\n return stableId(\"snyk-sarif\", fields);\n}\n\nfunction snykSarifProject(run: Record<string, unknown>): string | null {\n const details = run[\"automationDetails\"];\n const id = isRecord(details) ? text(details[\"id\"]) : null;\n // The formatter appends a run index and export timestamp after the project name.\n return /^Snyk\\/Open Source\\/(.+)\\/\\d+\\/[^/]+$/su.exec(id ?? \"\")?.[1] ?? null;\n}\n\nfunction pluginIdentity(value: unknown): string {\n const finding = record(value, \"Snyk plugin finding\");\n const id = record(finding[\"id\"], \"Snyk plugin identity\");\n return stableId(\"snyk-plugin\", [\n requiredText(id[\"kind\"], \"Identity kind\"),\n requiredText(id[\"value\"], \"Finding identity\"),\n ]);\n}\n\n/** Import the official Snyk Codex plugin's documented local SCA bundle. */\nexport function normalizeSnykFindingsExport(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const document = record(input, \"Snyk plugin export\");\n if (\n document[\"format\"] !== \"snyk-findings-export/v1\" ||\n document[\"provider\"] !== \"snyk\"\n )\n throw new Error(\"Expected a snyk-findings-export/v1 bundle from Snyk.\");\n const collection = record(document[\"collection\"], \"Snyk collection\");\n const sourceTarget = record(collection[\"target\"], \"Snyk target\");\n const { findings: _findings, ...context } = document;\n return normalizeRecords(\n array(document[\"findings\"], \"Snyk findings\"),\n (value) => {\n const finding = record(value, \"Snyk plugin finding\");\n const observation = record(finding[\"observation\"], \"Snyk observation\");\n if (\n finding[\"originatingScanner\"] !== \"snyk-open-source\" ||\n finding[\"category\"] !== \"dependency_vulnerability\" ||\n observation[\"scan\"] !== \"sca\"\n )\n throw new Error(\n \"Only Snyk Open Source SCA vulnerability findings are supported from plugin bundles.\",\n );\n record(finding[\"nativeRecord\"], \"Snyk native MCP record\");\n const asset = record(finding[\"asset\"], \"Snyk asset\");\n const pkg = record(asset[\"package\"], \"Snyk package\");\n const rule = record(finding[\"rule\"], \"Snyk rule\");\n const aliases = record(rule[\"aliases\"] ?? {}, \"Snyk rule aliases\");\n const remediation = record(\n finding[\"remediation\"] ?? {},\n \"Snyk remediation\",\n );\n const severity = text(\n record(finding[\"severity\"], \"Snyk severity\")[\"value\"],\n )?.toLowerCase();\n const revision = text(sourceTarget[\"revision\"]);\n return validateExternalEvidence(\n {\n title: requiredText(finding[\"title\"], \"Snyk title\"),\n description: text(\n record(finding[\"description\"] ?? {}, \"Snyk description\")[\"text\"],\n ),\n severity: [\"critical\", \"high\", \"medium\", \"low\"].includes(\n severity ?? \"\",\n )\n ? severity\n : \"unknown\",\n advisory_ids: [\n ...new Set([\n requiredText(rule[\"id\"], \"Snyk advisory ID\"),\n ...strings(aliases[\"cve\"]),\n ]),\n ],\n packages: [\n {\n name: requiredText(pkg[\"name\"], \"Snyk package name\"),\n ecosystem: text(pkg[\"ecosystem\"]),\n installed_version: text(pkg[\"version\"]),\n // Plugin v1 manifests are target-relative, without a Git-root offset.\n manifest_path: null,\n fixed_versions: strings(remediation[\"fixedIn\"]),\n },\n ],\n locations: [],\n code_revision:\n sourceTarget[\"workingTreeDirty\"] === false && revision !== \"unknown\"\n ? revision\n : null,\n source_data: structuredClone({ ...context, finding }),\n },\n target,\n );\n },\n pluginIdentity,\n target,\n );\n}\n\nfunction normalizeGitRepositoryUrl(\n repository: string,\n cloudRepositoryUrl?: string,\n): string {\n // Cloud's selected catalog repository supplies connected GitHub host context;\n // imported evidence alone cannot establish an Enterprise host's SSH aliases.\n const destination = cloudRepositoryUrl\n ? new URL(cloudRepositoryUrl)\n : undefined;\n const connectedHost =\n destination?.protocol === \"https:\"\n ? destination.hostname.toLowerCase()\n : undefined;\n const connectedTenant = /^([^.]+)\\.ghe\\.com$/u.exec(connectedHost ?? \"\")?.[1];\n const isGitHubSshUser = (username: string, hostname: string) =>\n (username === \"git\" &&\n (hostname === \"github.com\" || hostname === connectedHost)) ||\n (username === connectedTenant && hostname === connectedHost);\n const scp = /^([^@/:]+)@([^/:]+):(.+)$/u.exec(repository);\n if (scp && isGitHubSshUser(scp[1]!, scp[2]!.toLowerCase()))\n return `https://${scp[2]}/${scp[3]}`;\n // Compare Git's literal SSH userinfo before URL strips tabs or newlines.\n const ssh = /^ssh:\\/\\/([^/]+)@/u.exec(repository);\n if (ssh) {\n // Git retains these bytes, but URL parsing would erase them from the alias.\n if (/[\\t\\r\\n]/u.test(repository)) return repository;\n const url = new URL(repository);\n const hostname = url.hostname.toLowerCase();\n const githubSsh =\n isGitHubSshUser(ssh[1]!, hostname) &&\n (url.port === \"\" || url.port === \"22\");\n const githubSshOverHttps =\n ssh[1] === \"git\" && hostname === \"ssh.github.com\" && url.port === \"443\";\n if (githubSshOverHttps) return `https://github.com${url.pathname}`;\n if (githubSsh) return `https://${hostname}${url.pathname}`;\n }\n return repository;\n}\n\n/** @internal Repository claims retained in original Snyk evidence. */\nexport function snykRepositoryUrls(\n sourceData: unknown,\n {\n normalizeGitRemote = true,\n cloudRepositoryUrl,\n }: {\n normalizeGitRemote?: boolean;\n /** The selected destination from the authenticated Cloud repository catalog. */\n cloudRepositoryUrl?: string;\n } = {},\n): string[] {\n if (\n !sourceData ||\n typeof sourceData !== \"object\" ||\n Array.isArray(sourceData)\n )\n return [];\n const source = sourceData as Record<string, unknown>;\n if (source[\"format\"] === \"snyk-findings-export/v1\") {\n const collection = record(source[\"collection\"], \"Snyk collection\");\n const target = record(collection[\"target\"], \"Snyk target\");\n const repository = text(target[\"repository\"]);\n if (repository === null || repository === \"unknown\") return [];\n return [\n normalizeGitRemote\n ? normalizeGitRepositoryUrl(repository, cloudRepositoryUrl)\n : repository,\n ];\n }\n // Generic normalized evidence may use these field names for opaque metadata.\n const document = source[\"document\"];\n const driver = source[\"driver\"];\n if (\n !isRecord(document) ||\n document[\"version\"] !== \"2.1.0\" ||\n !isRecord(driver) ||\n driver[\"name\"] !== \"Snyk Open Source\"\n )\n return [];\n const run = source[\"run\"];\n if (run == null) return [];\n return array(\n record(run, \"Snyk run context\")[\"versionControlProvenance\"] ?? [],\n \"Snyk version control provenance\",\n ).map((entry) => {\n const repository = requiredText(\n record(entry, \"Snyk repository provenance\")[\"repositoryUri\"],\n \"Snyk repository URI\",\n );\n return normalizeGitRemote\n ? normalizeGitRepositoryUrl(repository, cloudRepositoryUrl)\n : repository;\n });\n}\n\n/** Snyk Open Source's formatter groups all dependency paths for an advisory in a project. */\nexport function normalizeSnykSarif(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const document = record(input, \"Snyk SARIF\");\n if (document[\"version\"] !== \"2.1.0\")\n throw new Error(\"Expected Snyk Open Source SARIF 2.1.0.\");\n const entries = array(document[\"runs\"], \"SARIF runs\").flatMap((value) => {\n const run = record(value, \"SARIF run\");\n const driver = record(\n record(run[\"tool\"], \"SARIF tool\")[\"driver\"],\n \"SARIF driver\",\n );\n if (driver[\"name\"] !== \"Snyk Open Source\")\n throw new Error(\n \"Only Snyk Open Source SARIF is supported; Code, Container, and IaC need separate mappings.\",\n );\n if (\n hasSarifExternalPropertyReferences(run[\"externalPropertyFileReferences\"])\n )\n throw new Error(\n \"External SARIF property files are unsupported; use a self-contained report.\",\n );\n const rules = array(driver[\"rules\"], \"SARIF rules\").map((rule) =>\n record(rule, \"SARIF rule\"),\n );\n const rulesById = new Map<\n unknown,\n { rule: Record<string, unknown>; index: number } | null\n >();\n rules.forEach((rule, index) => {\n const id = rule[\"id\"];\n rulesById.set(id, rulesById.has(id) ? null : { rule, index });\n });\n const project = snykSarifProject(run);\n const { results: _results, tool: _tool, ...runContext } = run;\n const { rules: _rules, ...driverContext } = driver;\n const { driver: _driver, ...toolContext } = record(\n run[\"tool\"],\n \"SARIF tool\",\n );\n runContext[\"tool\"] = toolContext;\n const { runs: _runs, ...documentContext } = document;\n return array(run[\"results\"], \"SARIF results\").map((result) => ({\n result,\n rulesById,\n project,\n runContext,\n driverContext,\n documentContext,\n }));\n });\n return normalizeRecords(\n entries,\n ({\n result: value,\n rulesById,\n runContext,\n driverContext,\n documentContext,\n }) => {\n const result = record(value, \"SARIF result\");\n const id = requiredText(result[\"ruleId\"], \"Snyk advisory ruleId\");\n const match = rulesById.get(id);\n if (!match)\n throw new Error(\"Result must reference exactly one rule in its run.\");\n const { rule, index } = match;\n if (result[\"ruleIndex\"] !== undefined && result[\"ruleIndex\"] !== index)\n throw new Error(\"Result ruleIndex and ruleId disagree.\");\n if (result[\"rule\"] !== undefined) {\n const ref = record(result[\"rule\"], \"Rule reference\");\n if (\n ref[\"toolComponent\"] !== undefined ||\n (ref[\"id\"] !== undefined && ref[\"id\"] !== id) ||\n (ref[\"index\"] !== undefined && ref[\"index\"] !== index) ||\n (ref[\"guid\"] !== undefined && ref[\"guid\"] !== rule[\"guid\"])\n )\n throw new Error(\n \"Result uses an inconsistent or external rule reference.\",\n );\n }\n const help = requiredText(\n record(rule[\"help\"], \"Rule help\")[\"markdown\"],\n \"Rule help markdown\",\n );\n const manager = /^\\* Package Manager: (.+)$/mu.exec(help)?.[1] ?? null;\n if (!manager || !/^\\* Vulnerable module: .+$/mu.test(help))\n throw new Error(\n \"Expected the Snyk Open Source vulnerability profile; license findings are unsupported.\",\n );\n const title = requiredText(\n record(rule[\"shortDescription\"], \"Rule shortDescription\")[\"text\"],\n \"Rule title\",\n );\n const severity =\n /^(Critical|High|Medium|Low) severity - /u\n .exec(title)?.[1]\n ?.toLowerCase() ?? \"unknown\";\n const message = requiredText(\n record(result[\"message\"], \"Result message\")[\"text\"],\n \"Result message text\",\n );\n const locations = array(\n result[\"locations\"] ?? [],\n \"Result locations\",\n ).map((v) => record(v, \"Location\"));\n const packages: {\n name: string;\n ecosystem: string;\n installed_version: string | null;\n manifest_path: string | null;\n fixed_versions: string[];\n }[] = [];\n for (const location of locations) {\n for (const logical of array(\n location[\"logicalLocations\"] ?? [],\n \"Logical locations\",\n )) {\n const coordinate = text(\n record(logical, \"Logical location\")[\"fullyQualifiedName\"],\n );\n if (!coordinate) continue;\n const split = coordinate.lastIndexOf(\"@\");\n if (split <= 0) continue;\n packages.push({\n name: coordinate.slice(0, split),\n ecosystem: manager,\n installed_version: coordinate.slice(split + 1) || null,\n manifest_path: null,\n fixed_versions: [],\n });\n }\n }\n const description = [message, help].join(\"\\n\\n\");\n // Use the project, advisory group, and literal manifest set within the caller's namespace.\n return validateExternalEvidence(\n {\n title,\n description,\n severity,\n advisory_ids: [\n ...new Set([\n id,\n ...(text(\n record(rule[\"fullDescription\"] ?? {}, \"Full description\")[\n \"text\"\n ],\n )?.match(/\\bCVE-\\d{4}-\\d+\\b/gu) ?? []),\n ]),\n ],\n packages,\n // Snyk emits target-relative paths without a Git-root offset and may\n // synthesize startLine=1. Keep both only in the original evidence.\n locations: [],\n source_data: structuredClone({\n document: documentContext,\n run: sarifRunContextForResult(\n runContext,\n result,\n rule,\n driverContext,\n documentContext,\n ),\n driver: driverContext,\n rule,\n result,\n }),\n },\n target,\n );\n },\n ({ result, project }) => snykIdentity(result, project),\n target,\n );\n}\n\n/** Import native `snyk test --json` Open Source vulnerability occurrences. */\nexport function normalizeSnykJson(\n input: unknown,\n target: ExternalImportTarget = \"cloud\",\n): ExternalFindings {\n const projects = Array.isArray(input) ? input : [input];\n const entries = projects.flatMap((value) => {\n const project = record(value, \"Snyk Open Source project\");\n if (project[\"error\"])\n throw new Error(`Snyk scan failed: ${String(project[\"error\"])}`);\n if (project[\"docker\"] || project[\"applications\"])\n throw new Error(\n \"Snyk Container JSON is unsupported; use Open Source SCA results.\",\n );\n if (typeof project[\"ok\"] !== \"boolean\")\n throw new Error(\"Expected a completed Snyk Open Source test result.\");\n const manager = requiredText(\n project[\"packageManager\"],\n \"Snyk package manager\",\n );\n const manifest =\n text(project[\"displayTargetFile\"]) ?? text(project[\"targetFile\"]);\n const { vulnerabilities, ...context } = project;\n return array(vulnerabilities, \"Snyk vulnerabilities\").map((value) => ({\n value,\n context,\n manager,\n manifest,\n }));\n });\n return normalizeRecords(\n entries,\n ({ value, context, manager }) => {\n const vulnerability = record(value, \"Snyk vulnerability\");\n if (vulnerability[\"type\"] === \"license\")\n throw new Error(\n \"Snyk license findings are unsupported; only Open Source SCA vulnerabilities are imported.\",\n );\n const identifiers = record(\n vulnerability[\"identifiers\"] ?? {},\n \"Snyk identifiers\",\n );\n const severity = text(vulnerability[\"severity\"])?.toLowerCase();\n return validateExternalEvidence(\n {\n title: requiredText(\n vulnerability[\"title\"],\n \"Snyk vulnerability title\",\n ),\n description: text(vulnerability[\"description\"]),\n severity: [\"critical\", \"high\", \"medium\", \"low\"].includes(\n severity ?? \"\",\n )\n ? severity\n : \"unknown\",\n advisory_ids: [\n ...new Set([\n requiredText(vulnerability[\"id\"], \"Snyk advisory ID\"),\n ...strings(identifiers[\"CVE\"]),\n ]),\n ],\n packages: [\n {\n name: requiredText(\n vulnerability[\"name\"] ?? vulnerability[\"packageName\"],\n \"Snyk package name\",\n ),\n ecosystem: manager,\n installed_version: text(vulnerability[\"version\"]),\n // Native test paths are scan-target-relative, without a Git-root offset.\n manifest_path: null,\n fixed_versions: strings(vulnerability[\"fixedIn\"]),\n },\n ],\n locations: [],\n source_data: structuredClone({ project: context, vulnerability }),\n },\n target,\n );\n },\n ({ value, manager, manifest }) => {\n const vulnerability = record(value, \"Snyk vulnerability\");\n return stableId(\"snyk-json\", [\n manager,\n manifest,\n requiredText(vulnerability[\"id\"], \"Snyk advisory ID\"),\n requiredText(\n vulnerability[\"name\"] ?? vulnerability[\"packageName\"],\n \"Snyk package name\",\n ),\n text(vulnerability[\"version\"]),\n array(vulnerability[\"from\"] ?? [], \"Snyk dependency path\").map((item) =>\n requiredText(item, \"Snyk dependency\"),\n ),\n ]);\n },\n target,\n );\n}\n\nexport async function readSnykFindings(\n path: string,\n target: ExternalImportTarget = \"cloud\",\n): Promise<ExternalFindings> {\n const input = await readScannerJson(path);\n if (Array.isArray(input)) return normalizeSnykJson(input, target);\n const document = record(input, \"Snyk findings\");\n if (document[\"format\"] === \"snyk-findings-export/v1\")\n return normalizeSnykFindingsExport(document, target);\n if (document[\"version\"] === \"2.1.0\")\n return normalizeSnykSarif(document, target);\n return normalizeSnykJson(document, target);\n}\n"]}
|
package/docs/cli.md
CHANGED
|
@@ -460,8 +460,9 @@ explicit unsupported binary files are rejected. Bulk scans share this context
|
|
|
460
460
|
with every repository.
|
|
461
461
|
|
|
462
462
|
Use `--output-dir DIR` to choose where a scan saves its results. The directory
|
|
463
|
-
must be empty and outside the scanned directory and enclosing Git worktree.
|
|
464
|
-
|
|
463
|
+
must be empty and outside the scanned directory and enclosing Git worktree.
|
|
464
|
+
Existing directories keep their permissions; newly created directories are
|
|
465
|
+
private to you by default.
|
|
465
466
|
`--archive-existing` moves earlier output to
|
|
466
467
|
`<output-dir>.previous-<timestamp>-<id>`; `--dry-run` previews the move.
|
|
467
468
|
|
|
@@ -1006,8 +1007,9 @@ directory.
|
|
|
1006
1007
|
|
|
1007
1008
|
### Progress and cost
|
|
1008
1009
|
|
|
1009
|
-
Interactive scans show full-screen progress.
|
|
1010
|
-
|
|
1010
|
+
Interactive scans show full-screen progress. The dashboard title uses the resolved
|
|
1011
|
+
directory name, so `scan .` shows the current directory's name. CI, redirected output,
|
|
1012
|
+
`--headless`, and `--verbose` use plain status lines. Results go to stdout; progress and
|
|
1011
1013
|
diagnostics go to stderr. Press `d` in the dashboard for details, then `a` for
|
|
1012
1014
|
all sources, `m` for the main scan, or `1`–`9` for a worker.
|
|
1013
1015
|
|
|
@@ -1304,9 +1306,11 @@ Use the same vendor input and parser as Cloud publication, selecting a local
|
|
|
1304
1306
|
repository path instead of a Cloud repository ID or URL. Supported inputs include
|
|
1305
1307
|
Wiz findings, [Snyk Open Source JSON and SARIF](#import-snyk-open-source-findings),
|
|
1306
1308
|
[Endor Labs Finding JSON and SARIF](#import-endor-labs-findings),
|
|
1309
|
+
[Amazon Inspector repository findings](https://github.com/openai/codex-security/blob/main/docs/scanner-imports/inspector.md),
|
|
1307
1310
|
[Semgrep Code JSON and SARIF](https://github.com/openai/codex-security/blob/main/docs/scanner-imports/semgrep.md),
|
|
1308
1311
|
[OpenGrep native JSON](https://github.com/openai/codex-security/blob/main/docs/scanner-imports/opengrep.md),
|
|
1309
|
-
|
|
1312
|
+
[GitHub Dependabot repository alerts](https://github.com/openai/codex-security/blob/main/docs/scanner-imports/github-dependabot.md),
|
|
1313
|
+
and [saved GitHub code-scanning alerts and GHSA advisories](#import-github-findings-locally-or-to-cloud):
|
|
1310
1314
|
|
|
1311
1315
|
```bash
|
|
1312
1316
|
codex-security publish findings selected-wiz.json \
|
|
@@ -2281,6 +2285,33 @@ be unchanged since the scan. `--source-root` is supported only for SARIF.
|
|
|
2281
2285
|
If export fails, it exits with `2`. Fix the reported error and rerun the export;
|
|
2282
2286
|
the saved scan remains available, so you don't need to run another scan.
|
|
2283
2287
|
|
|
2288
|
+
### Export findings for ServiceNow
|
|
2289
|
+
|
|
2290
|
+
Use `servicenow-avit` to prepare a CSV for ServiceNow Application Vulnerability
|
|
2291
|
+
Response. In ServiceNow, open **All > Manual AVIT Ingestion > Upload File UI**
|
|
2292
|
+
and download the CSV template. Keep the headers and a single row per template
|
|
2293
|
+
file. Fill in the exact ServiceNow application name, requester, assignee, and
|
|
2294
|
+
assignment group. Supply the application team, purpose, sensitive data types,
|
|
2295
|
+
compliance programs, technology stack, and URLs to test. Leave the finding
|
|
2296
|
+
columns blank and reuse this file for future exports of the same application. See the
|
|
2297
|
+
[example template](https://github.com/openai/codex-security/blob/main/examples/servicenow-avit-template.csv).
|
|
2298
|
+
|
|
2299
|
+
```bash
|
|
2300
|
+
codex-security export --scan latest --export-format servicenow-avit \
|
|
2301
|
+
--avit-template invoice-desk.csv --output findings-avit.csv
|
|
2302
|
+
```
|
|
2303
|
+
|
|
2304
|
+
The command writes one row per saved finding. It fills the risk rating and uses
|
|
2305
|
+
the first CWE when available, otherwise the Codex finding ID. Technical details
|
|
2306
|
+
include that ID, the primary file and line, the summary, and remediation. For
|
|
2307
|
+
**Steps to reproduce**, review any recorded attack-path steps and complete blank
|
|
2308
|
+
cells before uploading. Both text fields have a 1,000-character limit. An ellipsis
|
|
2309
|
+
marks shortened text. Other template columns keep their original values.
|
|
2310
|
+
|
|
2311
|
+
The output defaults to `servicenow-avit.csv`. Upload the completed file in the
|
|
2312
|
+
same ServiceNow screen. Each upload creates a new penetration-test form for the
|
|
2313
|
+
application. See [ServiceNow's upload instructions](https://www.servicenow.com/docs/r/security-management/application-vulnerability-response/ingest-vulnerabilities-manually-avr.html).
|
|
2314
|
+
|
|
2284
2315
|
### Export a threat model
|
|
2285
2316
|
|
|
2286
2317
|
To save a scan's threat model as Markdown, run:
|
|
@@ -2323,6 +2354,8 @@ console.log(exported.path, exported.provenance);
|
|
|
2323
2354
|
```
|
|
2324
2355
|
|
|
2325
2356
|
Use `artifact: "findings"` with `format: "csv" | "json" | "sarif"` for findings.
|
|
2357
|
+
For ServiceNow, use `format: "servicenow-avit"` and set `avitTemplate` to the
|
|
2358
|
+
path of the application's populated CSV template.
|
|
2326
2359
|
`output: "-"` streams stdout and returns null path/provenance. `pythonPath`
|
|
2327
2360
|
selects an interpreter; `signal` cancels.
|
|
2328
2361
|
|
|
@@ -2405,10 +2438,13 @@ Acquire code-scanning findings with the existing `import github` collector and
|
|
|
2405
2438
|
save its complete JSON output. In Codex, the official
|
|
2406
2439
|
[GitHub Codex plugin](https://github.com/openai/plugins/tree/main/plugins/github)
|
|
2407
2440
|
can help select the repository, alert numbers and ref through GitHub's MCP
|
|
2408
|
-
server
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
repository
|
|
2441
|
+
server. Pass that selection to the collector. For Dependabot, use a token with
|
|
2442
|
+
**Dependabot alerts: read** and follow
|
|
2443
|
+
the [repository alert export guide](https://github.com/openai/codex-security/blob/main/docs/scanner-imports/github-dependabot.md)
|
|
2444
|
+
to save the native REST records from one repository and preview them with
|
|
2445
|
+
`--provider github`. For GHSA disclosures, use the
|
|
2446
|
+
[advisory collector](#import-ghsa-advisories-separately).
|
|
2447
|
+
The following example previews local storage of a code-scanning export.
|
|
2412
2448
|
|
|
2413
2449
|
```bash
|
|
2414
2450
|
codex-security import github example/project --format json > /path/outside/repository/alerts.json
|
|
@@ -2429,11 +2465,11 @@ The importer fetches every page, retrieves alert details, and retains the select
|
|
|
2429
2465
|
ref's instance. It writes the saved input for publication; no website download or
|
|
2430
2466
|
hand-written JSON mapping is needed. Use `--github-alert NUMBER` repeatedly for
|
|
2431
2467
|
selected alerts or `--github-ref REF` for another ref. Defaults are open alerts on
|
|
2432
|
-
the default branch. MCP list calls are paginated separately
|
|
2433
|
-
|
|
2468
|
+
the default branch. MCP list calls are paginated separately. Code-scanning
|
|
2469
|
+
imports require the saved collector output, which includes the selected instance.
|
|
2434
2470
|
|
|
2435
2471
|
The importer uses GitHub CLI authentication (`gh auth login`) and `GH_HOST`;
|
|
2436
|
-
the plugin's connection does not sign in `gh`. Reading alerts requires
|
|
2472
|
+
the plugin's connection does not sign in `gh`. Reading code-scanning alerts requires
|
|
2437
2473
|
[code-scanning access](https://docs.github.com/en/rest/code-scanning/code-scanning#list-code-scanning-alerts-for-a-repository):
|
|
2438
2474
|
**Code scanning alerts: read** for a fine-grained token, or `security_events` for
|
|
2439
2475
|
a classic token (`public_repo` is sufficient for public repositories). The source
|
|
@@ -2783,7 +2819,9 @@ patch-risk assessment still uses its read-only sandbox.
|
|
|
2783
2819
|
|
|
2784
2820
|
`scan --patch` runs after a complete scan. `--patch-severity` defaults to `low`;
|
|
2785
2821
|
`high` selects high and critical findings. Interactive users can select findings
|
|
2786
|
-
and add instructions.
|
|
2822
|
+
and add instructions. The interactive finding browser lists critical, high,
|
|
2823
|
+
medium, then low findings, preserving scan order within each severity.
|
|
2824
|
+
Patch results are `verified`, `no_change`, `blocked`, or
|
|
2787
2825
|
`failed`. Verified/already-fixed findings no longer fail the severity threshold.
|
|
2788
2826
|
|
|
2789
2827
|
### Create or resume a draft pull request
|
|
@@ -2862,7 +2900,7 @@ from the repository root with the published image:
|
|
|
2862
2900
|
|
|
2863
2901
|
```bash
|
|
2864
2902
|
mkdir -p results state
|
|
2865
|
-
chmod 700
|
|
2903
|
+
chmod 700 state
|
|
2866
2904
|
export CODEX_SECURITY_USER="$(id -u):$(id -g)"
|
|
2867
2905
|
export CODEX_SECURITY_IMAGE=ghcr.io/openai/codex-security:latest
|
|
2868
2906
|
docker compose pull codex-security
|
package/docs/dedupe-records.md
CHANGED
|
@@ -190,8 +190,8 @@ For failure or an inconclusive review, send an explicit error:
|
|
|
190
190
|
}
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
-
A host error ends the review without another submission. Invalid model
|
|
194
|
-
answers, missing decisions, and host errors make the whole batch unresolved;
|
|
193
|
+
A host error ends the review without another submission. Invalid final model
|
|
194
|
+
answers, missing final decisions, and host errors make the whole batch unresolved;
|
|
195
195
|
previous successful reviews in that run do not become persistence decisions.
|
|
196
196
|
The existing algorithm treats a validated `DISTINCT` as a nonmatch, when
|
|
197
197
|
supplied finding content is insufficient to establish a shared correction. If the host considers the review
|
|
@@ -213,10 +213,23 @@ fresh JSON-RPC ID and `params: {requestId, prompt}`. The request ID in the
|
|
|
213
213
|
parameters identifies the original review. Submit the prompt in the same
|
|
214
214
|
session and reply on the new JSON-RPC ID. The correction omits
|
|
215
215
|
`supportsContinuation`, so the host releases the session after that turn. A second missing submission ends
|
|
216
|
-
the review as unresolved. A pending tool call
|
|
217
|
-
|
|
216
|
+
the review as unresolved. A pending tool call stays in the original turn.
|
|
217
|
+
An uncertain outcome or explicit blocker follows the
|
|
218
218
|
existing error path. Hosts without continuation support can ignore the field.
|
|
219
219
|
|
|
220
|
+
When `review.run` also advertises `supportsSubmissionValidation: true`, a host
|
|
221
|
+
can keep a pending decision tool call open by adding `reviewPending: true` to
|
|
222
|
+
the JSON-RPC reply envelope, alongside `id` and `result`. Put the raw tool
|
|
223
|
+
arguments in `result`; only the host sets the envelope flag. The CLI checks
|
|
224
|
+
the arguments against the original assignment. If valid, it sends
|
|
225
|
+
`review.release` with `{requestId}`. Release the session and reply
|
|
226
|
+
`{"status":"released"}` only after cleanup succeeds. If invalid, the CLI sends
|
|
227
|
+
`review.continue` with the validation error. Return that prompt to the pending
|
|
228
|
+
tool call in the same session. Release the session and reply with the corrected
|
|
229
|
+
decision. The CLI validates this final answer and allows no further correction.
|
|
230
|
+
Either follow-up uses a fresh JSON-RPC ID. A host that has already closed the
|
|
231
|
+
session returns its ordinary final answer as before.
|
|
232
|
+
|
|
220
233
|
## Final response and persistence
|
|
221
234
|
|
|
222
235
|
```json
|
package/docs/hosted-scans.md
CHANGED
|
@@ -208,6 +208,20 @@ needs before returning that outcome. Use shared mounts or a coordinated transfer
|
|
|
208
208
|
that preserves the supplied path bindings, not independent copies of mutable
|
|
209
209
|
workbench state.
|
|
210
210
|
|
|
211
|
+
For path scans with the Linux CLI and a current plugin, use the inventory
|
|
212
|
+
path the scope helper reports. A Linux executor can keep the inventory in
|
|
213
|
+
`stateDirectory` outside the checkout and captured output. The state binding
|
|
214
|
+
may include one protected symlink and must exclude `..` from the path and
|
|
215
|
+
link target. Its protected directory must support executor-owned mode-`0600`
|
|
216
|
+
files and keep a reader open across writer close.
|
|
217
|
+
|
|
218
|
+
Other layouts use `scoped-source-input.jsonl` in scan output. If a later
|
|
219
|
+
shell loses the inventory, run the recovery command in the prompt. It may
|
|
220
|
+
replace an earlier output file, so the executor needs permission to remove it.
|
|
221
|
+
State transfers include private inventories named
|
|
222
|
+
`<scope-input-filename>.scoped-<24 lowercase hex digits>.jsonl`. Hosts can
|
|
223
|
+
remove the request's private inventories after execution finishes.
|
|
224
|
+
|
|
211
225
|
Run the plugin stdio server from
|
|
212
226
|
`pluginRoot/scripts/launch_codex_security_mcp --stdio` with the supplied
|
|
213
227
|
environment. The executor needs the target files, plugin skills and registered
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openai/codex-security",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "TypeScript SDK and CLI for Codex Security",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "OpenAI",
|
|
@@ -58,10 +58,10 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@inquirer/prompts": "8.7.4",
|
|
61
|
-
"@linear/sdk": "
|
|
61
|
+
"@linear/sdk": "99.0.0",
|
|
62
62
|
"@octokit/core": "7.0.8",
|
|
63
|
-
"@openai/codex": "0.
|
|
64
|
-
"@openai/codex-sdk": "0.
|
|
63
|
+
"@openai/codex": "0.165.0",
|
|
64
|
+
"@openai/codex-sdk": "0.165.0",
|
|
65
65
|
"ajv": "8.20.0",
|
|
66
66
|
"fflate": "0.8.3",
|
|
67
67
|
"incur": "0.7.1",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"prettier": "3.9.10",
|
|
97
97
|
"typescript": "7.0.2"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "79ff4bde8a4685b9c31ad8f449bdb40df8f468f7",
|
|
100
100
|
"scripts": {
|
|
101
101
|
"audit:prod": "pnpm audit --prod --audit-level high",
|
|
102
102
|
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
@@ -378,7 +378,7 @@
|
|
|
378
378
|
"additionalProperties": false,
|
|
379
379
|
"properties": {
|
|
380
380
|
"provider": {
|
|
381
|
-
"enum": ["wiz", "endor", "snyk", "github", "semgrep"],
|
|
381
|
+
"enum": ["wiz", "endor", "snyk", "github", "semgrep", "inspector"],
|
|
382
382
|
"title": "Provider",
|
|
383
383
|
"type": "string"
|
|
384
384
|
},
|