@openai/codex-security 0.1.16 → 0.1.18

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 (125) hide show
  1. package/README.md +228 -18
  2. package/_bundled_plugin/.app.json +1 -1
  3. package/_bundled_plugin/.mcp.json +10 -3
  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/references/config-preflight.md +1 -1
  7. package/_bundled_plugin/references/core-scan.md +1 -1
  8. package/_bundled_plugin/references/final-report.md +4 -2
  9. package/_bundled_plugin/references/sarif-adapter.md +2 -0
  10. package/_bundled_plugin/references/scan-artifacts.md +1 -1
  11. package/_bundled_plugin/references/scan-contract.md +18 -7
  12. package/_bundled_plugin/schemas/scan-manifest.schema.json +2 -2
  13. package/_bundled_plugin/schemas/tools/scan-draft.schema.json +23 -0
  14. package/_bundled_plugin/scripts/deep_scan_workbench.py +122 -7
  15. package/_bundled_plugin/scripts/finalize_scan_contract.py +106 -38
  16. package/_bundled_plugin/scripts/generate_in_scope_files.py +20 -0
  17. package/_bundled_plugin/scripts/generate_rank_input.py +23 -7
  18. package/_bundled_plugin/scripts/launch_codex_security_mcp +32 -0
  19. package/_bundled_plugin/scripts/launch_codex_security_mcp.cmd +27 -0
  20. package/_bundled_plugin/scripts/report_projection.py +19 -8
  21. package/_bundled_plugin/scripts/workbench_cli.py +35 -15
  22. package/_bundled_plugin/scripts/workbench_db.py +184 -202
  23. package/_bundled_plugin/scripts/workbench_finding_index.py +101 -0
  24. package/_bundled_plugin/scripts/workbench_progress.py +6 -3
  25. package/_bundled_plugin/scripts/workbench_remediation.py +19 -0
  26. package/_bundled_plugin/scripts/workbench_saved_results.py +1289 -0
  27. package/_bundled_plugin/scripts/workbench_scan_history.py +17 -2
  28. package/_bundled_plugin/scripts/workbench_schema.py +28 -0
  29. package/_bundled_plugin/scripts/workbench_target.py +36 -5
  30. package/_bundled_plugin/scripts/workbench_validation.py +9 -0
  31. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +4 -4
  32. package/_bundled_plugin/skills/fix-finding/SKILL.md +17 -1
  33. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +1 -1
  34. package/_bundled_plugin/skills/security-scan/SKILL.md +1 -1
  35. package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +1 -1
  36. package/dist/api.d.ts +18 -1
  37. package/dist/api.d.ts.map +1 -1
  38. package/dist/api.js +234 -18
  39. package/dist/api.js.map +1 -1
  40. package/dist/cli.d.ts +5 -3
  41. package/dist/cli.d.ts.map +1 -1
  42. package/dist/cli.js +348 -43
  43. package/dist/cli.js.map +1 -1
  44. package/dist/component-plan.d.ts +15 -0
  45. package/dist/component-plan.d.ts.map +1 -0
  46. package/dist/component-plan.js +145 -0
  47. package/dist/component-plan.js.map +1 -0
  48. package/dist/component-scan.d.ts +83 -0
  49. package/dist/component-scan.d.ts.map +1 -0
  50. package/dist/component-scan.js +279 -0
  51. package/dist/component-scan.js.map +1 -0
  52. package/dist/contract.d.ts +8 -2
  53. package/dist/contract.d.ts.map +1 -1
  54. package/dist/contract.js +27 -8
  55. package/dist/contract.js.map +1 -1
  56. package/dist/cost-model.d.ts +20 -0
  57. package/dist/cost-model.d.ts.map +1 -0
  58. package/dist/cost-model.js +86 -0
  59. package/dist/cost-model.js.map +1 -0
  60. package/dist/cost.d.ts +2 -11
  61. package/dist/cost.d.ts.map +1 -1
  62. package/dist/cost.js +15 -98
  63. package/dist/cost.js.map +1 -1
  64. package/dist/custom-validation-prompt.d.ts +4 -0
  65. package/dist/custom-validation-prompt.d.ts.map +1 -0
  66. package/dist/custom-validation-prompt.js +94 -0
  67. package/dist/custom-validation-prompt.js.map +1 -0
  68. package/dist/custom-validation.d.ts +45 -0
  69. package/dist/custom-validation.d.ts.map +1 -0
  70. package/dist/custom-validation.js +292 -0
  71. package/dist/custom-validation.js.map +1 -0
  72. package/dist/errors.d.ts +1 -1
  73. package/dist/errors.d.ts.map +1 -1
  74. package/dist/errors.js +1 -1
  75. package/dist/errors.js.map +1 -1
  76. package/dist/index.d.ts +6 -1
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +2 -0
  79. package/dist/index.js.map +1 -1
  80. package/dist/models.d.ts +1 -1
  81. package/dist/models.d.ts.map +1 -1
  82. package/dist/models.js.map +1 -1
  83. package/dist/multiscan.d.ts +1 -0
  84. package/dist/multiscan.d.ts.map +1 -1
  85. package/dist/multiscan.js +53 -5
  86. package/dist/multiscan.js.map +1 -1
  87. package/dist/patch-tui.js +1 -1
  88. package/dist/patch-tui.js.map +1 -1
  89. package/dist/publication.d.ts.map +1 -1
  90. package/dist/publication.js +3 -4
  91. package/dist/publication.js.map +1 -1
  92. package/dist/runtime.d.ts +4 -2
  93. package/dist/runtime.d.ts.map +1 -1
  94. package/dist/runtime.js +109 -38
  95. package/dist/runtime.js.map +1 -1
  96. package/dist/scan-comparison.d.ts +12 -5
  97. package/dist/scan-comparison.d.ts.map +1 -1
  98. package/dist/scan-comparison.js +72 -28
  99. package/dist/scan-comparison.js.map +1 -1
  100. package/dist/scan-dashboard.d.ts +9 -2
  101. package/dist/scan-dashboard.d.ts.map +1 -1
  102. package/dist/scan-dashboard.js +198 -3
  103. package/dist/scan-dashboard.js.map +1 -1
  104. package/dist/scan-logs.d.ts.map +1 -1
  105. package/dist/scan-logs.js +5 -21
  106. package/dist/scan-logs.js.map +1 -1
  107. package/dist/scan-sessions.d.ts +4 -0
  108. package/dist/scan-sessions.d.ts.map +1 -0
  109. package/dist/scan-sessions.js +35 -0
  110. package/dist/scan-sessions.js.map +1 -0
  111. package/dist/targets.d.ts.map +1 -1
  112. package/dist/targets.js +16 -1
  113. package/dist/targets.js.map +1 -1
  114. package/dist/version.d.ts.map +1 -1
  115. package/dist/version.js +2 -20
  116. package/dist/version.js.map +1 -1
  117. package/dist/windows-path.d.ts +3 -0
  118. package/dist/windows-path.d.ts.map +1 -0
  119. package/dist/windows-path.js +16 -0
  120. package/dist/windows-path.js.map +1 -0
  121. package/dist/worker-progress.d.ts +1 -0
  122. package/dist/worker-progress.d.ts.map +1 -1
  123. package/dist/worker-progress.js +12 -0
  124. package/dist/worker-progress.js.map +1 -1
  125. package/package.json +8 -2
@@ -0,0 +1,32 @@
1
+ #!/bin/sh
2
+ set -eu
3
+
4
+ PATH="${PATH:-/usr/bin:/bin}:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
5
+ export PATH
6
+
7
+ launcher_dir=$(CDPATH= cd "$(dirname "$0")" && pwd)
8
+ server_path=$launcher_dir/../mcp/server.mjs
9
+ cache_root=${XDG_CACHE_HOME:-${HOME:-}/.cache}
10
+ codex_resources=
11
+ case "${CODEX_CLI_PATH:-}" in
12
+ */*) codex_resources=${CODEX_CLI_PATH%/*} ;;
13
+ esac
14
+
15
+ for candidate in \
16
+ "${CODEX_MCP_NODE_PATH:-}" \
17
+ "${CODEX_BROWSER_USE_NODE_PATH:-}" \
18
+ "${CODEX_ELECTRON_RESOURCES_PATH:-}/cua_node/bin/node" \
19
+ "$codex_resources/cua_node/bin/node" \
20
+ "$cache_root/codex-runtimes/codex-primary-runtime/dependencies/node/bin/node"
21
+ do
22
+ if [ -n "$candidate" ] && [ -x "$candidate" ]; then
23
+ exec "$candidate" "$server_path" "$@"
24
+ fi
25
+ done
26
+
27
+ if command -v node >/dev/null 2>&1; then
28
+ exec node "$server_path" "$@"
29
+ fi
30
+
31
+ printf '%s\n' 'Codex Security could not find a Node runtime. Reinstall or update Codex, or set CODEX_MCP_NODE_PATH to an executable Node runtime.' >&2
32
+ exit 127
@@ -0,0 +1,27 @@
1
+ @echo off
2
+ setlocal DisableDelayedExpansion
3
+
4
+ set "CODEX_SECURITY_MCP_SCRIPT=%~dp0..\mcp\server.mjs"
5
+
6
+ rem This process waits for Node and must not keep the installed plugin directory locked.
7
+ if "%~d0"=="" (cd /d "%SystemRoot%") else (cd /d "%~d0\")
8
+ if errorlevel 1 (
9
+ echo Codex Security could not start: no safe Windows working directory. 1>&2
10
+ exit /b 1
11
+ )
12
+
13
+ rem WindowsApps can expose a Node path that exists but cannot be executed.
14
+ rem Prefer relocated user-writable runtimes before probing packaged paths.
15
+ if defined LOCALAPPDATA for /d %%D in ("%LOCALAPPDATA%\OpenAI\Codex\runtimes\cua_node\*") do if exist "%%~fD\bin\node.exe" ("%%~fD\bin\node.exe" "%CODEX_SECURITY_MCP_SCRIPT%" %* & exit)
16
+ if defined XDG_CACHE_HOME if exist "%XDG_CACHE_HOME%\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe" ("%XDG_CACHE_HOME%\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe" "%CODEX_SECURITY_MCP_SCRIPT%" %* & exit)
17
+ if defined USERPROFILE if exist "%USERPROFILE%\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe" ("%USERPROFILE%\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\bin\node.exe" "%CODEX_SECURITY_MCP_SCRIPT%" %* & exit)
18
+ if defined CODEX_MCP_NODE_PATH if exist "%CODEX_MCP_NODE_PATH%" ("%CODEX_MCP_NODE_PATH%" "%CODEX_SECURITY_MCP_SCRIPT%" %* & exit)
19
+ if defined CODEX_BROWSER_USE_NODE_PATH if exist "%CODEX_BROWSER_USE_NODE_PATH%" ("%CODEX_BROWSER_USE_NODE_PATH%" "%CODEX_SECURITY_MCP_SCRIPT%" %* & exit)
20
+ if defined CODEX_ELECTRON_RESOURCES_PATH if exist "%CODEX_ELECTRON_RESOURCES_PATH%\cua_node\bin\node.exe" ("%CODEX_ELECTRON_RESOURCES_PATH%\cua_node\bin\node.exe" "%CODEX_SECURITY_MCP_SCRIPT%" %* & exit)
21
+ if defined CODEX_CLI_PATH for %%I in ("%CODEX_CLI_PATH%") do if exist "%%~dpIcua_node\bin\node.exe" ("%%~dpIcua_node\bin\node.exe" "%CODEX_SECURITY_MCP_SCRIPT%" %* & exit)
22
+
23
+ where node >nul 2>&1
24
+ if not errorlevel 1 (node "%CODEX_SECURITY_MCP_SCRIPT%" %* & exit)
25
+
26
+ echo Codex Security could not find a Node runtime. Reinstall or update Codex, or set CODEX_MCP_NODE_PATH to an executable Node runtime. 1>&2
27
+ exit /b 127
@@ -865,6 +865,7 @@ def build_report_markdown(
865
865
  "",
866
866
  "| Field | Value |",
867
867
  "| --- | --- |",
868
+ f"| Scan outcome | {scan.get('status', 'completed')} |",
868
869
  *summary_count_lines,
869
870
  f"| Coverage | {coverage['completeness']} |",
870
871
  f"| Validation mode | {_cell(scope.get('validationMode', 'not recorded'))} |",
@@ -973,20 +974,30 @@ def build_report_markdown(
973
974
  for item in deferred
974
975
  )
975
976
  )
977
+ stopped = manifest.get("scan", {}).get("status") in {
978
+ "failed",
979
+ "canceled",
980
+ "interrupted",
981
+ }
976
982
  lines.extend(
977
983
  [
978
984
  "### No findings",
979
985
  "",
980
986
  (
981
- "No source review completed before the configured time limit. "
982
- "No vulnerability conclusion can be drawn."
983
- if no_source_review
987
+ "No findings were retained before the scan stopped. "
988
+ "The scan did not complete. No vulnerability conclusion can be drawn."
989
+ if stopped
984
990
  else (
985
- "No findings were validated before the scan reached its cost limit. "
986
- "Review the deferred candidates in Open Questions And Follow Up."
987
- if budget_exhausted
988
- else "No reportable findings survived the canonical discovery, validation, "
989
- "and reportability gates."
991
+ "No source review completed before the configured time limit. "
992
+ "No vulnerability conclusion can be drawn."
993
+ if no_source_review
994
+ else (
995
+ "No findings were validated before the scan reached its cost limit. "
996
+ "Review the deferred candidates in Open Questions And Follow Up."
997
+ if budget_exhausted
998
+ else "No reportable findings survived the canonical discovery, validation, "
999
+ "and reportability gates."
1000
+ )
990
1001
  )
991
1002
  ),
992
1003
  ]
@@ -24,6 +24,12 @@ from workbench_constants import (
24
24
  )
25
25
 
26
26
 
27
+ def add_user_context(parser: argparse.ArgumentParser, *, required: bool = False) -> None:
28
+ context = parser.add_mutually_exclusive_group(required=required)
29
+ context.add_argument("--user-context")
30
+ context.add_argument("--user-context-stdin", action="store_true")
31
+
32
+
27
33
  def parse_args(description: str) -> argparse.Namespace:
28
34
  parser = argparse.ArgumentParser(description=description)
29
35
  subparsers = parser.add_subparsers(dest="command", required=True)
@@ -34,7 +40,7 @@ def parse_args(description: str) -> argparse.Namespace:
34
40
  create_workspace.add_argument("--target-path")
35
41
  create_workspace.add_argument("--target-title")
36
42
  create_workspace.add_argument("--target-summary")
37
- create_workspace.add_argument("--user-context")
43
+ add_user_context(create_workspace)
38
44
  create_workspace.add_argument("--scope")
39
45
  create_workspace.add_argument("--mode", choices=MODES, default="standard")
40
46
  create_workspace.add_argument("--diff-target-kind", choices=DIFF_TARGET_KINDS)
@@ -64,7 +70,7 @@ def parse_args(description: str) -> argparse.Namespace:
64
70
  save_workspace.add_argument("--scope", required=True)
65
71
  save_workspace.add_argument("--mode", choices=MODES, required=True)
66
72
  save_workspace.add_argument("--target-summary")
67
- save_workspace.add_argument("--user-context")
73
+ add_user_context(save_workspace)
68
74
  save_workspace.add_argument("--diff-target-kind", choices=DIFF_TARGET_KINDS)
69
75
  save_workspace.add_argument("--diff-base-revision")
70
76
  save_workspace.add_argument("--diff-head-revision")
@@ -82,7 +88,7 @@ def parse_args(description: str) -> argparse.Namespace:
82
88
  start_prompt_only_scan.add_argument("--scope", required=True)
83
89
  start_prompt_only_scan.add_argument("--mode", choices=("diff", "standard"), required=True)
84
90
  start_prompt_only_scan.add_argument("--target-summary")
85
- start_prompt_only_scan.add_argument("--user-context")
91
+ add_user_context(start_prompt_only_scan)
86
92
  start_prompt_only_scan.add_argument("--diff-target-kind", choices=DIFF_TARGET_KINDS)
87
93
  start_prompt_only_scan.add_argument("--diff-base-revision")
88
94
  start_prompt_only_scan.add_argument("--diff-head-revision")
@@ -96,7 +102,7 @@ def parse_args(description: str) -> argparse.Namespace:
96
102
  start_headless_standard_scan.add_argument("--target-path", required=True)
97
103
  start_headless_standard_scan.add_argument("--scope", required=True)
98
104
  start_headless_standard_scan.add_argument("--target-summary")
99
- start_headless_standard_scan.add_argument("--user-context")
105
+ add_user_context(start_headless_standard_scan)
100
106
  start_headless_standard_scan.add_argument("--scan-root")
101
107
  start_headless_standard_scan.add_argument("--model")
102
108
  start_headless_standard_scan.add_argument("--reasoning-effort")
@@ -119,7 +125,7 @@ def parse_args(description: str) -> argparse.Namespace:
119
125
 
120
126
  update_scan_context = subparsers.add_parser("update-scan-context")
121
127
  update_scan_context.add_argument("--scan-id", required=True)
122
- update_scan_context.add_argument("--user-context", required=True)
128
+ add_user_context(update_scan_context, required=True)
123
129
  update_scan_context_owner = update_scan_context.add_mutually_exclusive_group(required=True)
124
130
  update_scan_context_owner.add_argument("--workspace-id")
125
131
  update_scan_context_owner.add_argument("--thread-id")
@@ -142,7 +148,10 @@ def parse_args(description: str) -> argparse.Namespace:
142
148
  register_cli_scan = subparsers.add_parser("register-cli-scan")
143
149
  register_cli_scan.add_argument("--scan-dir", required=True)
144
150
  register_cli_scan.add_argument("--repository", required=True)
145
- register_cli_scan.add_argument("--recipe-json", required=True)
151
+ recipe = register_cli_scan.add_mutually_exclusive_group(required=True)
152
+ recipe.add_argument("--recipe-json")
153
+ recipe.add_argument("--recipe-json-stdin", action="store_true")
154
+ recipe.add_argument("--registration-json-stdin", action="store_true")
146
155
  register_cli_scan.add_argument("--parent-scan-id")
147
156
  register_cli_scan.add_argument("--archive-existing", action="store_true")
148
157
  register_cli_scan.add_argument("--archived-scan-dir")
@@ -163,7 +172,9 @@ def parse_args(description: str) -> argparse.Namespace:
163
172
  save_scan_comparison = subparsers.add_parser("save-scan-comparison")
164
173
  save_scan_comparison.add_argument("--before-scan-id", required=True)
165
174
  save_scan_comparison.add_argument("--after-scan-id", required=True)
166
- save_scan_comparison.add_argument("--matches-json", required=True)
175
+ matches = save_scan_comparison.add_mutually_exclusive_group(required=True)
176
+ matches.add_argument("--matches-json")
177
+ matches.add_argument("--matches-json-stdin", action="store_true")
167
178
 
168
179
  list_global_findings = subparsers.add_parser("list-global-findings")
169
180
  list_global_findings.add_argument("--query")
@@ -193,7 +204,9 @@ def parse_args(description: str) -> argparse.Namespace:
193
204
  update_progress.add_argument("--phase-items-total", type=non_negative_int)
194
205
  update_progress.add_argument("--phase-items-completed", type=non_negative_int)
195
206
  update_progress.add_argument("--phase-progress-unit", choices=PHASE_PROGRESS_UNITS)
196
- update_progress.add_argument("--preflight-issues-json")
207
+ preflight_issues = update_progress.add_mutually_exclusive_group()
208
+ preflight_issues.add_argument("--preflight-issues-json")
209
+ preflight_issues.add_argument("--preflight-issues-json-stdin", action="store_true")
197
210
  update_progress.add_argument("--review-items-total", type=non_negative_int)
198
211
  update_progress.add_argument("--review-items-completed", type=non_negative_int)
199
212
  update_progress.add_argument("--reportable-findings-count", type=non_negative_int)
@@ -228,6 +241,19 @@ def parse_args(description: str) -> argparse.Namespace:
228
241
  fail_scan.add_argument("--claim-token")
229
242
  fail_scan.add_argument("--cost-json")
230
243
 
244
+ preserve_scan = subparsers.add_parser("preserve-scan-results")
245
+ preserve_scan.add_argument("--scan-id", required=True)
246
+ preserve_scan.add_argument("--thread-id")
247
+ preserve_scan.add_argument("--claim-token")
248
+ preserve_scan.add_argument("--coordinator-generation", type=positive_int)
249
+
250
+ write_scan_draft = subparsers.add_parser("write-scan-draft")
251
+ write_scan_draft.add_argument("--scan-id", required=True)
252
+ write_scan_draft.add_argument("--draft-path", required=True)
253
+ write_scan_draft.add_argument("--checkpoint-path")
254
+ write_scan_draft.add_argument("--expected-draft-digest")
255
+ write_scan_draft.add_argument("--claim-token")
256
+
231
257
  mark_handoff_delivered = subparsers.add_parser("mark-handoff-delivered")
232
258
  mark_handoff_delivered.add_argument("--scan-id", required=True)
233
259
  mark_handoff_delivered.add_argument("--claim-token", required=True)
@@ -309,13 +335,7 @@ def parse_args(description: str) -> argparse.Namespace:
309
335
  publication.add_argument("--input-file", required=True)
310
336
 
311
337
  subparsers.add_parser("database-info")
312
- arguments = sys.argv[1:]
313
- if "--user-context-stdin" in arguments:
314
- if arguments.count("--user-context-stdin") != 1 or "--user-context" in arguments:
315
- parser.error("pass exactly one user-context transport")
316
- index = arguments.index("--user-context-stdin")
317
- arguments[index : index + 1] = ["--user-context", sys.stdin.read()]
318
- return parser.parse_args(arguments)
338
+ return parser.parse_args()
319
339
 
320
340
 
321
341
  def non_negative_int(value: str) -> int: