@openai/codex-security 0.1.9 → 0.1.10
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 -5
- package/_bundled_plugin/.codex-plugin/plugin.json +1 -1
- 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/preflight/capability-profiles.toml +1 -1
- package/_bundled_plugin/references/scan-contract.md +1 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +22 -0
- package/_bundled_plugin/scripts/generate_in_scope_files.py +102 -1
- package/_bundled_plugin/scripts/normalize_candidates.py +20 -2
- package/_bundled_plugin/scripts/workbench_cli.py +4 -0
- package/_bundled_plugin/scripts/workbench_db.py +12 -0
- package/_bundled_plugin/scripts/workbench_native_indexes.py +100 -43
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +8 -4
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +21 -140
- package/dist/api.d.ts +42 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +103 -44
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +93 -39
- package/dist/cli.js.map +1 -1
- package/dist/cost.d.ts +1 -0
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +1 -1
- package/dist/cost.js.map +1 -1
- package/dist/errors.d.ts +4 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -46
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/multiscan.js +2 -2
- package/dist/multiscan.js.map +1 -1
- package/dist/result.d.ts +13 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +3 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.js +3 -3
- package/dist/runtime.js.map +1 -1
- package/dist/scan-comparison.d.ts +14 -0
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +89 -0
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +1 -0
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +10 -0
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +17 -0
- package/dist/scan-logs.d.ts.map +1 -0
- package/dist/scan-logs.js +90 -0
- package/dist/scan-logs.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { CodexSecurity } from "./api.js";
|
|
|
4
4
|
import { type BulkScanDiscoveryDependencies, type BulkScanPrompt } from "./bulk-scan-discovery.js";
|
|
5
5
|
import { type CodexSecurityConfig, type ExternalModelProvider, type JsonObject } from "./config.js";
|
|
6
6
|
import { type CodexCommand } from "./runtime.js";
|
|
7
|
-
import { matchScanFindings } from "./scan-comparison.js";
|
|
7
|
+
import { type matchScanFindings } from "./scan-comparison.js";
|
|
8
8
|
import { type UpdateNotice } from "./version.js";
|
|
9
9
|
type Writable = Pick<NodeJS.WriteStream, "write"> & {
|
|
10
10
|
readonly isTTY?: boolean;
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA4BA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAEL,aAAa,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA4BA,OAAO,KAAK,EAAE,oBAAoB,EA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B,eAAe,EACf,KAAK,GAAG,aAAa,GAAG,eAAe,CACjB,EACxB,WAAW,UAAO;IAQpB,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,IAAW,cAAc,IAAI,MAAM,CAKlC;IAEM,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAejC,SAAS,IAAI,IAAI;IAgBjB,eAAe,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI;CA2BhD"}
|
package/dist/cli.js
CHANGED
|
@@ -10,15 +10,16 @@ import { pipeline } from "node:stream/promises";
|
|
|
10
10
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
11
|
import { Cli, z } from "incur";
|
|
12
12
|
import { parse as parseToml } from "smol-toml";
|
|
13
|
-
import { classifyConnectionFailure,
|
|
13
|
+
import { classifyConnectionFailure, createSecurityInternal, listRepositoryFindings, scanAuthentication, } from "./api.js";
|
|
14
14
|
import { accountStatus } from "./auth.js";
|
|
15
15
|
import { createBulkScanDiscoveryDependencies, runBulkScanWizard, } from "./bulk-scan-discovery.js";
|
|
16
16
|
import { DEFAULT_CODEX_CONFIG, EXTERNAL_CODEX_PROVIDERS, isExternalModelProvider, mergedCodexConfig, scanModelConfiguration, scanModelProvider, } from "./config.js";
|
|
17
17
|
import { formatUsd } from "./cost.js";
|
|
18
|
-
import { CodexSecurityError, ConfigurationError, InvalidTargetError, OutputDirectoryError, OutputInsideProtectedRootError, PluginPythonUnavailableError,
|
|
18
|
+
import { CodexSecurityError, ConfigurationError, InvalidTargetError, OutputDirectoryError, OutputInsideProtectedRootError, PluginPythonUnavailableError, errorMessage, safeErrorMessage, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
19
19
|
import { runMultiscan } from "./multiscan.js";
|
|
20
20
|
import { bundledPluginRoot, codexSecurityCredentialHome, codexSecurityStateDirectory, expandHome, prepareCodexSecurityCredentialHome, resolveCodexCommand, resolvePluginPython, runWorkbench, setCodexSecurityCredentialLogout, } from "./runtime.js";
|
|
21
|
-
import {
|
|
21
|
+
import { matchScanFindingsInternal, } from "./scan-comparison.js";
|
|
22
|
+
import { readScanLogs } from "./scan-logs.js";
|
|
22
23
|
import { renderScanHistory, } from "./scan-history-renderer.js";
|
|
23
24
|
import { ScanDashboard } from "./scan-dashboard.js";
|
|
24
25
|
import { DiffTarget } from "./targets.js";
|
|
@@ -146,7 +147,7 @@ async function readPromptFiles(directory, scanPromptFile, postScanPromptFile) {
|
|
|
146
147
|
};
|
|
147
148
|
}
|
|
148
149
|
const DEFAULT_DEPENDENCIES = {
|
|
149
|
-
createSecurity: (config) =>
|
|
150
|
+
createSecurity: (config) => createSecurityInternal(config, { surface: "cli" }),
|
|
150
151
|
environment: process.env,
|
|
151
152
|
prepareAuthenticationHome: prepareCodexSecurityCredentialHome,
|
|
152
153
|
checkForUpdate: () => checkForUpdate({ environment: process.env }),
|
|
@@ -248,7 +249,7 @@ const DEFAULT_DEPENDENCIES = {
|
|
|
248
249
|
failureMessage: "Could not read Codex Security scan history",
|
|
249
250
|
}, args);
|
|
250
251
|
},
|
|
251
|
-
matchFindings:
|
|
252
|
+
matchFindings: (input, options) => matchScanFindingsInternal(input, options, { surface: "cli" }),
|
|
252
253
|
};
|
|
253
254
|
export async function runCodexSkillCommand(args, output, command = resolveCodexCommand(), processEnvironment = process.env) {
|
|
254
255
|
const configuredHome = processEnvironment["CODEX_HOME"];
|
|
@@ -447,7 +448,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
447
448
|
return await select(await dependencies.runWorkbench(args));
|
|
448
449
|
}
|
|
449
450
|
catch (error) {
|
|
450
|
-
errorOutput.write(`codex-security: ${
|
|
451
|
+
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
|
|
451
452
|
exitCode = 2;
|
|
452
453
|
return undefined;
|
|
453
454
|
}
|
|
@@ -527,6 +528,27 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
527
528
|
]);
|
|
528
529
|
},
|
|
529
530
|
});
|
|
531
|
+
findingFeedback.command("list", {
|
|
532
|
+
description: "List open findings for a repository across its scans.",
|
|
533
|
+
mcp: false,
|
|
534
|
+
args: z.object({
|
|
535
|
+
repository: z
|
|
536
|
+
.string()
|
|
537
|
+
.optional()
|
|
538
|
+
.describe("Repository to inspect (default: current directory)."),
|
|
539
|
+
}),
|
|
540
|
+
output: z.record(z.string(), z.unknown()).optional(),
|
|
541
|
+
async run({ args, format }) {
|
|
542
|
+
const repository = resolve(dependencies.currentDirectory(), args.repository ?? ".");
|
|
543
|
+
return presentHistory(await history(["list-repositories"], async (value) => {
|
|
544
|
+
const target = value["repositories"].find((entry) => entry["targetPath"] === repository);
|
|
545
|
+
const findings = target === undefined
|
|
546
|
+
? []
|
|
547
|
+
: await listRepositoryFindings(dependencies.runWorkbench, target["targetId"]);
|
|
548
|
+
return { repository, findings: findings ?? [] };
|
|
549
|
+
}), "findings", format, { repository });
|
|
550
|
+
},
|
|
551
|
+
});
|
|
530
552
|
const scanHistory = Cli.create("scans", {
|
|
531
553
|
description: "List, inspect, rerun, match, and compare saved Codex Security scans.",
|
|
532
554
|
})
|
|
@@ -591,6 +613,31 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
591
613
|
};
|
|
592
614
|
}), "show", format, { showLinkedFindings: options.showLinkedFindings });
|
|
593
615
|
},
|
|
616
|
+
})
|
|
617
|
+
.command("logs", {
|
|
618
|
+
description: "Show saved activity for a scan and its workers.",
|
|
619
|
+
mcp: false,
|
|
620
|
+
args: z.object({
|
|
621
|
+
scanId: z
|
|
622
|
+
.string()
|
|
623
|
+
.min(1)
|
|
624
|
+
.describe("Saved scan identifier or unique prefix."),
|
|
625
|
+
}),
|
|
626
|
+
output: z.record(z.string(), z.unknown()).optional(),
|
|
627
|
+
async run({ args }) {
|
|
628
|
+
return await history(["get-scan", "--scan-id", args.scanId], async (value) => {
|
|
629
|
+
const scan = value["scan"];
|
|
630
|
+
const threadId = scan.continuationThreadId;
|
|
631
|
+
if (!threadId) {
|
|
632
|
+
throw new CodexSecurityError(`No session is associated with scan ${scan.scanId}.`);
|
|
633
|
+
}
|
|
634
|
+
return (await readScanLogs({
|
|
635
|
+
scanId: scan.scanId,
|
|
636
|
+
threadId,
|
|
637
|
+
codexHome: codexSecurityCredentialHome(dependencies.environment),
|
|
638
|
+
}));
|
|
639
|
+
});
|
|
640
|
+
},
|
|
594
641
|
})
|
|
595
642
|
.command("rerun", {
|
|
596
643
|
description: "Rerun a saved scan with its original configuration.",
|
|
@@ -618,7 +665,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
618
665
|
scanArguments.verbose = options.verbose;
|
|
619
666
|
}
|
|
620
667
|
catch (error) {
|
|
621
|
-
const message =
|
|
668
|
+
const message = errorMessage(error);
|
|
622
669
|
errorOutput.write(`codex-security: ${message}\n`);
|
|
623
670
|
exitCode = 2;
|
|
624
671
|
return incurError({
|
|
@@ -674,7 +721,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
674
721
|
return presentHistory(await matchScanPair(args.beforeId, args.afterId, options.force), "compare", format);
|
|
675
722
|
}
|
|
676
723
|
catch (error) {
|
|
677
|
-
errorOutput.write(`codex-security: ${
|
|
724
|
+
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
|
|
678
725
|
exitCode = 2;
|
|
679
726
|
return undefined;
|
|
680
727
|
}
|
|
@@ -720,7 +767,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
720
767
|
verbose: z
|
|
721
768
|
.boolean()
|
|
722
769
|
.default(false)
|
|
723
|
-
.describe("Print
|
|
770
|
+
.describe("Print scan diagnostics to stderr."),
|
|
724
771
|
path: z
|
|
725
772
|
.array(optionValue("--path"))
|
|
726
773
|
.default([])
|
|
@@ -939,7 +986,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
939
986
|
};
|
|
940
987
|
}
|
|
941
988
|
catch (error) {
|
|
942
|
-
errorOutput.write(`codex-security: ${
|
|
989
|
+
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
|
|
943
990
|
exitCode = 2;
|
|
944
991
|
return undefined;
|
|
945
992
|
}
|
|
@@ -1075,7 +1122,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
1075
1122
|
signal: controller.signal,
|
|
1076
1123
|
onProgress: ({ repository, status, attempt, error, warning }) => {
|
|
1077
1124
|
const detail = error ?? warning;
|
|
1078
|
-
errorOutput.write(`codex-security: ${repository} ${status} (attempt ${attempt})${detail === undefined ? "" : `: ${
|
|
1125
|
+
errorOutput.write(`codex-security: ${repository} ${status} (attempt ${attempt})${detail === undefined ? "" : `: ${errorMessage(detail)}`}\n`);
|
|
1079
1126
|
},
|
|
1080
1127
|
});
|
|
1081
1128
|
exitCode =
|
|
@@ -1089,7 +1136,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
1089
1136
|
(error instanceof Error && error.name === "ExitPromptError"
|
|
1090
1137
|
? 130
|
|
1091
1138
|
: 2);
|
|
1092
|
-
errorOutput.write(`codex-security: ${
|
|
1139
|
+
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
|
|
1093
1140
|
}
|
|
1094
1141
|
finally {
|
|
1095
1142
|
dependencies.removeSignalListener("SIGINT", onInterrupt);
|
|
@@ -1165,7 +1212,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
1165
1212
|
}
|
|
1166
1213
|
catch (error) {
|
|
1167
1214
|
exitCode = 2;
|
|
1168
|
-
errorOutput.write(`codex-security: ${
|
|
1215
|
+
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
|
|
1169
1216
|
}
|
|
1170
1217
|
},
|
|
1171
1218
|
})
|
|
@@ -1192,7 +1239,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
1192
1239
|
}
|
|
1193
1240
|
catch (error) {
|
|
1194
1241
|
exitCode = 2;
|
|
1195
|
-
errorOutput.write(`codex-security: ${
|
|
1242
|
+
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
|
|
1196
1243
|
}
|
|
1197
1244
|
},
|
|
1198
1245
|
})
|
|
@@ -1341,7 +1388,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
1341
1388
|
if (frameworkExit !== undefined) {
|
|
1342
1389
|
if (exitCode !== 0)
|
|
1343
1390
|
return exitCode;
|
|
1344
|
-
errorOutput.write(`codex-security: ${
|
|
1391
|
+
errorOutput.write(`codex-security: ${errorMessage(incurErrorMessage(frameworkOutput))}\n`);
|
|
1345
1392
|
return 2;
|
|
1346
1393
|
}
|
|
1347
1394
|
if (frameworkOutput.length === 0)
|
|
@@ -1351,7 +1398,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
1351
1398
|
return exitCode;
|
|
1352
1399
|
}
|
|
1353
1400
|
catch (error) {
|
|
1354
|
-
errorOutput.write(`codex-security: ${
|
|
1401
|
+
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
|
|
1355
1402
|
return 2;
|
|
1356
1403
|
}
|
|
1357
1404
|
}
|
|
@@ -1726,6 +1773,8 @@ async function runSkill(skill, inputs, codexOverrides, effort, stdout, stderr, d
|
|
|
1726
1773
|
`model_reasoning_effort=${JSON.stringify(reasoningEffort)}`,
|
|
1727
1774
|
"--config",
|
|
1728
1775
|
'approval_policy="never"',
|
|
1776
|
+
"--config",
|
|
1777
|
+
'responses_api_metadata.codex_security_surface="cli"',
|
|
1729
1778
|
"--sandbox",
|
|
1730
1779
|
"workspace-write",
|
|
1731
1780
|
"--skip-git-repo-check",
|
|
@@ -1872,14 +1921,12 @@ async function runExport(arguments_, output, errorOutput, dependencies) {
|
|
|
1872
1921
|
return 0;
|
|
1873
1922
|
}
|
|
1874
1923
|
catch (error) {
|
|
1875
|
-
errorOutput.write(`codex-security: ${
|
|
1924
|
+
errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
|
|
1876
1925
|
return 2;
|
|
1877
1926
|
}
|
|
1878
1927
|
}
|
|
1879
|
-
function
|
|
1880
|
-
return
|
|
1881
|
-
.replaceAll(/(\b(?:tenant(?:[_-]?id)?|org(?:anization)?(?:[_-]?id)?|project(?:[_-]?id)?|(?:x[_-]?)?(?:request|trace|correlation)[_-]?id)\b(?:\\*["'])?\s*[:=]\s*)(?!\[redacted\])(?:(\\*)(['"])(?:(?!(?<!\\)\2\3)(?:\\.|[^\\]))*(?:(?<!\\)\2\3|$)|[^\s"',;&}\]]+)/giu, "$1$2$3[redacted]$2$3")
|
|
1882
|
-
.replaceAll(/[\u0000-\u001F\u007F\u0085\u2028\u2029]/gu, " ");
|
|
1928
|
+
function diagnosticValue(value) {
|
|
1929
|
+
return errorMessage(value).replaceAll(/[\u0000-\u001F\u007F\u0085\u2028\u2029]/gu, " ");
|
|
1883
1930
|
}
|
|
1884
1931
|
async function runScan(arguments_, errorOutput, dependencies, interactive = true) {
|
|
1885
1932
|
let scanDir = null;
|
|
@@ -1911,7 +1958,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
|
|
|
1911
1958
|
const attributes = Object.entries(fields).flatMap(([name, value]) => value === undefined
|
|
1912
1959
|
? []
|
|
1913
1960
|
: [
|
|
1914
|
-
`${name}=${JSON.stringify(typeof value === "string" ?
|
|
1961
|
+
`${name}=${JSON.stringify(typeof value === "string" ? diagnosticValue(value) : value)}`,
|
|
1915
1962
|
]);
|
|
1916
1963
|
writeAboveProgress(() => {
|
|
1917
1964
|
errorOutput.write(`codex-security: debug: ${event}${attributes.length === 0 ? "" : ` ${attributes.join(" ")}`}\n`);
|
|
@@ -2039,7 +2086,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
|
|
|
2039
2086
|
: { maxCostUsd: arguments_.maxCostUsd }),
|
|
2040
2087
|
clock: dependencies,
|
|
2041
2088
|
color: dependencies.environment["NO_COLOR"] === undefined,
|
|
2042
|
-
sanitize:
|
|
2089
|
+
sanitize: safeErrorMessage,
|
|
2043
2090
|
input: process.stdin,
|
|
2044
2091
|
onInterrupt,
|
|
2045
2092
|
});
|
|
@@ -2128,11 +2175,11 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
|
|
|
2128
2175
|
onOutputArchived: (archiveDir) => {
|
|
2129
2176
|
diagnostic("scan.output_archived", { archive_dir: archiveDir });
|
|
2130
2177
|
if (dashboard !== null) {
|
|
2131
|
-
dashboard.note(`Moved existing results to: ${
|
|
2178
|
+
dashboard.note(`Moved existing results to: ${errorMessage(archiveDir)}`);
|
|
2132
2179
|
return;
|
|
2133
2180
|
}
|
|
2134
2181
|
progress?.stopTimer();
|
|
2135
|
-
errorOutput.write(`Moved existing results to: ${
|
|
2182
|
+
errorOutput.write(`Moved existing results to: ${errorMessage(archiveDir)}\n`);
|
|
2136
2183
|
},
|
|
2137
2184
|
signal: preparationAbortController.signal,
|
|
2138
2185
|
onOutputDirReady: (path) => {
|
|
@@ -2277,7 +2324,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
|
|
|
2277
2324
|
progress.startTimer(runningMessage());
|
|
2278
2325
|
},
|
|
2279
2326
|
onWarning: (warning, details) => {
|
|
2280
|
-
const message =
|
|
2327
|
+
const message = diagnosticValue(warning);
|
|
2281
2328
|
if (details?.kind === "target_changed") {
|
|
2282
2329
|
targetWarnings.push(message);
|
|
2283
2330
|
}
|
|
@@ -2291,7 +2338,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
|
|
|
2291
2338
|
observer,
|
|
2292
2339
|
classification: classifyConnectionFailure(error),
|
|
2293
2340
|
});
|
|
2294
|
-
const warning = `${observer} observer failed: ${
|
|
2341
|
+
const warning = `${observer} observer failed: ${diagnosticValue(error)}`;
|
|
2295
2342
|
if (dashboard === null) {
|
|
2296
2343
|
writeAboveProgress(() => {
|
|
2297
2344
|
errorOutput.write(`codex-security: warning: ${warning}\n`);
|
|
@@ -2346,7 +2393,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
|
|
|
2346
2393
|
if (failed) {
|
|
2347
2394
|
const costLimitFailure = failure instanceof ScanCostLimitExceededError ? failure : undefined;
|
|
2348
2395
|
const message = failure instanceof OutputInsideProtectedRootError
|
|
2349
|
-
?
|
|
2396
|
+
? errorMessage(protectedRootErrorMessage(failure))
|
|
2350
2397
|
: scanFailureMessage(failure, selectedAuthentication);
|
|
2351
2398
|
diagnostic("scan.failed", {
|
|
2352
2399
|
classification: costLimitFailure !== undefined
|
|
@@ -2363,7 +2410,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
|
|
|
2363
2410
|
return { exitCode: 2, error: message };
|
|
2364
2411
|
}
|
|
2365
2412
|
if (scanDir !== null) {
|
|
2366
|
-
errorOutput.write(`Partial output was kept at ${
|
|
2413
|
+
errorOutput.write(`Partial output was kept at ${errorMessage(scanDir)}.\n`);
|
|
2367
2414
|
}
|
|
2368
2415
|
return { exitCode: 2, error: message };
|
|
2369
2416
|
}
|
|
@@ -2471,7 +2518,7 @@ function scanFailureMessage(error, authentication) {
|
|
|
2471
2518
|
// errors can name the organization or project, which must not reach stderr or
|
|
2472
2519
|
// the JSON error field.
|
|
2473
2520
|
if (isLocalScanFailure(error))
|
|
2474
|
-
return
|
|
2521
|
+
return diagnosticValue(error);
|
|
2475
2522
|
switch (classifyConnectionFailure(error)) {
|
|
2476
2523
|
case "unauthorized":
|
|
2477
2524
|
if (authentication?.method === "aws_credentials") {
|
|
@@ -2499,7 +2546,7 @@ function scanFailureMessage(error, authentication) {
|
|
|
2499
2546
|
case "network_error":
|
|
2500
2547
|
case "timeout":
|
|
2501
2548
|
case "unknown":
|
|
2502
|
-
return
|
|
2549
|
+
return diagnosticValue(error);
|
|
2503
2550
|
}
|
|
2504
2551
|
}
|
|
2505
2552
|
function scanScope(arguments_) {
|
|
@@ -2511,7 +2558,7 @@ function scanScope(arguments_) {
|
|
|
2511
2558
|
portable.startsWith("//")
|
|
2512
2559
|
? portable.split("/").at(-1) ?? portable
|
|
2513
2560
|
: portable;
|
|
2514
|
-
return
|
|
2561
|
+
return errorMessage(scoped.replaceAll(/[\u0000-\u001F\u007F]/gu, " "));
|
|
2515
2562
|
});
|
|
2516
2563
|
return `${displayed.join(", ")}${arguments_.paths.length > displayed.length ? `, +${arguments_.paths.length - displayed.length} more` : ""}`;
|
|
2517
2564
|
}
|
|
@@ -2535,8 +2582,10 @@ function scanPhase(value) {
|
|
|
2535
2582
|
}
|
|
2536
2583
|
function printScanSummary(result, progress, errorOutput, color) {
|
|
2537
2584
|
const paint = (value, code) => color ? `\u001B[${code}m${value}\u001B[0m` : value;
|
|
2585
|
+
const repositoryFindings = result.repositoryFindings;
|
|
2586
|
+
const findings = repositoryFindings ?? result.findings.findings;
|
|
2538
2587
|
const severities = new Map();
|
|
2539
|
-
for (const finding of
|
|
2588
|
+
for (const finding of findings) {
|
|
2540
2589
|
severities.set(finding.severity.level, (severities.get(finding.severity.level) ?? 0) + 1);
|
|
2541
2590
|
}
|
|
2542
2591
|
const severitySummary = DISPLAY_SEVERITIES.map((severity) => {
|
|
@@ -2555,7 +2604,12 @@ function printScanSummary(result, progress, errorOutput, color) {
|
|
|
2555
2604
|
const duration = elapsed < 60
|
|
2556
2605
|
? `${elapsed}s`
|
|
2557
2606
|
: `${Math.floor(elapsed / 60)}m ${elapsed % 60}s`;
|
|
2558
|
-
const findingCount =
|
|
2607
|
+
const findingCount = findings.length;
|
|
2608
|
+
const confirmedCount = repositoryFindings?.filter((finding) => finding.confirmedInLatestScan)
|
|
2609
|
+
.length ?? 0;
|
|
2610
|
+
const findingSummary = repositoryFindings?.length
|
|
2611
|
+
? `${confirmedCount} confirmed this scan; ${findingCount - confirmedCount} previously found; ${severitySummary}`
|
|
2612
|
+
: severitySummary;
|
|
2559
2613
|
const findingColor = findingCount === 0
|
|
2560
2614
|
? 32
|
|
2561
2615
|
: severities.has("critical") || severities.has("high")
|
|
@@ -2563,8 +2617,8 @@ function printScanSummary(result, progress, errorOutput, color) {
|
|
|
2563
2617
|
: severities.has("medium")
|
|
2564
2618
|
? 33
|
|
2565
2619
|
: 36;
|
|
2566
|
-
errorOutput.write(`\n ${paint("REPORT", "1;36")} ${paint(
|
|
2567
|
-
` ${paint("FINDINGS", 1)} ${paint(`${findingCount}${
|
|
2620
|
+
errorOutput.write(`\n ${paint("REPORT", "1;36")} ${paint(errorMessage(result.reportPath), 4)}\n\n` +
|
|
2621
|
+
` ${paint("FINDINGS", 1)} ${paint(`${findingCount}${findingSummary === "" ? "" : ` (${findingSummary})`}`, findingColor)}\n` +
|
|
2568
2622
|
` ${paint("COVERAGE", 1)} ${result.coverage.completeness}\n` +
|
|
2569
2623
|
` ${paint("ELAPSED", 1)} ${duration}\n`);
|
|
2570
2624
|
const tokenSummary = formatTokenUsage(result.turnResult.usage);
|
|
@@ -2574,7 +2628,7 @@ function printScanSummary(result, progress, errorOutput, color) {
|
|
|
2574
2628
|
if (result.cost !== null) {
|
|
2575
2629
|
errorOutput.write(` ${paint("COST", 1)} ${formatUsd(result.cost.estimatedUsd)}\n`);
|
|
2576
2630
|
}
|
|
2577
|
-
errorOutput.write(` ${paint("RESULTS", 1)} ${
|
|
2631
|
+
errorOutput.write(` ${paint("RESULTS", 1)} ${errorMessage(result.scanDir)}\n`);
|
|
2578
2632
|
}
|
|
2579
2633
|
function formatTokenUsage(usage) {
|
|
2580
2634
|
if (usage === null || typeof usage !== "object")
|
|
@@ -2844,7 +2898,7 @@ function interruptedExit(signal, scanDir, errorOutput) {
|
|
|
2844
2898
|
errorOutput.write(`codex-security: Scan ${ctrlC ? "canceled by Ctrl-C" : "terminated by SIGTERM"}.\n`);
|
|
2845
2899
|
errorOutput.write(scanDir === null
|
|
2846
2900
|
? "codex-security: No partial output was kept.\n"
|
|
2847
|
-
: `codex-security: Partial output was kept at ${
|
|
2901
|
+
: `codex-security: Partial output was kept at ${errorMessage(scanDir)}.\n`);
|
|
2848
2902
|
return ctrlC ? 130 : 143;
|
|
2849
2903
|
}
|
|
2850
2904
|
function isJsonObject(value) {
|
|
@@ -2867,7 +2921,7 @@ if (invokedAsMain()) {
|
|
|
2867
2921
|
void main().then((exitCode) => {
|
|
2868
2922
|
process.exitCode = exitCode;
|
|
2869
2923
|
}, (error) => {
|
|
2870
|
-
process.stderr.write(`codex-security: ${
|
|
2924
|
+
process.stderr.write(`codex-security: ${errorMessage(error)}\n`);
|
|
2871
2925
|
process.exitCode = 2;
|
|
2872
2926
|
});
|
|
2873
2927
|
}
|