@openai/codex-security 0.8.0 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/README.md +16 -10
  2. package/_bundled_plugin/.codex-plugin/plugin.json +1 -0
  3. package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
  4. package/_bundled_plugin/mcp/helpers.mjs.br.part-001 +0 -0
  5. package/_bundled_plugin/mcp/native/THIRD_PARTY_NOTICES.txt +4 -4
  6. package/_bundled_plugin/mcp/native/darwin-arm64/unix.node +0 -0
  7. package/_bundled_plugin/mcp/native/darwin-x64/unix.node +0 -0
  8. package/_bundled_plugin/mcp/native/linux-arm64-gnu/unix.node +0 -0
  9. package/_bundled_plugin/mcp/native/linux-arm64-musl/unix.node +0 -0
  10. package/_bundled_plugin/mcp/native/linux-x64-gnu/unix.node +0 -0
  11. package/_bundled_plugin/mcp/native/linux-x64-musl/unix.node +0 -0
  12. package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
  13. package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
  14. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  15. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  16. package/_bundled_plugin/mcp/server.mjs.br.part-002 +0 -0
  17. package/_bundled_plugin/references/scan-artifacts.md +1 -1
  18. package/_bundled_plugin/scripts/finalize_scan_contract.py +37 -1
  19. package/_bundled_plugin/scripts/servicenow_avit.py +107 -0
  20. package/_bundled_plugin/scripts/workbench_coverage_receipts.py +0 -17
  21. package/_bundled_plugin/scripts/workbench_db.py +1 -3
  22. package/_bundled_plugin/scripts/workbench_saved_results.py +0 -66
  23. package/_bundled_plugin/scripts/workbench_scan_start.py +4 -1
  24. package/_bundled_plugin/scripts/workbench_target.py +0 -108
  25. package/_bundled_plugin/skills/publish-findings/SKILL.md +9 -3
  26. package/_bundled_plugin/skills/resolve-dependency-alert/SKILL.md +18 -0
  27. package/_bundled_plugin/skills/resolve-dependency-alert/agents/openai.yaml +4 -0
  28. package/_bundled_plugin/skills/security-scan/SKILL.md +1 -1
  29. package/_bundled_plugin/skills/threat-model-visualize/SKILL.md +83 -0
  30. package/_bundled_plugin/skills/threat-model-visualize/agents/openai.yaml +4 -0
  31. package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-overview.svg +366 -0
  32. package/_bundled_plugin/skills/threat-model-visualize/assets/context-reference-path.svg +558 -0
  33. package/_bundled_plugin/skills/threat-model-visualize/assets/control-effects.js +85 -0
  34. package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.css +17 -0
  35. package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.html +38 -0
  36. package/_bundled_plugin/skills/threat-model-visualize/assets/explorer.js +372 -0
  37. package/_bundled_plugin/skills/threat-model-visualize/assets/route-paths.js +71 -0
  38. package/_bundled_plugin/skills/threat-model-visualize/assets/source-roles.js +47 -0
  39. package/_bundled_plugin/skills/threat-model-visualize/assets/svg-layout.js +149 -0
  40. package/_bundled_plugin/skills/threat-model-visualize/references/context-explorer.md +21 -0
  41. package/_bundled_plugin/skills/threat-model-visualize/references/view-model.md +49 -0
  42. package/_bundled_plugin/skills/threat-model-visualize/scripts/build_explorer.py +563 -0
  43. package/dist/api.d.ts.map +1 -1
  44. package/dist/api.js +36 -15
  45. package/dist/api.js.map +1 -1
  46. package/dist/artifact-export.d.ts +12 -3
  47. package/dist/artifact-export.d.ts.map +1 -1
  48. package/dist/artifact-export.js +30 -10
  49. package/dist/artifact-export.js.map +1 -1
  50. package/dist/auth.js +1 -1
  51. package/dist/auth.js.map +1 -1
  52. package/dist/cli-help.d.ts.map +1 -1
  53. package/dist/cli-help.js +1 -0
  54. package/dist/cli-help.js.map +1 -1
  55. package/dist/cli.d.ts +1 -1
  56. package/dist/cli.d.ts.map +1 -1
  57. package/dist/cli.js +72 -50
  58. package/dist/cli.js.map +1 -1
  59. package/dist/contract.d.ts +1 -0
  60. package/dist/contract.d.ts.map +1 -1
  61. package/dist/contract.js +16 -12
  62. package/dist/contract.js.map +1 -1
  63. package/dist/custom-validation-prompt.d.ts.map +1 -1
  64. package/dist/custom-validation-prompt.js +12 -4
  65. package/dist/custom-validation-prompt.js.map +1 -1
  66. package/dist/custom-validation.js +2 -2
  67. package/dist/custom-validation.js.map +1 -1
  68. package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
  69. package/dist/deduplication/deduplication-reviewer.js +1 -1
  70. package/dist/deduplication/deduplication-reviewer.js.map +1 -1
  71. package/dist/deduplication/records-protocol.d.ts.map +1 -1
  72. package/dist/deduplication/records-protocol.js +36 -22
  73. package/dist/deduplication/records-protocol.js.map +1 -1
  74. package/dist/deduplication/records.d.ts +3 -1
  75. package/dist/deduplication/records.d.ts.map +1 -1
  76. package/dist/deduplication/records.js +12 -8
  77. package/dist/deduplication/records.js.map +1 -1
  78. package/dist/endor-findings.d.ts.map +1 -1
  79. package/dist/endor-findings.js +46 -61
  80. package/dist/endor-findings.js.map +1 -1
  81. package/dist/external-findings-import.d.ts.map +1 -1
  82. package/dist/external-findings-import.js +8 -6
  83. package/dist/external-findings-import.js.map +1 -1
  84. package/dist/external-findings-local.d.ts +3 -1
  85. package/dist/external-findings-local.d.ts.map +1 -1
  86. package/dist/external-findings-local.js +136 -36
  87. package/dist/external-findings-local.js.map +1 -1
  88. package/dist/external-findings-publish.d.ts +3 -1
  89. package/dist/external-findings-publish.d.ts.map +1 -1
  90. package/dist/external-findings-publish.js +56 -31
  91. package/dist/external-findings-publish.js.map +1 -1
  92. package/dist/external-findings-read.d.ts +2 -0
  93. package/dist/external-findings-read.d.ts.map +1 -1
  94. package/dist/external-findings-read.js +9 -0
  95. package/dist/external-findings-read.js.map +1 -1
  96. package/dist/external-findings.d.ts +11 -0
  97. package/dist/external-findings.d.ts.map +1 -1
  98. package/dist/external-findings.js +13 -1
  99. package/dist/external-findings.js.map +1 -1
  100. package/dist/external-import-models.d.ts +1 -1
  101. package/dist/external-import-models.d.ts.map +1 -1
  102. package/dist/external-import-models.js.map +1 -1
  103. package/dist/github-advisories.d.ts.map +1 -1
  104. package/dist/github-advisories.js +5 -5
  105. package/dist/github-advisories.js.map +1 -1
  106. package/dist/github-dependabot-findings.d.ts +6 -0
  107. package/dist/github-dependabot-findings.d.ts.map +1 -0
  108. package/dist/github-dependabot-findings.js +247 -0
  109. package/dist/github-dependabot-findings.js.map +1 -0
  110. package/dist/github-findings.d.ts.map +1 -1
  111. package/dist/github-findings.js +11 -4
  112. package/dist/github-findings.js.map +1 -1
  113. package/dist/github-identifiers.d.ts +4 -0
  114. package/dist/github-identifiers.d.ts.map +1 -0
  115. package/dist/github-identifiers.js +9 -0
  116. package/dist/github-identifiers.js.map +1 -0
  117. package/dist/github.d.ts.map +1 -1
  118. package/dist/github.js +4 -6
  119. package/dist/github.js.map +1 -1
  120. package/dist/host-protocol.d.ts +5 -0
  121. package/dist/host-protocol.d.ts.map +1 -1
  122. package/dist/host-protocol.js +27 -3
  123. package/dist/host-protocol.js.map +1 -1
  124. package/dist/hosted-scan.d.ts.map +1 -1
  125. package/dist/hosted-scan.js +13 -5
  126. package/dist/hosted-scan.js.map +1 -1
  127. package/dist/index.d.ts +2 -0
  128. package/dist/index.d.ts.map +1 -1
  129. package/dist/index.js +2 -0
  130. package/dist/index.js.map +1 -1
  131. package/dist/inspector-findings.d.ts +9 -0
  132. package/dist/inspector-findings.d.ts.map +1 -0
  133. package/dist/inspector-findings.js +517 -0
  134. package/dist/inspector-findings.js.map +1 -0
  135. package/dist/patch-tui.d.ts +1 -1
  136. package/dist/patch-tui.d.ts.map +1 -1
  137. package/dist/patch-tui.js +4 -1
  138. package/dist/patch-tui.js.map +1 -1
  139. package/dist/runtime.d.ts +3 -2
  140. package/dist/runtime.d.ts.map +1 -1
  141. package/dist/runtime.js +15 -5
  142. package/dist/runtime.js.map +1 -1
  143. package/dist/scan-dashboard.d.ts.map +1 -1
  144. package/dist/scan-dashboard.js +25 -15
  145. package/dist/scan-dashboard.js.map +1 -1
  146. package/dist/scanner-import.d.ts +6 -2
  147. package/dist/scanner-import.d.ts.map +1 -1
  148. package/dist/scanner-import.js +23 -14
  149. package/dist/scanner-import.js.map +1 -1
  150. package/dist/semgrep-findings.d.ts.map +1 -1
  151. package/dist/semgrep-findings.js +39 -49
  152. package/dist/semgrep-findings.js.map +1 -1
  153. package/dist/snyk-findings.d.ts.map +1 -1
  154. package/dist/snyk-findings.js +78 -88
  155. package/dist/snyk-findings.js.map +1 -1
  156. package/docs/cli.md +52 -14
  157. package/docs/dedupe-records.md +17 -4
  158. package/docs/hosted-scans.md +14 -0
  159. package/package.json +5 -5
  160. package/schemas/external-findings.schema.json +1 -1
package/dist/api.js CHANGED
@@ -55,7 +55,7 @@ import { CODEX_SECURITY_THREAD_SOURCES } from "./thread-source.js";
55
55
  import { codexSecurityRequestContext } from "./request-metadata.js";
56
56
  import { CODEX_EXECUTABLE_VERSION, CODEX_SDK_VERSION } from "./version.js";
57
57
  import { bundledCodexSdkEnvironment } from "./codex-sdk-environment.js";
58
- import { canonicalConfigPath, acquireCodexSecurityCredentialHomeLock, withCredentialHomeLock, bootstrapPlugin, bundledPluginRoot, cleanupSdkDirectory, codexSecurityCredentialAllowsAmbientImport, codexSecurityCredentialHome, codexSecurityHasStoredFileCredentials, codexSecurityStateDirectory, codexExecutableReadPaths, createIsolatedHome, executablePathForSpawn, expandHome, importAmbientAuth, prepareCodexSecurityCredentialHome, preserveCodexSecurityPluginRegistration, pluginExecutionEnvironment, environmentWithGit, pluginMetadata, planOutputArchive, prepareScanArtifactRestorer, prepareOutputDir, prepareScanRegistrationOutput, preparePersistentOutputRoot, probeCodexSandbox, requireModelSafeOutputDir, requireOutputOutsideRepositories, requireOutputOutsideRepository, requirePrivateCredentialHome, requirePrivatePolicyOutputDirectory, resolveCodexCommand, resolvePluginPath, resolvePluginPython, runWorkbench, setCodexSecurityCredentialLogout, validateOutputDir, } from "./runtime.js";
58
+ import { canonicalConfigPath, acquireCodexSecurityCredentialHomeLock, withCredentialHomeLock, bootstrapPlugin, bundledPluginRoot, cleanupSdkDirectory, codexSecurityCredentialAllowsAmbientImport, codexSecurityCredentialHome, codexSecurityHasStoredFileCredentials, codexSecurityStateDirectory, codexExecutableReadPaths, createIsolatedHome, executablePathForSpawn, expandHome, importAmbientAuth, prepareCodexSecurityCredentialHome, preserveCodexSecurityPluginRegistration, pluginExecutionEnvironment, environmentWithGit, pluginMetadata, planOutputArchive, prepareScanArtifactRestorer, prepareOutputDir, prepareScanRegistrationOutput, preparePersistentOutputRoot, probeCodexSandbox, requireModelSafeOutputDir, requireOutputOutsideRepositories, requireOutputOutsideRepository, requirePrivateCredentialHome, preparePolicyOutputDirectory, resolveCodexCommand, resolvePluginPath, resolvePluginPython, runWorkbench, setCodexSecurityCredentialLogout, validateOutputDir, } from "./runtime.js";
59
59
  import { enclosingGitWorktreeRoot, normalizeRepository, normalizeTarget, gitMarkerRoot, repositoryRevision, resolveRepositoryPath, validatedGitEnvironment, validateCommittedDiffCheckout, validateMode, } from "./targets.js";
60
60
  import { inspectTrustedExecutable, isWithin, } from "./trusted-executable.js";
61
61
  const DEEP_SCAN_CONFIG_PATH_ENVIRONMENT = "CODEX_SECURITY_DEEP_SCAN_CONFIG_PATH";
@@ -863,8 +863,8 @@ export class CodexSecurity {
863
863
  outputDir = await (this.#dependencies.prepareOutputDir ?? prepareOutputDir)(inputs.outputDir ?? undefined, `${basename(target.repository)}-policy`, root, (path) => requireOutputOutsideRepositories(inputs.protectedRoots, path));
864
864
  requireOutputOutsideRepositories(inputs.protectedRoots, outputDir);
865
865
  requireModelSafeOutputDir(outputDir);
866
- await (this.#dependencies.requirePrivatePolicyOutputDirectory ??
867
- requirePrivatePolicyOutputDirectory)(outputDir);
866
+ await (this.#dependencies.preparePolicyOutputDirectory ??
867
+ preparePolicyOutputDirectory)(outputDir);
868
868
  if (options.knowledgeBasePaths?.length) {
869
869
  knowledgeBase = await prepareKnowledgeBase(options.knowledgeBasePaths, signal, outputDir);
870
870
  }
@@ -1600,7 +1600,7 @@ export class CodexSecurity {
1600
1600
  await writeCustomValidationStatus(scanDir, { scanId, status: "pending" }, signal);
1601
1601
  }
1602
1602
  checkOpen();
1603
- const basePrompt = scanPrompt(await targetInstruction(normalized, shellPluginRoot), mode, skillName, scanId, knowledgeBase !== null, options.resumeScanId !== undefined &&
1603
+ const basePrompt = scanPrompt(await targetInstruction(normalized, shellPluginRoot, this.#dependencies.hostedScan !== undefined), mode, skillName, scanId, knowledgeBase !== null, options.resumeScanId !== undefined &&
1604
1604
  typeof registration["userContext"] === "string"
1605
1605
  ? registration["userContext"]
1606
1606
  : options.scanPrompt, options.maxCostUsd !== undefined, discoveryPrompt, modelProvider, options.ownerSuggestions);
@@ -3421,7 +3421,7 @@ function skillNameFor(target, mode) {
3421
3421
  return "security-diff-scan";
3422
3422
  return mode === "deep" ? "deep-security-scan" : "security-scan";
3423
3423
  }
3424
- async function targetInstruction(target, pluginRoot) {
3424
+ async function targetInstruction(target, pluginRoot, hosted) {
3425
3425
  if (target.kind === "repository")
3426
3426
  return "Scan target: the entire repository.";
3427
3427
  if (target.kind === "paths") {
@@ -3436,16 +3436,33 @@ async function targetInstruction(target, pluginRoot) {
3436
3436
  if (code !== "ENOENT" && code !== "ENOTDIR")
3437
3437
  throw error;
3438
3438
  }
3439
- const makeScope = legacyGenerator
3440
- ? `${pluginPythonCommand()} ${shellEnvironmentReference("CODEX_SECURITY_PLUGIN_ROOT", "/scripts/generate_rank_input.py")} make-repo-scope-input --repo ${shellEnvironmentReference("CODEX_SECURITY_REPOSITORY")} --scopes-file ${scopes} --out ${shellEnvironmentReference("CODEX_SECURITY_SCAN_DIR", "/scoped-source-input.jsonl")}`
3441
- : process.platform === "win32"
3442
- ? String.raw `cmd.exe /d /v:off /s /c '""%CODEX_SECURITY_PLUGIN_ROOT%\scripts\launch_codex_security_mcp.cmd" --helper make-repo-scope-input --repo "%CODEX_SECURITY_REPOSITORY%\." --scopes-file "%CODEX_SECURITY_TARGET_PATHS_FILE%" --out "%CODEX_SECURITY_SCAN_DIR%\scoped-source-input.jsonl""'`
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")}`;
3439
+ const inventory = shellEnvironmentReference("CODEX_SECURITY_SCAN_DIR", "/scoped-source-input.jsonl");
3440
+ const scopeArgs = `--repo ${shellEnvironmentReference("CODEX_SECURITY_REPOSITORY")} --scopes-file ${scopes} --out ${inventory}`;
3444
3441
  // CMD expands the environment references once, preserving percent signs in path values.
3445
3442
  const bindScopes = process.platform === "win32"
3446
3443
  ? 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")}`;
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.`;
3444
+ : `${helper} --helper bind-repo-scopes --scopes-file ${scopes} --manifest ${shellEnvironmentReference("CODEX_SECURITY_SCAN_DIR", "/scan-manifest.json")}`;
3445
+ const scanTarget = "Scan target paths: resolve every requested file and all non-ignored descendants of requested directories";
3446
+ const finalize = `Before finalization, preserve every requested scope with:\n${bindScopes}\nDo not print, evaluate, or modify the target-paths file.`;
3447
+ if (hosted && process.platform === "linux" && !legacyGenerator) {
3448
+ const capabilities = await pluginCapabilities(pluginRoot).catch(() => undefined);
3449
+ if (capabilities?.["hostedScopeInventory"] === 1) {
3450
+ const hostedHelper = `${helper} --helper make-hosted-repo-scope-input ${scopeArgs}`;
3451
+ return [
3452
+ `${scanTarget} using the hosted scope helper:`,
3453
+ `${hostedHelper} --state-dir ${shellEnvironmentReference("CODEX_SECURITY_STATE_DIR")}`,
3454
+ "Use the reported path. If a later shell cannot read it, use the path reported by this recovery command:",
3455
+ hostedHelper,
3456
+ finalize,
3457
+ ].join("\n");
3458
+ }
3459
+ }
3460
+ const makeScope = legacyGenerator
3461
+ ? `${pluginPythonCommand()} ${shellEnvironmentReference("CODEX_SECURITY_PLUGIN_ROOT", "/scripts/generate_rank_input.py")} make-repo-scope-input ${scopeArgs}`
3462
+ : process.platform === "win32"
3463
+ ? String.raw `cmd.exe /d /v:off /s /c '""%CODEX_SECURITY_PLUGIN_ROOT%\scripts\launch_codex_security_mcp.cmd" --helper make-repo-scope-input --repo "%CODEX_SECURITY_REPOSITORY%\." --scopes-file "%CODEX_SECURITY_TARGET_PATHS_FILE%" --out "%CODEX_SECURITY_SCAN_DIR%\scoped-source-input.jsonl""'`
3464
+ : `${helper} --helper make-repo-scope-input ${scopeArgs}`;
3465
+ return `${scanTarget} using ${makeScope}. ${finalize}`;
3449
3466
  }
3450
3467
  if (target.kind === "refs") {
3451
3468
  return `Scan target: Git diff from ${target.base} to ${target.head}.`;
@@ -4075,13 +4092,17 @@ export function scanPreflightCodexConfig(config) {
4075
4092
  }
4076
4093
  return result;
4077
4094
  }
4078
- async function requireCurrentDeepScanPlugin(runtime) {
4079
- const manifest = JSON.parse(await readFile(join(runtime.plugin.pluginRoot, ".codex-plugin", "plugin.json"), "utf8"));
4095
+ async function pluginCapabilities(pluginRoot) {
4096
+ const manifest = JSON.parse(await readFile(join(pluginRoot, ".codex-plugin", "plugin.json"), "utf8"));
4080
4097
  const capabilities = isRecord(manifest)
4081
4098
  ? manifest["codexSecurity"]
4082
4099
  : undefined;
4100
+ return isRecord(capabilities) ? capabilities : undefined;
4101
+ }
4102
+ async function requireCurrentDeepScanPlugin(runtime) {
4103
+ const capabilities = await pluginCapabilities(runtime.plugin.pluginRoot);
4083
4104
  if (runtime.deepScanConfigPath === undefined ||
4084
- !isRecord(capabilities) ||
4105
+ capabilities === undefined ||
4085
4106
  capabilities["directDeepScanEngine"] !== 1 ||
4086
4107
  capabilities["workerProviderSnapshot"] !== 4) {
4087
4108
  throw new CodexSecurityError("Deep Scan requires the current plugin's direct engine and isolated worker runtime support. Update the custom plugin or use the bundled plugin.");