@openai/codex-security 0.7.0 → 0.8.0

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 (153) hide show
  1. package/README.md +10 -4
  2. package/_bundled_plugin/examples/completed-scan/findings.json +34 -34
  3. package/_bundled_plugin/examples/completed-scan/report.md +22 -31
  4. package/_bundled_plugin/examples/completed-scan/scan-manifest.json +27 -29
  5. package/_bundled_plugin/examples/{completed-scan → legacy-completed-scan}/coverage.json +1 -0
  6. package/_bundled_plugin/examples/legacy-completed-scan/findings.json +57 -0
  7. package/_bundled_plugin/examples/legacy-completed-scan/report.md +98 -0
  8. package/_bundled_plugin/examples/legacy-completed-scan/scan-manifest.json +43 -0
  9. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  10. package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
  11. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  12. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  13. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  14. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  15. package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
  16. package/_bundled_plugin/references/core-scan.md +2 -2
  17. package/_bundled_plugin/references/final-report.md +16 -6
  18. package/_bundled_plugin/references/scan-artifacts.md +5 -5
  19. package/_bundled_plugin/references/scan-contract.md +10 -12
  20. package/_bundled_plugin/references/threat-model.md +1 -1
  21. package/_bundled_plugin/schemas/scan-manifest.schema.json +36 -11
  22. package/_bundled_plugin/schemas/tools/scan-draft.schema.json +5 -5
  23. package/_bundled_plugin/scripts/deep_scan_workbench.py +1 -1
  24. package/_bundled_plugin/scripts/finalize_scan_contract.py +60 -19
  25. package/_bundled_plugin/scripts/report_projection.py +5 -2
  26. package/_bundled_plugin/scripts/review_state.py +68 -0
  27. package/_bundled_plugin/scripts/validate_scan_contract.py +1 -2
  28. package/_bundled_plugin/scripts/workbench/retained_coverage.py +49 -37
  29. package/_bundled_plugin/scripts/workbench/retained_records.py +7 -7
  30. package/_bundled_plugin/scripts/workbench/saved_coverage.py +15 -15
  31. package/_bundled_plugin/scripts/workbench/saved_sources.py +24 -6
  32. package/_bundled_plugin/scripts/workbench_constants.py +0 -1
  33. package/_bundled_plugin/scripts/workbench_coverage_receipts.py +4 -4
  34. package/_bundled_plugin/scripts/workbench_db.py +5 -150
  35. package/_bundled_plugin/scripts/workbench_saved_results.py +169 -4
  36. package/_bundled_plugin/scripts/workbench_scan_history.py +12 -7
  37. package/_bundled_plugin/skills/publish-findings/SKILL.md +5 -1
  38. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +1 -1
  39. package/_bundled_plugin/skills/security-scan/SKILL.md +6 -6
  40. package/_bundled_plugin/skills/track-findings/SKILL.md +1 -1
  41. package/dist/api.d.ts.map +1 -1
  42. package/dist/api.js +19 -17
  43. package/dist/api.js.map +1 -1
  44. package/dist/cli.d.ts.map +1 -1
  45. package/dist/cli.js +28 -17
  46. package/dist/cli.js.map +1 -1
  47. package/dist/cloud-publish.d.ts.map +1 -1
  48. package/dist/cloud-publish.js +2 -23
  49. package/dist/cloud-publish.js.map +1 -1
  50. package/dist/contract.d.ts +3 -2
  51. package/dist/contract.d.ts.map +1 -1
  52. package/dist/contract.js +28 -14
  53. package/dist/contract.js.map +1 -1
  54. package/dist/custom-publish.js +2 -2
  55. package/dist/custom-publish.js.map +1 -1
  56. package/dist/custom-validation-prompt.js +5 -5
  57. package/dist/custom-validation-prompt.js.map +1 -1
  58. package/dist/custom-validation.d.ts.map +1 -1
  59. package/dist/custom-validation.js +17 -15
  60. package/dist/custom-validation.js.map +1 -1
  61. package/dist/deduplication/codex-review.d.ts.map +1 -1
  62. package/dist/deduplication/codex-review.js +2 -2
  63. package/dist/deduplication/codex-review.js.map +1 -1
  64. package/dist/deduplication/deduplication-prompts.d.ts +1 -0
  65. package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
  66. package/dist/deduplication/deduplication-prompts.js +3 -0
  67. package/dist/deduplication/deduplication-prompts.js.map +1 -1
  68. package/dist/deduplication/records-protocol.d.ts.map +1 -1
  69. package/dist/deduplication/records-protocol.js +21 -1
  70. package/dist/deduplication/records-protocol.js.map +1 -1
  71. package/dist/deduplication/scan.d.ts.map +1 -1
  72. package/dist/deduplication/scan.js +2 -2
  73. package/dist/deduplication/scan.js.map +1 -1
  74. package/dist/external-findings-local.d.ts +1 -0
  75. package/dist/external-findings-local.d.ts.map +1 -1
  76. package/dist/external-findings-local.js +6 -2
  77. package/dist/external-findings-local.js.map +1 -1
  78. package/dist/external-findings-publish.d.ts +1 -0
  79. package/dist/external-findings-publish.d.ts.map +1 -1
  80. package/dist/external-findings-publish.js +53 -25
  81. package/dist/external-findings-publish.js.map +1 -1
  82. package/dist/external-findings-read.d.ts +1 -0
  83. package/dist/external-findings-read.d.ts.map +1 -1
  84. package/dist/external-findings-read.js +10 -0
  85. package/dist/external-findings-read.js.map +1 -1
  86. package/dist/external-findings.d.ts +2 -0
  87. package/dist/external-findings.d.ts.map +1 -1
  88. package/dist/external-findings.js.map +1 -1
  89. package/dist/external-import-contract.d.ts +4 -0
  90. package/dist/external-import-contract.d.ts.map +1 -1
  91. package/dist/external-import-contract.js +34 -10
  92. package/dist/external-import-contract.js.map +1 -1
  93. package/dist/finding-workflow.d.ts +2 -0
  94. package/dist/finding-workflow.d.ts.map +1 -1
  95. package/dist/finding-workflow.js +3 -0
  96. package/dist/finding-workflow.js.map +1 -1
  97. package/dist/host-protocol.d.ts +1 -1
  98. package/dist/host-protocol.d.ts.map +1 -1
  99. package/dist/host-protocol.js +2 -2
  100. package/dist/host-protocol.js.map +1 -1
  101. package/dist/hosted-scan.d.ts.map +1 -1
  102. package/dist/hosted-scan.js +0 -1
  103. package/dist/hosted-scan.js.map +1 -1
  104. package/dist/import-scan.js +16 -16
  105. package/dist/import-scan.js.map +1 -1
  106. package/dist/index.d.ts +1 -0
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +1 -0
  109. package/dist/index.js.map +1 -1
  110. package/dist/knowledge-base.js +3 -0
  111. package/dist/knowledge-base.js.map +1 -1
  112. package/dist/mock-scan.d.ts +1 -2
  113. package/dist/mock-scan.d.ts.map +1 -1
  114. package/dist/mock-scan.js +12 -17
  115. package/dist/mock-scan.js.map +1 -1
  116. package/dist/models.d.ts +9 -1
  117. package/dist/models.d.ts.map +1 -1
  118. package/dist/models.js.map +1 -1
  119. package/dist/multiscan.d.ts.map +1 -1
  120. package/dist/multiscan.js +1 -6
  121. package/dist/multiscan.js.map +1 -1
  122. package/dist/native-json-findings.d.ts +30 -0
  123. package/dist/native-json-findings.d.ts.map +1 -0
  124. package/dist/native-json-findings.js +114 -0
  125. package/dist/native-json-findings.js.map +1 -0
  126. package/dist/opengrep-findings.d.ts +10 -0
  127. package/dist/opengrep-findings.d.ts.map +1 -0
  128. package/dist/opengrep-findings.js +198 -0
  129. package/dist/opengrep-findings.js.map +1 -0
  130. package/dist/patch-tui.d.ts.map +1 -1
  131. package/dist/patch-tui.js +2 -0
  132. package/dist/patch-tui.js.map +1 -1
  133. package/dist/publication.js +1 -2
  134. package/dist/publication.js.map +1 -1
  135. package/dist/record.d.ts +1 -0
  136. package/dist/record.d.ts.map +1 -1
  137. package/dist/record.js +10 -0
  138. package/dist/record.js.map +1 -1
  139. package/dist/result.d.ts +5 -3
  140. package/dist/result.d.ts.map +1 -1
  141. package/dist/result.js +9 -6
  142. package/dist/result.js.map +1 -1
  143. package/dist/scan-history-renderer.js +1 -1
  144. package/dist/scan-history-renderer.js.map +1 -1
  145. package/dist/security-policy.d.ts.map +1 -1
  146. package/dist/security-policy.js +16 -2
  147. package/dist/security-policy.js.map +1 -1
  148. package/dist/semgrep-findings.d.ts.map +1 -1
  149. package/dist/semgrep-findings.js +15 -82
  150. package/dist/semgrep-findings.js.map +1 -1
  151. package/docs/cli.md +16 -3
  152. package/docs/dedupe-records.md +15 -1
  153. package/package.json +3 -3
package/dist/api.js CHANGED
@@ -43,7 +43,7 @@ import { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, In
43
43
  import { forwardExternalImportSetting } from "./external-imports-feature.js";
44
44
  import { knowledgeBaseProtectedRoots, prepareKnowledgeBase, readKnowledgeBaseSnapshot, } from "./knowledge-base.js";
45
45
  import { scanInputIdentity, saveScanKnowledge } from "./scan-inputs.js";
46
- import { FindingWorkflow, workflowDigest } from "./finding-workflow.js";
46
+ import { FindingWorkflow, scanArtifactDigest, workflowDigest, } from "./finding-workflow.js";
47
47
  import { reviewSqliteHome } from "./deduplication/codex-review.js";
48
48
  import { ScanResult, } from "./result.js";
49
49
  import { formatSecurityPolicyText, inspectSecurityPolicySources, readSecurityPolicySnapshot, requireUnchangedSecurityPolicy, resolveSecurityPolicyGuidance, resolveSecurityPolicyTarget, runSecurityPolicyStages, parseSecurityPolicyStageResult, securityPolicyDiff, securityPolicyProtectedRoots, requireSecurityPolicyRepositoryBinding, securityPolicyStageOutputSchema, } from "./security-policy.js";
@@ -219,7 +219,7 @@ export class CodexSecurity {
219
219
  expectedScanId: state.scanId,
220
220
  signal,
221
221
  });
222
- await workflow.bind({ artifactDigest: workflowDigest(contract) });
222
+ await workflow.bind({ artifactDigest: scanArtifactDigest(contract) });
223
223
  metadata ??= { threadId: "", turnResult: { status: "completed" } };
224
224
  await workflow.complete("scan", metadata);
225
225
  return new ScanResult({
@@ -250,11 +250,7 @@ export class CodexSecurity {
250
250
  await workflow.bind({
251
251
  scanId: result.manifest.scan.id,
252
252
  scanDir: result.scanDir,
253
- artifactDigest: workflowDigest({
254
- manifest: result.manifest,
255
- findings: result.findings,
256
- coverage: result.coverage,
257
- }),
253
+ artifactDigest: scanArtifactDigest(result),
258
254
  });
259
255
  await workflow.complete("scan", metadata);
260
256
  return result;
@@ -1941,7 +1937,6 @@ export class CodexSecurity {
1941
1937
  ...new Set([
1942
1938
  "scan-manifest.json",
1943
1939
  "findings.json",
1944
- "coverage.json",
1945
1940
  "report.md",
1946
1941
  ...(result.threatModelPath === null
1947
1942
  ? []
@@ -2850,7 +2845,7 @@ export class CodexSecurity {
2850
2845
  }
2851
2846
  throwIfAborted(signal, scanDir);
2852
2847
  notifyObserver(options, "onScanStarted")();
2853
- await writeMockScanDraft(scanDir, scanId, local.target, registration, signal);
2848
+ await writeMockScanDraft(scanDir, scanId, registration, signal);
2854
2849
  const usage = {
2855
2850
  input_tokens: 0,
2856
2851
  cached_input_tokens: 0,
@@ -3204,14 +3199,21 @@ export async function runScanEvents(options) {
3204
3199
  usage = finalizedUsage;
3205
3200
  }
3206
3201
  options.signal.throwIfAborted();
3207
- await requireScanArtifacts(options.scanDir, ["scan-manifest.json", "findings.json", "coverage.json"], options.signal);
3208
- const [manifest, findings, coverage] = await Promise.all(["scan-manifest.json", "findings.json", "coverage.json"].map(async (name) => JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(await readScanFile(options.scanDir, name, name, options.signal)))));
3202
+ await requireScanArtifacts(options.scanDir, ["scan-manifest.json", "findings.json"], options.signal);
3203
+ const [manifest, findings] = await Promise.all(["scan-manifest.json", "findings.json"].map(async (name) => JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(await readScanFile(options.scanDir, name, name, options.signal)))));
3209
3204
  const helper = (await import(__rewriteRelativeImportExtension(pathToFileURL(join(await bundledPluginRoot(), "mcp/helpers.mjs")).href))).default;
3210
3205
  const draft = helper.parseCanonicalScanDraft({
3211
3206
  scanId: options.scanId ?? manifest.scan.id,
3212
3207
  manifest,
3213
3208
  findings,
3214
- coverage,
3209
+ reviewState: manifest.scan.reviewState ??
3210
+ (manifest.scan.coverageRef
3211
+ ? JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(await readScanFile(options.scanDir, "coverage.json", "legacy review state", options.signal)))
3212
+ : {
3213
+ surfaces: [],
3214
+ explicitExclusions: [],
3215
+ deferred: [],
3216
+ }),
3215
3217
  });
3216
3218
  options.signal.throwIfAborted();
3217
3219
  if (draft.complete === false) {
@@ -3369,7 +3371,7 @@ function scanPrompt(targetDescription, mode, skillName, scanId, hasKnowledgeBase
3369
3371
  `Use ${python} as <python_command> for plugin Python helper scripts (.py files); replace any literal python or python3 helper invocation with this exact interpreter.`,
3370
3372
  `Repository root: ${shellEnvironmentReference("CODEX_SECURITY_REPOSITORY")}`,
3371
3373
  `Use this exact scan directory for all scan output: ${shellEnvironmentReference("CODEX_SECURITY_SCAN_DIR")}`,
3372
- `Use exactly ${JSON.stringify(scanId)} as the scan ID in the manifest, findings, and coverage.`,
3374
+ `Use exactly ${JSON.stringify(scanId)} as the scan ID in the manifest and findings.`,
3373
3375
  `Use exactly ${shellEnvironmentReference("CODEX_SECURITY_TARGET_ID")} as scan.target.targetId; do not derive a different target ID.`,
3374
3376
  `Use exactly ${shellEnvironmentReference("CODEX_SECURITY_TARGET_DISPLAY_NAME")} as scan.target.displayName; do not infer a display name from the Git remote.`,
3375
3377
  `Use exactly ${shellEnvironmentReference("CODEX_SECURITY_TARGET_KIND")} as scan.target.kind; do not infer the target kind from the checkout.`,
@@ -3404,7 +3406,7 @@ function scanPrompt(targetDescription, mode, skillName, scanId, hasKnowledgeBase
3404
3406
  ]
3405
3407
  : skillName === "security-scan" || enforceCostLimit || customValidation
3406
3408
  ? [
3407
- "Write the complete canonical scan-manifest.json, findings.json, and coverage.json, but do not finalize or seal them; the SDK workbench owns authoritative metadata, finalization, report generation, and sealing.",
3409
+ "Write the complete canonical scan-manifest.json and findings.json with review bookkeeping in scan.reviewState, but do not finalize or seal them; the SDK workbench owns authoritative metadata, finalization, report generation, and sealing.",
3408
3410
  ]
3409
3411
  : [
3410
3412
  "Use record_codex_security_scan_draft and complete_codex_security_scan as directed by the selected skill; the workbench owns authoritative metadata, finalization, report generation, and sealing.",
@@ -3441,8 +3443,8 @@ async function targetInstruction(target, pluginRoot) {
3441
3443
  : `${helper} --helper make-repo-scope-input --repo ${shellEnvironmentReference("CODEX_SECURITY_REPOSITORY")} --scopes-file ${scopes} --out ${shellEnvironmentReference("CODEX_SECURITY_SCAN_DIR", "/scoped-source-input.jsonl")}`;
3442
3444
  // CMD expands the environment references once, preserving percent signs in path values.
3443
3445
  const bindScopes = process.platform === "win32"
3444
- ? String.raw `cmd.exe /d /v:off /s /c '""%CODEX_SECURITY_PLUGIN_ROOT%\scripts\launch_codex_security_mcp.cmd" --helper bind-repo-scopes --scopes-file "%CODEX_SECURITY_TARGET_PATHS_FILE%" --manifest "%CODEX_SECURITY_SCAN_DIR%\scan-manifest.json" --coverage "%CODEX_SECURITY_SCAN_DIR%\coverage.json""'`
3445
- : `${shellEnvironmentReference("CODEX_SECURITY_PLUGIN_ROOT", "/scripts/launch_codex_security_mcp")} --helper bind-repo-scopes --scopes-file ${scopes} --manifest ${shellEnvironmentReference("CODEX_SECURITY_SCAN_DIR", "/scan-manifest.json")} --coverage ${shellEnvironmentReference("CODEX_SECURITY_SCAN_DIR", "/coverage.json")}`;
3446
+ ? String.raw `cmd.exe /d /v:off /s /c '""%CODEX_SECURITY_PLUGIN_ROOT%\scripts\launch_codex_security_mcp.cmd" --helper bind-repo-scopes --scopes-file "%CODEX_SECURITY_TARGET_PATHS_FILE%" --manifest "%CODEX_SECURITY_SCAN_DIR%\scan-manifest.json""'`
3447
+ : `${shellEnvironmentReference("CODEX_SECURITY_PLUGIN_ROOT", "/scripts/launch_codex_security_mcp")} --helper bind-repo-scopes --scopes-file ${scopes} --manifest ${shellEnvironmentReference("CODEX_SECURITY_SCAN_DIR", "/scan-manifest.json")}`;
3446
3448
  return `Scan target paths: resolve every requested file and all non-ignored descendants of requested directories using ${makeScope}. Before finalization, preserve every requested scope with ${bindScopes}. Do not print, evaluate, or modify the target-paths file.`;
3447
3449
  }
3448
3450
  if (target.kind === "refs") {
@@ -3532,7 +3534,7 @@ async function requireScanArtifacts(scanDir, required, signal) {
3532
3534
  }
3533
3535
  }
3534
3536
  async function collectResult(turnResult, threadId, scanDir, pluginRoot, expectation, signal, workbenchValidated = false, pythonPath, protectedRoot) {
3535
- await requireScanArtifacts(scanDir, ["scan-manifest.json", "findings.json", "coverage.json", "report.md"], signal);
3537
+ await requireScanArtifacts(scanDir, ["scan-manifest.json", "findings.json", "report.md"], signal);
3536
3538
  const contract = await loadContract(scanDir, {
3537
3539
  pluginRoot,
3538
3540
  expectation,