@openai/codex-security 0.1.9 → 0.1.11

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.
Files changed (87) hide show
  1. package/README.md +43 -18
  2. package/_bundled_plugin/.codex-plugin/plugin.json +1 -1
  3. package/_bundled_plugin/.mcp.json +3 -1
  4. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  5. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  6. package/_bundled_plugin/preflight/capability-profiles.toml +1 -1
  7. package/_bundled_plugin/references/scan-contract.md +1 -1
  8. package/_bundled_plugin/scripts/deep_scan_config.py +21 -1
  9. package/_bundled_plugin/scripts/deep_scan_workbench.py +66 -14
  10. package/_bundled_plugin/scripts/finalize_scan_contract.py +15 -207
  11. package/_bundled_plugin/scripts/generate_in_scope_files.py +127 -2
  12. package/_bundled_plugin/scripts/generate_rank_input.py +38 -5
  13. package/_bundled_plugin/scripts/normalize_candidates.py +20 -2
  14. package/_bundled_plugin/scripts/rank_preview.py +4 -0
  15. package/_bundled_plugin/scripts/report_projection.py +39 -1
  16. package/_bundled_plugin/scripts/workbench_cli.py +9 -0
  17. package/_bundled_plugin/scripts/workbench_db.py +295 -4
  18. package/_bundled_plugin/scripts/workbench_native_indexes.py +100 -43
  19. package/_bundled_plugin/scripts/workbench_schema.py +15 -0
  20. package/_bundled_plugin/scripts/workbench_source_excerpt.py +1 -5
  21. package/_bundled_plugin/scripts/workbench_target.py +82 -0
  22. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +5 -3
  23. package/_bundled_plugin/skills/finding-discovery/SKILL.md +8 -4
  24. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +21 -140
  25. package/dist/api.d.ts +43 -3
  26. package/dist/api.d.ts.map +1 -1
  27. package/dist/api.js +319 -135
  28. package/dist/api.js.map +1 -1
  29. package/dist/auth.d.ts +2 -3
  30. package/dist/auth.d.ts.map +1 -1
  31. package/dist/auth.js +59 -270
  32. package/dist/auth.js.map +1 -1
  33. package/dist/cli.d.ts +1 -1
  34. package/dist/cli.d.ts.map +1 -1
  35. package/dist/cli.js +107 -43
  36. package/dist/cli.js.map +1 -1
  37. package/dist/contract.js +7 -5
  38. package/dist/contract.js.map +1 -1
  39. package/dist/cost.d.ts +2 -0
  40. package/dist/cost.d.ts.map +1 -1
  41. package/dist/cost.js +24 -2
  42. package/dist/cost.js.map +1 -1
  43. package/dist/errors.d.ts +4 -2
  44. package/dist/errors.d.ts.map +1 -1
  45. package/dist/errors.js +10 -46
  46. package/dist/errors.js.map +1 -1
  47. package/dist/index.d.ts +2 -2
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +1 -1
  50. package/dist/index.js.map +1 -1
  51. package/dist/knowledge-base.d.ts.map +1 -1
  52. package/dist/knowledge-base.js +2 -1
  53. package/dist/knowledge-base.js.map +1 -1
  54. package/dist/multiscan.d.ts.map +1 -1
  55. package/dist/multiscan.js +3 -2
  56. package/dist/multiscan.js.map +1 -1
  57. package/dist/result.d.ts +13 -1
  58. package/dist/result.d.ts.map +1 -1
  59. package/dist/result.js +3 -0
  60. package/dist/result.js.map +1 -1
  61. package/dist/runtime.d.ts +9 -6
  62. package/dist/runtime.d.ts.map +1 -1
  63. package/dist/runtime.js +130 -287
  64. package/dist/runtime.js.map +1 -1
  65. package/dist/scan-comparison.d.ts +14 -0
  66. package/dist/scan-comparison.d.ts.map +1 -1
  67. package/dist/scan-comparison.js +90 -1
  68. package/dist/scan-comparison.js.map +1 -1
  69. package/dist/scan-dashboard.d.ts.map +1 -1
  70. package/dist/scan-dashboard.js +1 -0
  71. package/dist/scan-dashboard.js.map +1 -1
  72. package/dist/scan-history-renderer.d.ts +1 -1
  73. package/dist/scan-history-renderer.d.ts.map +1 -1
  74. package/dist/scan-history-renderer.js +10 -0
  75. package/dist/scan-history-renderer.js.map +1 -1
  76. package/dist/scan-logs.d.ts +17 -0
  77. package/dist/scan-logs.d.ts.map +1 -0
  78. package/dist/scan-logs.js +90 -0
  79. package/dist/scan-logs.js.map +1 -0
  80. package/dist/targets.d.ts +1 -0
  81. package/dist/targets.d.ts.map +1 -1
  82. package/dist/targets.js +22 -0
  83. package/dist/targets.js.map +1 -1
  84. package/dist/version.d.ts +1 -1
  85. package/dist/version.js +1 -1
  86. package/dist/version.js.map +1 -1
  87. package/package.json +2 -2
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, CodexSecurity, scanAuthentication, } from "./api.js";
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, redactedErrorMessage, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
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 { matchScanFindings, } from "./scan-comparison.js";
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";
@@ -79,6 +80,7 @@ const VALUE_OPTIONS = new Set([
79
80
  "--subagents",
80
81
  "--stop-after-no-new",
81
82
  "--max-discovery-runs",
83
+ "--max-time-hours",
82
84
  "--max-attempts",
83
85
  "--export-format",
84
86
  "--output",
@@ -130,6 +132,12 @@ const DEEP_SCAN_OPTION_SCHEMAS = {
130
132
  .positive()
131
133
  .optional()
132
134
  .describe("Maximum deep-scan discovery runs."),
135
+ maxTimeHours: z
136
+ .number()
137
+ .positive()
138
+ .max(96)
139
+ .optional()
140
+ .describe("Maximum deep-scan discovery hours (default: 96; maximum: 96)."),
133
141
  };
134
142
  async function readPromptFiles(directory, scanPromptFile, postScanPromptFile) {
135
143
  const [scanPrompt, postScanPrompt] = await Promise.all([
@@ -146,14 +154,14 @@ async function readPromptFiles(directory, scanPromptFile, postScanPromptFile) {
146
154
  };
147
155
  }
148
156
  const DEFAULT_DEPENDENCIES = {
149
- createSecurity: (config) => new CodexSecurity(config),
157
+ createSecurity: (config) => createSecurityInternal(config, { surface: "cli" }),
150
158
  environment: process.env,
151
159
  prepareAuthenticationHome: prepareCodexSecurityCredentialHome,
152
160
  checkForUpdate: () => checkForUpdate({ environment: process.env }),
153
161
  hasStoredChatGPTSignIn: async () => {
154
162
  const environment = Object.fromEntries(Object.entries(process.env).filter(([name]) => name.toUpperCase() !== "OPENAI_API_KEY" &&
155
163
  name.toUpperCase() !== "CODEX_API_KEY"));
156
- const command = resolveCodexCommand();
164
+ const command = resolveCodexCommand(environment);
157
165
  if (existsSync(codexSecurityCredentialHome(process.env))) {
158
166
  const dedicatedStatus = await accountStatus(command, {
159
167
  ...environment,
@@ -180,7 +188,7 @@ const DEFAULT_DEPENDENCIES = {
180
188
  writeSync(stream.fd, value);
181
189
  },
182
190
  forceExit: (signal) => process.kill(process.pid, signal),
183
- runCodex: (args, output, environment) => runCodexSkillCommand(args, output, resolveCodexCommand(), environment),
191
+ runCodex: (args, output, environment) => runCodexSkillCommand(args, output, resolveCodexCommand(environment), environment),
184
192
  exportFindings: async (arguments_, output) => {
185
193
  const environment = exportEnvironment();
186
194
  const python = await resolvePluginPython({
@@ -248,7 +256,7 @@ const DEFAULT_DEPENDENCIES = {
248
256
  failureMessage: "Could not read Codex Security scan history",
249
257
  }, args);
250
258
  },
251
- matchFindings: matchScanFindings,
259
+ matchFindings: (input, options) => matchScanFindingsInternal(input, options, { surface: "cli" }),
252
260
  };
253
261
  export async function runCodexSkillCommand(args, output, command = resolveCodexCommand(), processEnvironment = process.env) {
254
262
  const configuredHome = processEnvironment["CODEX_HOME"];
@@ -260,7 +268,7 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
260
268
  if (configuredHome?.trim()) {
261
269
  environment["CODEX_HOME"] = resolve(expandHome(configuredHome));
262
270
  }
263
- const invocation = spawn(command.command, [...command.prefixArgs, ...args], {
271
+ const invocation = spawn(command.command, [...args], {
264
272
  env: environment,
265
273
  cwd: parse(process.execPath).root,
266
274
  stdio: output === undefined ? "inherit" : ["ignore", "pipe", "pipe"],
@@ -447,7 +455,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
447
455
  return await select(await dependencies.runWorkbench(args));
448
456
  }
449
457
  catch (error) {
450
- errorOutput.write(`codex-security: ${redactedErrorMessage(error)}\n`);
458
+ errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
451
459
  exitCode = 2;
452
460
  return undefined;
453
461
  }
@@ -527,6 +535,27 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
527
535
  ]);
528
536
  },
529
537
  });
538
+ findingFeedback.command("list", {
539
+ description: "List open findings for a repository across its scans.",
540
+ mcp: false,
541
+ args: z.object({
542
+ repository: z
543
+ .string()
544
+ .optional()
545
+ .describe("Repository to inspect (default: current directory)."),
546
+ }),
547
+ output: z.record(z.string(), z.unknown()).optional(),
548
+ async run({ args, format }) {
549
+ const repository = resolve(dependencies.currentDirectory(), args.repository ?? ".");
550
+ return presentHistory(await history(["list-repositories"], async (value) => {
551
+ const target = value["repositories"].find((entry) => entry["targetPath"] === repository);
552
+ const findings = target === undefined
553
+ ? []
554
+ : await listRepositoryFindings(dependencies.runWorkbench, target["targetId"]);
555
+ return { repository, findings: findings ?? [] };
556
+ }), "findings", format, { repository });
557
+ },
558
+ });
530
559
  const scanHistory = Cli.create("scans", {
531
560
  description: "List, inspect, rerun, match, and compare saved Codex Security scans.",
532
561
  })
@@ -591,6 +620,31 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
591
620
  };
592
621
  }), "show", format, { showLinkedFindings: options.showLinkedFindings });
593
622
  },
623
+ })
624
+ .command("logs", {
625
+ description: "Show saved activity for a scan and its workers.",
626
+ mcp: false,
627
+ args: z.object({
628
+ scanId: z
629
+ .string()
630
+ .min(1)
631
+ .describe("Saved scan identifier or unique prefix."),
632
+ }),
633
+ output: z.record(z.string(), z.unknown()).optional(),
634
+ async run({ args }) {
635
+ return await history(["get-scan", "--scan-id", args.scanId], async (value) => {
636
+ const scan = value["scan"];
637
+ const threadId = scan.continuationThreadId;
638
+ if (!threadId) {
639
+ throw new CodexSecurityError(`No session is associated with scan ${scan.scanId}.`);
640
+ }
641
+ return (await readScanLogs({
642
+ scanId: scan.scanId,
643
+ threadId,
644
+ codexHome: codexSecurityCredentialHome(dependencies.environment),
645
+ }));
646
+ });
647
+ },
594
648
  })
595
649
  .command("rerun", {
596
650
  description: "Rerun a saved scan with its original configuration.",
@@ -618,7 +672,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
618
672
  scanArguments.verbose = options.verbose;
619
673
  }
620
674
  catch (error) {
621
- const message = redactedErrorMessage(error);
675
+ const message = errorMessage(error);
622
676
  errorOutput.write(`codex-security: ${message}\n`);
623
677
  exitCode = 2;
624
678
  return incurError({
@@ -674,7 +728,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
674
728
  return presentHistory(await matchScanPair(args.beforeId, args.afterId, options.force), "compare", format);
675
729
  }
676
730
  catch (error) {
677
- errorOutput.write(`codex-security: ${redactedErrorMessage(error)}\n`);
731
+ errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
678
732
  exitCode = 2;
679
733
  return undefined;
680
734
  }
@@ -720,7 +774,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
720
774
  verbose: z
721
775
  .boolean()
722
776
  .default(false)
723
- .describe("Print redacted scan diagnostics to stderr."),
777
+ .describe("Print scan diagnostics to stderr."),
724
778
  path: z
725
779
  .array(optionValue("--path"))
726
780
  .default([])
@@ -808,7 +862,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
808
862
  (options.workers === undefined &&
809
863
  options.subagents === undefined &&
810
864
  options.stopAfterNoNew === undefined &&
811
- options.maxDiscoveryRuns === undefined), { message: "Deep scan settings require --mode deep." }),
865
+ options.maxDiscoveryRuns === undefined &&
866
+ options.maxTimeHours === undefined), { message: "Deep scan settings require --mode deep." }),
812
867
  examples: [
813
868
  { args: { repository: "." } },
814
869
  { args: { repository: "." }, options: { model: "gpt-5.6-terra" } },
@@ -851,6 +906,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
851
906
  subagents: options.subagents,
852
907
  stopAfterNoNew: options.stopAfterNoNew,
853
908
  maxDiscoveryRuns: options.maxDiscoveryRuns,
909
+ maxTimeHours: options.maxTimeHours,
854
910
  model: options.model,
855
911
  effort: options.effort,
856
912
  provider: options.provider,
@@ -939,7 +995,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
939
995
  };
940
996
  }
941
997
  catch (error) {
942
- errorOutput.write(`codex-security: ${redactedErrorMessage(error)}\n`);
998
+ errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
943
999
  exitCode = 2;
944
1000
  return undefined;
945
1001
  }
@@ -1075,7 +1131,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1075
1131
  signal: controller.signal,
1076
1132
  onProgress: ({ repository, status, attempt, error, warning }) => {
1077
1133
  const detail = error ?? warning;
1078
- errorOutput.write(`codex-security: ${repository} ${status} (attempt ${attempt})${detail === undefined ? "" : `: ${redactedErrorMessage(detail)}`}\n`);
1134
+ errorOutput.write(`codex-security: ${repository} ${status} (attempt ${attempt})${detail === undefined ? "" : `: ${errorMessage(detail)}`}\n`);
1079
1135
  },
1080
1136
  });
1081
1137
  exitCode =
@@ -1089,7 +1145,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1089
1145
  (error instanceof Error && error.name === "ExitPromptError"
1090
1146
  ? 130
1091
1147
  : 2);
1092
- errorOutput.write(`codex-security: ${redactedErrorMessage(error)}\n`);
1148
+ errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
1093
1149
  }
1094
1150
  finally {
1095
1151
  dependencies.removeSignalListener("SIGINT", onInterrupt);
@@ -1165,7 +1221,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1165
1221
  }
1166
1222
  catch (error) {
1167
1223
  exitCode = 2;
1168
- errorOutput.write(`codex-security: ${redactedErrorMessage(error)}\n`);
1224
+ errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
1169
1225
  }
1170
1226
  },
1171
1227
  })
@@ -1192,7 +1248,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1192
1248
  }
1193
1249
  catch (error) {
1194
1250
  exitCode = 2;
1195
- errorOutput.write(`codex-security: ${redactedErrorMessage(error)}\n`);
1251
+ errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
1196
1252
  }
1197
1253
  },
1198
1254
  })
@@ -1341,7 +1397,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1341
1397
  if (frameworkExit !== undefined) {
1342
1398
  if (exitCode !== 0)
1343
1399
  return exitCode;
1344
- errorOutput.write(`codex-security: ${redactedErrorMessage(incurErrorMessage(frameworkOutput))}\n`);
1400
+ errorOutput.write(`codex-security: ${errorMessage(incurErrorMessage(frameworkOutput))}\n`);
1345
1401
  return 2;
1346
1402
  }
1347
1403
  if (frameworkOutput.length === 0)
@@ -1351,7 +1407,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1351
1407
  return exitCode;
1352
1408
  }
1353
1409
  catch (error) {
1354
- errorOutput.write(`codex-security: ${redactedErrorMessage(error)}\n`);
1410
+ errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
1355
1411
  return 2;
1356
1412
  }
1357
1413
  }
@@ -1726,6 +1782,8 @@ async function runSkill(skill, inputs, codexOverrides, effort, stdout, stderr, d
1726
1782
  `model_reasoning_effort=${JSON.stringify(reasoningEffort)}`,
1727
1783
  "--config",
1728
1784
  'approval_policy="never"',
1785
+ "--config",
1786
+ 'responses_api_metadata.codex_security_surface="cli"',
1729
1787
  "--sandbox",
1730
1788
  "workspace-write",
1731
1789
  "--skip-git-repo-check",
@@ -1872,14 +1930,12 @@ async function runExport(arguments_, output, errorOutput, dependencies) {
1872
1930
  return 0;
1873
1931
  }
1874
1932
  catch (error) {
1875
- errorOutput.write(`codex-security: ${redactedErrorMessage(error)}\n`);
1933
+ errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
1876
1934
  return 2;
1877
1935
  }
1878
1936
  }
1879
- function sanitizeDiagnosticValue(value) {
1880
- return redactedErrorMessage(value)
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, " ");
1937
+ function diagnosticValue(value) {
1938
+ return errorMessage(value).replaceAll(/[\u0000-\u001F\u007F\u0085\u2028\u2029]/gu, " ");
1883
1939
  }
1884
1940
  async function runScan(arguments_, errorOutput, dependencies, interactive = true) {
1885
1941
  let scanDir = null;
@@ -1911,7 +1967,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
1911
1967
  const attributes = Object.entries(fields).flatMap(([name, value]) => value === undefined
1912
1968
  ? []
1913
1969
  : [
1914
- `${name}=${JSON.stringify(typeof value === "string" ? sanitizeDiagnosticValue(value) : value)}`,
1970
+ `${name}=${JSON.stringify(typeof value === "string" ? diagnosticValue(value) : value)}`,
1915
1971
  ]);
1916
1972
  writeAboveProgress(() => {
1917
1973
  errorOutput.write(`codex-security: debug: ${event}${attributes.length === 0 ? "" : ` ${attributes.join(" ")}`}\n`);
@@ -2039,7 +2095,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2039
2095
  : { maxCostUsd: arguments_.maxCostUsd }),
2040
2096
  clock: dependencies,
2041
2097
  color: dependencies.environment["NO_COLOR"] === undefined,
2042
- sanitize: redactedErrorMessage,
2098
+ sanitize: safeErrorMessage,
2043
2099
  input: process.stdin,
2044
2100
  onInterrupt,
2045
2101
  });
@@ -2087,6 +2143,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2087
2143
  subagents: arguments_.subagents,
2088
2144
  stopAfterNoNew: arguments_.stopAfterNoNew,
2089
2145
  maxDiscoveryRuns: arguments_.maxDiscoveryRuns,
2146
+ maxTimeHours: arguments_.maxTimeHours,
2090
2147
  outputDir: arguments_.outputDir,
2091
2148
  archiveExisting: arguments_.archiveExisting,
2092
2149
  parentScanId: arguments_.parentScanId,
@@ -2128,11 +2185,11 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2128
2185
  onOutputArchived: (archiveDir) => {
2129
2186
  diagnostic("scan.output_archived", { archive_dir: archiveDir });
2130
2187
  if (dashboard !== null) {
2131
- dashboard.note(`Moved existing results to: ${redactedErrorMessage(archiveDir)}`);
2188
+ dashboard.note(`Moved existing results to: ${errorMessage(archiveDir)}`);
2132
2189
  return;
2133
2190
  }
2134
2191
  progress?.stopTimer();
2135
- errorOutput.write(`Moved existing results to: ${redactedErrorMessage(archiveDir)}\n`);
2192
+ errorOutput.write(`Moved existing results to: ${errorMessage(archiveDir)}\n`);
2136
2193
  },
2137
2194
  signal: preparationAbortController.signal,
2138
2195
  onOutputDirReady: (path) => {
@@ -2277,7 +2334,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2277
2334
  progress.startTimer(runningMessage());
2278
2335
  },
2279
2336
  onWarning: (warning, details) => {
2280
- const message = sanitizeDiagnosticValue(warning);
2337
+ const message = diagnosticValue(warning);
2281
2338
  if (details?.kind === "target_changed") {
2282
2339
  targetWarnings.push(message);
2283
2340
  }
@@ -2291,7 +2348,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2291
2348
  observer,
2292
2349
  classification: classifyConnectionFailure(error),
2293
2350
  });
2294
- const warning = `${observer} observer failed: ${sanitizeDiagnosticValue(error)}`;
2351
+ const warning = `${observer} observer failed: ${diagnosticValue(error)}`;
2295
2352
  if (dashboard === null) {
2296
2353
  writeAboveProgress(() => {
2297
2354
  errorOutput.write(`codex-security: warning: ${warning}\n`);
@@ -2346,7 +2403,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2346
2403
  if (failed) {
2347
2404
  const costLimitFailure = failure instanceof ScanCostLimitExceededError ? failure : undefined;
2348
2405
  const message = failure instanceof OutputInsideProtectedRootError
2349
- ? redactedErrorMessage(protectedRootErrorMessage(failure))
2406
+ ? errorMessage(protectedRootErrorMessage(failure))
2350
2407
  : scanFailureMessage(failure, selectedAuthentication);
2351
2408
  diagnostic("scan.failed", {
2352
2409
  classification: costLimitFailure !== undefined
@@ -2363,7 +2420,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
2363
2420
  return { exitCode: 2, error: message };
2364
2421
  }
2365
2422
  if (scanDir !== null) {
2366
- errorOutput.write(`Partial output was kept at ${redactedErrorMessage(scanDir)}.\n`);
2423
+ errorOutput.write(`Partial output was kept at ${errorMessage(scanDir)}.\n`);
2367
2424
  }
2368
2425
  return { exitCode: 2, error: message };
2369
2426
  }
@@ -2471,7 +2528,7 @@ function scanFailureMessage(error, authentication) {
2471
2528
  // errors can name the organization or project, which must not reach stderr or
2472
2529
  // the JSON error field.
2473
2530
  if (isLocalScanFailure(error))
2474
- return sanitizeDiagnosticValue(error);
2531
+ return diagnosticValue(error);
2475
2532
  switch (classifyConnectionFailure(error)) {
2476
2533
  case "unauthorized":
2477
2534
  if (authentication?.method === "aws_credentials") {
@@ -2499,7 +2556,7 @@ function scanFailureMessage(error, authentication) {
2499
2556
  case "network_error":
2500
2557
  case "timeout":
2501
2558
  case "unknown":
2502
- return sanitizeDiagnosticValue(error);
2559
+ return diagnosticValue(error);
2503
2560
  }
2504
2561
  }
2505
2562
  function scanScope(arguments_) {
@@ -2511,7 +2568,7 @@ function scanScope(arguments_) {
2511
2568
  portable.startsWith("//")
2512
2569
  ? portable.split("/").at(-1) ?? portable
2513
2570
  : portable;
2514
- return redactedErrorMessage(scoped.replaceAll(/[\u0000-\u001F\u007F]/gu, " "));
2571
+ return errorMessage(scoped.replaceAll(/[\u0000-\u001F\u007F]/gu, " "));
2515
2572
  });
2516
2573
  return `${displayed.join(", ")}${arguments_.paths.length > displayed.length ? `, +${arguments_.paths.length - displayed.length} more` : ""}`;
2517
2574
  }
@@ -2535,8 +2592,10 @@ function scanPhase(value) {
2535
2592
  }
2536
2593
  function printScanSummary(result, progress, errorOutput, color) {
2537
2594
  const paint = (value, code) => color ? `\u001B[${code}m${value}\u001B[0m` : value;
2595
+ const repositoryFindings = result.repositoryFindings;
2596
+ const findings = repositoryFindings ?? result.findings.findings;
2538
2597
  const severities = new Map();
2539
- for (const finding of result.findings.findings) {
2598
+ for (const finding of findings) {
2540
2599
  severities.set(finding.severity.level, (severities.get(finding.severity.level) ?? 0) + 1);
2541
2600
  }
2542
2601
  const severitySummary = DISPLAY_SEVERITIES.map((severity) => {
@@ -2555,7 +2614,12 @@ function printScanSummary(result, progress, errorOutput, color) {
2555
2614
  const duration = elapsed < 60
2556
2615
  ? `${elapsed}s`
2557
2616
  : `${Math.floor(elapsed / 60)}m ${elapsed % 60}s`;
2558
- const findingCount = result.findings.findings.length;
2617
+ const findingCount = findings.length;
2618
+ const confirmedCount = repositoryFindings?.filter((finding) => finding.confirmedInLatestScan)
2619
+ .length ?? 0;
2620
+ const findingSummary = repositoryFindings?.length
2621
+ ? `${confirmedCount} confirmed this scan; ${findingCount - confirmedCount} previously found; ${severitySummary}`
2622
+ : severitySummary;
2559
2623
  const findingColor = findingCount === 0
2560
2624
  ? 32
2561
2625
  : severities.has("critical") || severities.has("high")
@@ -2563,8 +2627,8 @@ function printScanSummary(result, progress, errorOutput, color) {
2563
2627
  : severities.has("medium")
2564
2628
  ? 33
2565
2629
  : 36;
2566
- errorOutput.write(`\n ${paint("REPORT", "1;36")} ${paint(redactedErrorMessage(result.reportPath), 4)}\n\n` +
2567
- ` ${paint("FINDINGS", 1)} ${paint(`${findingCount}${severitySummary === "" ? "" : ` (${severitySummary})`}`, findingColor)}\n` +
2630
+ errorOutput.write(`\n ${paint("REPORT", "1;36")} ${paint(errorMessage(result.reportPath), 4)}\n\n` +
2631
+ ` ${paint("FINDINGS", 1)} ${paint(`${findingCount}${findingSummary === "" ? "" : ` (${findingSummary})`}`, findingColor)}\n` +
2568
2632
  ` ${paint("COVERAGE", 1)} ${result.coverage.completeness}\n` +
2569
2633
  ` ${paint("ELAPSED", 1)} ${duration}\n`);
2570
2634
  const tokenSummary = formatTokenUsage(result.turnResult.usage);
@@ -2574,7 +2638,7 @@ function printScanSummary(result, progress, errorOutput, color) {
2574
2638
  if (result.cost !== null) {
2575
2639
  errorOutput.write(` ${paint("COST", 1)} ${formatUsd(result.cost.estimatedUsd)}\n`);
2576
2640
  }
2577
- errorOutput.write(` ${paint("RESULTS", 1)} ${redactedErrorMessage(result.scanDir)}\n`);
2641
+ errorOutput.write(` ${paint("RESULTS", 1)} ${errorMessage(result.scanDir)}\n`);
2578
2642
  }
2579
2643
  function formatTokenUsage(usage) {
2580
2644
  if (usage === null || typeof usage !== "object")
@@ -2844,7 +2908,7 @@ function interruptedExit(signal, scanDir, errorOutput) {
2844
2908
  errorOutput.write(`codex-security: Scan ${ctrlC ? "canceled by Ctrl-C" : "terminated by SIGTERM"}.\n`);
2845
2909
  errorOutput.write(scanDir === null
2846
2910
  ? "codex-security: No partial output was kept.\n"
2847
- : `codex-security: Partial output was kept at ${redactedErrorMessage(scanDir)}.\n`);
2911
+ : `codex-security: Partial output was kept at ${errorMessage(scanDir)}.\n`);
2848
2912
  return ctrlC ? 130 : 143;
2849
2913
  }
2850
2914
  function isJsonObject(value) {
@@ -2867,7 +2931,7 @@ if (invokedAsMain()) {
2867
2931
  void main().then((exitCode) => {
2868
2932
  process.exitCode = exitCode;
2869
2933
  }, (error) => {
2870
- process.stderr.write(`codex-security: ${redactedErrorMessage(error)}\n`);
2934
+ process.stderr.write(`codex-security: ${errorMessage(error)}\n`);
2871
2935
  process.exitCode = 2;
2872
2936
  });
2873
2937
  }