@openai/codex-security 0.1.17 → 0.1.19

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 (55) hide show
  1. package/README.md +127 -18
  2. package/_bundled_plugin/.mcp.json +1 -0
  3. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  4. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  5. package/_bundled_plugin/references/core-scan.md +1 -1
  6. package/_bundled_plugin/references/final-report.md +4 -2
  7. package/_bundled_plugin/references/scan-artifacts.md +1 -1
  8. package/_bundled_plugin/references/scan-contract.md +18 -7
  9. package/_bundled_plugin/schemas/scan-manifest.schema.json +2 -2
  10. package/_bundled_plugin/schemas/tools/scan-draft.schema.json +23 -0
  11. package/_bundled_plugin/scripts/deep_scan_workbench.py +88 -1
  12. package/_bundled_plugin/scripts/finalize_scan_contract.py +58 -18
  13. package/_bundled_plugin/scripts/report_projection.py +19 -8
  14. package/_bundled_plugin/scripts/workbench_cli.py +13 -0
  15. package/_bundled_plugin/scripts/workbench_db.py +149 -167
  16. package/_bundled_plugin/scripts/workbench_finding_index.py +101 -0
  17. package/_bundled_plugin/scripts/workbench_remediation.py +19 -0
  18. package/_bundled_plugin/scripts/workbench_saved_results.py +1289 -0
  19. package/_bundled_plugin/scripts/workbench_schema.py +28 -0
  20. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +4 -4
  21. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +1 -1
  22. package/_bundled_plugin/skills/security-scan/SKILL.md +1 -1
  23. package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +1 -1
  24. package/dist/api.d.ts +2 -0
  25. package/dist/api.d.ts.map +1 -1
  26. package/dist/api.js +54 -7
  27. package/dist/api.js.map +1 -1
  28. package/dist/cli.d.ts +2 -0
  29. package/dist/cli.d.ts.map +1 -1
  30. package/dist/cli.js +247 -25
  31. package/dist/cli.js.map +1 -1
  32. package/dist/cloud-publish.d.ts +16 -0
  33. package/dist/cloud-publish.d.ts.map +1 -0
  34. package/dist/cloud-publish.js +138 -0
  35. package/dist/cloud-publish.js.map +1 -0
  36. package/dist/contract.d.ts +1 -0
  37. package/dist/contract.d.ts.map +1 -1
  38. package/dist/contract.js +4 -0
  39. package/dist/contract.js.map +1 -1
  40. package/dist/custom-validation-prompt.js +3 -3
  41. package/dist/custom-validation-prompt.js.map +1 -1
  42. package/dist/linear.d.ts.map +1 -1
  43. package/dist/linear.js +17 -6
  44. package/dist/linear.js.map +1 -1
  45. package/dist/models.d.ts +1 -1
  46. package/dist/models.d.ts.map +1 -1
  47. package/dist/models.js.map +1 -1
  48. package/dist/publication.d.ts +1 -0
  49. package/dist/publication.d.ts.map +1 -1
  50. package/dist/publication.js +1 -0
  51. package/dist/publication.js.map +1 -1
  52. package/dist/publish.d.ts +1 -0
  53. package/dist/publish.d.ts.map +1 -1
  54. package/dist/publish.js.map +1 -1
  55. package/package.json +2 -2
package/dist/cli.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { CodexSecurity } from "./api.js";
3
+ import { publishScanToCloud } from "./cloud-publish.js";
3
4
  import { type BulkScanDiscoveryDependencies, type BulkScanPrompt } from "./bulk-scan-discovery.js";
4
5
  import { type CodexSecurityConfig, type ExternalModelProvider, type JsonObject } from "./config.js";
5
6
  import { type LinearClientFactory } from "./linear.js";
@@ -52,6 +53,7 @@ interface CliDependencies {
52
53
  scanAuthenticationPrompt?: Pick<BulkScanPrompt, "isInteractive" | "select">;
53
54
  publishPrompt?: Pick<BulkScanPrompt, "isInteractive" | "select">;
54
55
  publishScan?: typeof publishScan;
56
+ publishScanToCloud?: typeof publishScanToCloud;
55
57
  confirmPatchReview?: (question: string) => Promise<boolean>;
56
58
  patchEditor?: (repository: string, findings: readonly Finding[]) => Promise<PatchSelection | null>;
57
59
  currentDirectory(): string;
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts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AO;IAQpB,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,IAAW,cAAc,IAAI,MAAM,CAKlC;IAEM,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK5B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAiBjC,SAAS,IAAI,IAAI;IAwCjB,eAAe,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI;CAoChD"}
package/dist/cli.js CHANGED
@@ -13,6 +13,7 @@ import { Cli, z } from "incur";
13
13
  import { parse as parseToml } from "smol-toml";
14
14
  import { classifyConnectionFailure, createSecurityInternal, listRepositoryFindings, SCAN_AUTH_MODES, scanAuthentication, } from "./api.js";
15
15
  import { accountStatus } from "./auth.js";
16
+ import { publishScanToCloud, } from "./cloud-publish.js";
16
17
  import { createBulkScanDiscoveryDependencies, runBulkScanWizard, } from "./bulk-scan-discovery.js";
17
18
  import { DEFAULT_CODEX_CONFIG, EXTERNAL_CODEX_PROVIDERS, isExternalModelProvider, mergedCodexConfig, scanModelConfiguration, scanModelProvider, } from "./config.js";
18
19
  import { formatUsd } from "./cost.js";
@@ -72,6 +73,7 @@ const EXPORT_DEFAULT_OUTPUTS = {
72
73
  };
73
74
  const VALUE_OPTIONS = new Set([
74
75
  "--auth",
76
+ "--safety-identifier",
75
77
  "--path",
76
78
  "--component",
77
79
  "--components-file",
@@ -97,6 +99,7 @@ const VALUE_OPTIONS = new Set([
97
99
  "--patch-severity",
98
100
  "--resume-pr",
99
101
  "--scan",
102
+ "--scan-dir",
100
103
  "--severity",
101
104
  "--max-cost",
102
105
  "--workers",
@@ -1328,7 +1331,21 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1328
1331
  .describe("Completed scan directory; omit to select a saved scan."),
1329
1332
  }),
1330
1333
  options: z.object({
1331
- to: z.literal("linear").describe("Publication destination."),
1334
+ scan: z
1335
+ .array(optionValue("--scan"))
1336
+ .default([])
1337
+ .describe("Saved scan ID, unique prefix, or latest; repeat for multiple scans (Linear accepts one)."),
1338
+ scanDir: z
1339
+ .array(optionValue("--scan-dir"))
1340
+ .default([])
1341
+ .describe("External completed scan directory; repeat for multiple scans (Linear accepts one)."),
1342
+ // Cloud remains an internal destination, omitted from public discovery.
1343
+ to: z
1344
+ .string()
1345
+ .refine((value) => value === "linear" || value === "cloud", {
1346
+ message: "Unsupported publication destination. Use --to linear.",
1347
+ })
1348
+ .describe("Publication destination (linear)."),
1332
1349
  linearTeam: optionValue("--linear-team")
1333
1350
  .optional()
1334
1351
  .describe("Linear team ID; defaults to CODEX_SECURITY_LINEAR_TEAM."),
@@ -1352,15 +1369,58 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1352
1369
  async run({ args, format, formatExplicit, options }) {
1353
1370
  const controller = new AbortController();
1354
1371
  let presentation;
1372
+ let cloudBatch;
1355
1373
  const cancel = (signal) => {
1356
1374
  presentation?.stop();
1357
1375
  controller.abort(signal);
1358
1376
  };
1377
+ const finishCancellation = (error) => {
1378
+ const signal = controller.signal.reason;
1379
+ if (signal !== "SIGINT" && signal !== "SIGTERM")
1380
+ return false;
1381
+ const reason = signal === "SIGINT"
1382
+ ? "Publication canceled by Ctrl-C."
1383
+ : "Publication terminated by SIGTERM.";
1384
+ const recovery = error === undefined || error === signal
1385
+ ? ""
1386
+ : ` ${diagnosticValue(safeErrorMessage(error))}`;
1387
+ errorOutput.write(`codex-security: ${reason}${recovery}\n`);
1388
+ exitCode = signal === "SIGINT" ? 130 : 143;
1389
+ return true;
1390
+ };
1359
1391
  const onInterrupt = () => cancel("SIGINT");
1360
1392
  const onTerminate = () => cancel("SIGTERM");
1361
1393
  let observingSignals = false;
1362
1394
  try {
1363
- const linearApiKey = resolveLinearApiKey(dependencies.environment, options.linearApiKey);
1395
+ const currentDirectory = dependencies.currentDirectory();
1396
+ const directories = [
1397
+ ...new Set([
1398
+ ...(args.scanDir === undefined ? [] : [args.scanDir]),
1399
+ ...options.scanDir,
1400
+ ].map((directory) => resolveCliPath(currentDirectory, directory))),
1401
+ ];
1402
+ if (directories.length > 1 && options.to !== "cloud") {
1403
+ throw new CodexSecurityError("Multiple scan directories are only supported with --to cloud.");
1404
+ }
1405
+ if (options.scan.length > 0 && directories.length > 0) {
1406
+ throw new CodexSecurityError("Use --scan or scan directory inputs, not both.");
1407
+ }
1408
+ if (new Set(options.scan).size > 1 && options.to !== "cloud") {
1409
+ throw new CodexSecurityError("Multiple scans are only supported with --to cloud.");
1410
+ }
1411
+ if (options.to === "cloud" &&
1412
+ [
1413
+ options.linearTeam,
1414
+ options.linearApiKey,
1415
+ options.linearProject,
1416
+ options.project,
1417
+ options.linearAssignee,
1418
+ ].some((value) => value !== undefined)) {
1419
+ throw new CodexSecurityError("Cloud publication cannot be combined with Linear options.");
1420
+ }
1421
+ const linearApiKey = options.to === "linear"
1422
+ ? resolveLinearApiKey(dependencies.environment, options.linearApiKey)
1423
+ : undefined;
1364
1424
  const assigneeId = options.linearAssignee?.trim();
1365
1425
  if (options.linearAssignee !== undefined && !assigneeId) {
1366
1426
  throw new CodexSecurityError("--linear-assignee must not be empty.");
@@ -1369,8 +1429,9 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1369
1429
  throw new CodexSecurityError("--linear-assignee requires --linear-api-key or CODEX_SECURITY_LINEAR_API_KEY.");
1370
1430
  }
1371
1431
  const teamId = options.linearTeam?.trim() ||
1372
- dependencies.environment["CODEX_SECURITY_LINEAR_TEAM"]?.trim();
1373
- if (!teamId) {
1432
+ dependencies.environment["CODEX_SECURITY_LINEAR_TEAM"]?.trim() ||
1433
+ "";
1434
+ if (options.to === "linear" && !teamId) {
1374
1435
  throw new CodexSecurityError("--linear-team or CODEX_SECURITY_LINEAR_TEAM is required.");
1375
1436
  }
1376
1437
  if (options.linearProject !== undefined &&
@@ -1386,7 +1447,20 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1386
1447
  const projectId = selectedProject ||
1387
1448
  dependencies.environment["CODEX_SECURITY_LINEAR_PROJECT"]?.trim() ||
1388
1449
  undefined;
1389
- let scanDir = args.scanDir;
1450
+ if (options.to === "cloud") {
1451
+ dependencies.addSignalListener("SIGINT", onInterrupt);
1452
+ dependencies.addSignalListener("SIGTERM", onTerminate);
1453
+ observingSignals = true;
1454
+ }
1455
+ const selectedScans = directories.map((scanDir) => ({ scanDir }));
1456
+ for (const requestedId of new Set(options.scan)) {
1457
+ controller.signal.throwIfAborted();
1458
+ const scan = await resolvePublicationScan(requestedId, dependencies);
1459
+ if (!selectedScans.some(({ scanId }) => scanId === scan.scanId)) {
1460
+ selectedScans.push(scan);
1461
+ }
1462
+ }
1463
+ let scanDir = selectedScans[0]?.scanDir;
1390
1464
  let publicationRepository = scanDir === undefined ? "scan" : basename(scanDir);
1391
1465
  if (scanDir === undefined) {
1392
1466
  const prompt = dependencies.publishPrompt ??
@@ -1396,7 +1470,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1396
1470
  currentDirectory: dependencies.currentDirectory,
1397
1471
  }).prompt;
1398
1472
  if (!prompt.isInteractive()) {
1399
- throw new CodexSecurityError("Interactive scan selection requires a terminal. Provide a completed scan directory: codex-security publish scan /path/to/sealed-scan --to linear --linear-team TEAM_ID.");
1473
+ throw new CodexSecurityError(`Interactive scan selection requires a terminal. Select a saved scan: codex-security publish scan --scan SCAN_ID --to ${options.to}${options.to === "linear" ? " --linear-team TEAM_ID" : ""}.`);
1400
1474
  }
1401
1475
  const saved = await dependencies.runWorkbench([
1402
1476
  "list-scans",
@@ -1414,7 +1488,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1414
1488
  if (typeof directory !== "string" || directory.length === 0) {
1415
1489
  return undefined;
1416
1490
  }
1417
- const metadata = await lstat(resolve(dependencies.currentDirectory(), directory)).catch(() => undefined);
1491
+ const metadata = await lstat(resolveCliPath(currentDirectory, directory)).catch(() => undefined);
1418
1492
  return metadata?.isDirectory() === true &&
1419
1493
  !metadata.isSymbolicLink()
1420
1494
  ? scan
@@ -1425,6 +1499,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1425
1499
  dependencies.environment["NO_COLOR"] === undefined &&
1426
1500
  dependencies.environment["TERM"] !== "dumb";
1427
1501
  const repositories = new Map();
1502
+ const scansById = new Map();
1428
1503
  const rows = scans.flatMap((scan) => {
1429
1504
  if (!isJsonObject(scan))
1430
1505
  return [];
@@ -1469,13 +1544,17 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1469
1544
  .replace(/\s+/gu, " ")
1470
1545
  .slice(-6)}`;
1471
1546
  repositories.set(directory, repository);
1547
+ scansById.set(scanId, {
1548
+ scanId,
1549
+ scanDir: resolveCliPath(currentDirectory, directory),
1550
+ });
1472
1551
  return [
1473
1552
  {
1474
1553
  repository,
1475
1554
  findings,
1476
1555
  age: publicationScanAge(timestamp, now),
1477
1556
  scanId: shortScanId,
1478
- value: directory,
1557
+ value: options.to === "cloud" ? scanId : directory,
1479
1558
  },
1480
1559
  ];
1481
1560
  });
@@ -1506,10 +1585,100 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1506
1585
  value: row.value,
1507
1586
  };
1508
1587
  });
1509
- scanDir = await prompt.select("Which completed scan would you like to publish?", choices, { header });
1588
+ if (options.to === "cloud") {
1589
+ let remaining = choices;
1590
+ while (true) {
1591
+ controller.signal.throwIfAborted();
1592
+ const selected = await prompt.select("Which completed scans would you like to publish?", selectedScans.length === 0
1593
+ ? remaining
1594
+ : [
1595
+ {
1596
+ label: `Done (${selectedScans.length} selected)`,
1597
+ value: "",
1598
+ },
1599
+ ...remaining,
1600
+ ], { header }, controller.signal);
1601
+ controller.signal.throwIfAborted();
1602
+ if (selected === "")
1603
+ break;
1604
+ selectedScans.push(scansById.get(selected));
1605
+ remaining = remaining.filter(({ value }) => value !== selected);
1606
+ }
1607
+ scanDir = selectedScans[0].scanDir;
1608
+ }
1609
+ else {
1610
+ scanDir = await prompt.select("Which completed scan would you like to publish?", choices, { header });
1611
+ selectedScans.push({ scanDir });
1612
+ }
1510
1613
  publicationRepository =
1511
1614
  repositories.get(scanDir) ?? basename(scanDir);
1512
1615
  }
1616
+ if (options.to === "cloud") {
1617
+ const seenDirectories = new Set();
1618
+ for (let index = 0; index < selectedScans.length;) {
1619
+ const selected = selectedScans[index];
1620
+ const canonical = await realpath(selected.scanDir).catch(() => selected.scanDir);
1621
+ const identity = process.platform === "win32"
1622
+ ? canonical.toLowerCase()
1623
+ : canonical;
1624
+ if (seenDirectories.has(identity)) {
1625
+ selectedScans.splice(index, 1);
1626
+ continue;
1627
+ }
1628
+ seenDirectories.add(identity);
1629
+ selected.scanDir = canonical;
1630
+ index++;
1631
+ }
1632
+ scanDir = selectedScans[0].scanDir;
1633
+ controller.signal.throwIfAborted();
1634
+ if (selectedScans.length > 1) {
1635
+ cloudBatch = {
1636
+ results: [],
1637
+ failed: [],
1638
+ notAttempted: selectedScans.map(({ scanId, scanDir }) => scanId ?? scanDir),
1639
+ };
1640
+ // Keep each scan's provenance and acceptance receipt separate. Never
1641
+ // retry a failed POST: a lost response may still have been accepted.
1642
+ for (const { scanDir: directory, scanId } of selectedScans) {
1643
+ if (controller.signal.aborted) {
1644
+ finishCancellation();
1645
+ break;
1646
+ }
1647
+ cloudBatch.notAttempted.shift();
1648
+ try {
1649
+ const result = await (dependencies.publishScanToCloud ?? publishScanToCloud)(directory, {
1650
+ environment: dependencies.environment,
1651
+ dryRun: options.dryRun,
1652
+ signal: controller.signal,
1653
+ ...(scanId === undefined ? {} : { expectedScanId: scanId }),
1654
+ });
1655
+ cloudBatch.results.push({ scanDir: directory, ...result });
1656
+ }
1657
+ catch (error) {
1658
+ const message = safeErrorMessage(error);
1659
+ cloudBatch.failed.push({
1660
+ scanDir: directory,
1661
+ ...(scanId === undefined ? {} : { scanId }),
1662
+ error: message,
1663
+ });
1664
+ if (controller.signal.aborted)
1665
+ throw error;
1666
+ exitCode = 2;
1667
+ errorOutput.write(`codex-security: ${diagnosticValue(safeErrorMessage(scanId ?? directory))}: ${diagnosticValue(message)}\n`);
1668
+ }
1669
+ }
1670
+ return cloudBatch;
1671
+ }
1672
+ const result = await (dependencies.publishScanToCloud ?? publishScanToCloud)(resolveCliPath(currentDirectory, scanDir), {
1673
+ environment: dependencies.environment,
1674
+ dryRun: options.dryRun,
1675
+ signal: controller.signal,
1676
+ ...(selectedScans[0]?.scanId === undefined
1677
+ ? {}
1678
+ : { expectedScanId: selectedScans[0].scanId }),
1679
+ });
1680
+ return { ...result };
1681
+ }
1513
1682
  const progress = new PublicationProgressPresenter(errorOutput, dependencies, publicationRepository);
1514
1683
  presentation = progress;
1515
1684
  if (!options.dryRun) {
@@ -1520,8 +1689,11 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1520
1689
  }
1521
1690
  let result;
1522
1691
  try {
1523
- result = await (dependencies.publishScan ?? publishScan)(resolve(dependencies.currentDirectory(), scanDir), {
1524
- destination: options.to,
1692
+ result = await (dependencies.publishScan ?? publishScan)(resolveCliPath(currentDirectory, scanDir), {
1693
+ destination: "linear",
1694
+ ...(selectedScans[0]?.scanId === undefined
1695
+ ? {}
1696
+ : { expectedScanId: selectedScans[0].scanId }),
1525
1697
  teamId,
1526
1698
  ...(projectId === undefined ? {} : { projectId }),
1527
1699
  dryRun: options.dryRun,
@@ -1559,22 +1731,11 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1559
1731
  return { ...result };
1560
1732
  }
1561
1733
  catch (error) {
1562
- const signal = controller.signal.reason;
1563
- if (signal === "SIGINT" || signal === "SIGTERM") {
1564
- const reason = signal === "SIGINT"
1565
- ? "Publication canceled by Ctrl-C."
1566
- : "Publication terminated by SIGTERM.";
1567
- const recovery = error === signal
1568
- ? ""
1569
- : ` ${diagnosticValue(safeErrorMessage(error))}`;
1570
- errorOutput.write(`codex-security: ${reason}${recovery}\n`);
1571
- exitCode = signal === "SIGINT" ? 130 : 143;
1572
- }
1573
- else {
1574
- errorOutput.write(`codex-security: ${errorMessage(error)}\n`);
1734
+ if (!finishCancellation(error)) {
1735
+ errorOutput.write(`codex-security: ${options.to === "cloud" ? safeErrorMessage(error) : errorMessage(error)}\n`);
1575
1736
  exitCode = 2;
1576
1737
  }
1577
- return undefined;
1738
+ return cloudBatch;
1578
1739
  }
1579
1740
  finally {
1580
1741
  if (observingSignals) {
@@ -1612,6 +1773,9 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1612
1773
  .boolean()
1613
1774
  .default(false)
1614
1775
  .describe("Print scan diagnostics to stderr."),
1776
+ safetyIdentifier: optionValue("--safety-identifier")
1777
+ .optional()
1778
+ .describe("Stable hashed end-user ID for this scan's model requests (1–64 characters)."),
1615
1779
  path: z
1616
1780
  .array(optionValue("--path"))
1617
1781
  .default([])
@@ -1749,6 +1913,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
1749
1913
  }
1750
1914
  const outcome = await runScan({
1751
1915
  auth: options.auth,
1916
+ safetyIdentifier: options.safetyIdentifier,
1752
1917
  verbose: options.verbose,
1753
1918
  repository: args.repository,
1754
1919
  paths: options.path,
@@ -3084,6 +3249,55 @@ async function* workbenchFindings(arguments_, dependencies) {
3084
3249
  offset = typeof page.nextOffset === "number" ? page.nextOffset : undefined;
3085
3250
  } while (offset !== undefined);
3086
3251
  }
3252
+ async function resolvePublicationScan(requestedId, dependencies) {
3253
+ let scanId = requestedId;
3254
+ if (scanId === "latest") {
3255
+ const history = await dependencies.runWorkbench([
3256
+ "list-scans",
3257
+ "--repository",
3258
+ resolve(dependencies.currentDirectory()),
3259
+ "--status",
3260
+ "complete",
3261
+ ]);
3262
+ const scans = history["scans"];
3263
+ const latest = Array.isArray(scans) ? scans[0] : undefined;
3264
+ if (latest === undefined ||
3265
+ !isJsonObject(latest) ||
3266
+ typeof latest["scanId"] !== "string") {
3267
+ throw new CodexSecurityError("No completed saved scan was found for this repository.");
3268
+ }
3269
+ scanId = latest["scanId"];
3270
+ }
3271
+ const context = await dependencies.runWorkbench([
3272
+ "get-scan",
3273
+ "--scan-id",
3274
+ scanId,
3275
+ ]);
3276
+ const scan = context["scan"];
3277
+ if (scan === undefined ||
3278
+ !isJsonObject(scan) ||
3279
+ typeof scan["scanId"] !== "string") {
3280
+ throw new CodexSecurityError(`Could not read saved scan ${scanId}.`);
3281
+ }
3282
+ scanId = scan["scanId"];
3283
+ const progress = scan["progress"];
3284
+ if (progress === undefined ||
3285
+ !isJsonObject(progress) ||
3286
+ progress["status"] !== "complete") {
3287
+ throw new CodexSecurityError(`Scan ${scanId} is not complete.`);
3288
+ }
3289
+ const storedDirectory = scan["scanDir"];
3290
+ const scanDir = typeof storedDirectory === "string" && storedDirectory.length > 0
3291
+ ? resolveCliPath(dependencies.currentDirectory(), storedDirectory)
3292
+ : undefined;
3293
+ const metadata = scanDir === undefined
3294
+ ? undefined
3295
+ : await lstat(scanDir).catch(() => undefined);
3296
+ if (scanDir === undefined || metadata?.isDirectory() !== true) {
3297
+ throw new CodexSecurityError(`Artifacts for scan ${scanId} are unavailable. Restore the completed scan artifacts or run a new scan.`);
3298
+ }
3299
+ return { ...scan, scanId, scanDir };
3300
+ }
3087
3301
  async function selectSavedFindings(identifiers, requestedScanId, severity, dependencies) {
3088
3302
  if (identifiers.some((identifier) => !isFindingIdentifier(identifier))) {
3089
3303
  throw new CodexSecurityError("Saved scan patching accepts only finding identifiers.");
@@ -3448,6 +3662,12 @@ async function runSkill(skill, inputs, codexOverrides, effort, stdout, stderr, d
3448
3662
  ...(verify ? ["--config", 'approvals_reviewer="auto_review"'] : []),
3449
3663
  "--config",
3450
3664
  'responses_api_metadata.codex_security_surface="cli"',
3665
+ ...(options.safetyIdentifier === undefined
3666
+ ? []
3667
+ : [
3668
+ "--config",
3669
+ `safety_identifier=${JSON.stringify(options.safetyIdentifier)}`,
3670
+ ]),
3451
3671
  ...(appServer
3452
3672
  ? []
3453
3673
  : [
@@ -4052,6 +4272,7 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
4052
4272
  security = dependencies.createSecurity(config);
4053
4273
  const options = {
4054
4274
  auth,
4275
+ safetyIdentifier: arguments_.safetyIdentifier,
4055
4276
  target,
4056
4277
  knowledgeBasePaths: arguments_.knowledgeBasePaths,
4057
4278
  ...prompts,
@@ -4459,6 +4680,7 @@ async function executeScan(arguments_, errorOutput, dependencies, interactive =
4459
4680
  try {
4460
4681
  patches = await runFindingPatches(selected, [`model=${JSON.stringify(effectiveModel)}`], effectiveReasoningEffort, errorOutput, dependencies, {
4461
4682
  ...providerOptions,
4683
+ safetyIdentifier: arguments_.safetyIdentifier,
4462
4684
  environment,
4463
4685
  findingInstructions: patchSelection?.instructions,
4464
4686
  });