@openai/codex-security 0.1.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 (178) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +306 -0
  3. package/_bundled_plugin/.app.json +20 -0
  4. package/_bundled_plugin/.codex-plugin/plugin.json +41 -0
  5. package/_bundled_plugin/.mcp.json +20 -0
  6. package/_bundled_plugin/assets/logo.png +0 -0
  7. package/_bundled_plugin/examples/completed-scan/coverage.json +22 -0
  8. package/_bundled_plugin/examples/completed-scan/findings.json +51 -0
  9. package/_bundled_plugin/examples/completed-scan/scan-manifest.json +43 -0
  10. package/_bundled_plugin/mcp/mcp-app.html.br +0 -0
  11. package/_bundled_plugin/mcp/server.mjs +24 -0
  12. package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
  13. package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
  14. package/_bundled_plugin/preflight/capability-profiles.toml +179 -0
  15. package/_bundled_plugin/references/config-preflight.md +115 -0
  16. package/_bundled_plugin/references/final-report.md +205 -0
  17. package/_bundled_plugin/references/finding-detail-fields.md +162 -0
  18. package/_bundled_plugin/references/sarif-adapter.md +26 -0
  19. package/_bundled_plugin/references/scan-artifacts.md +116 -0
  20. package/_bundled_plugin/references/scan-contract.md +164 -0
  21. package/_bundled_plugin/references/security-guidance.md +15 -0
  22. package/_bundled_plugin/references/shared-hard-rules.md +15 -0
  23. package/_bundled_plugin/references/static-finding-assessment.md +75 -0
  24. package/_bundled_plugin/schemas/coverage.schema.json +228 -0
  25. package/_bundled_plugin/schemas/findings.schema.json +359 -0
  26. package/_bundled_plugin/schemas/scan-manifest.schema.json +332 -0
  27. package/_bundled_plugin/scripts/config_preflight.py +901 -0
  28. package/_bundled_plugin/scripts/deep_scan_config.py +108 -0
  29. package/_bundled_plugin/scripts/deep_scan_workbench.py +1547 -0
  30. package/_bundled_plugin/scripts/filesystem_identity.py +30 -0
  31. package/_bundled_plugin/scripts/finalize_scan_contract.py +2208 -0
  32. package/_bundled_plugin/scripts/finding_preview.py +270 -0
  33. package/_bundled_plugin/scripts/generate_rank_input.py +1013 -0
  34. package/_bundled_plugin/scripts/normalize_candidates.py +320 -0
  35. package/_bundled_plugin/scripts/rank_preview.py +968 -0
  36. package/_bundled_plugin/scripts/report_projection.py +844 -0
  37. package/_bundled_plugin/scripts/resolve_security_md.py +158 -0
  38. package/_bundled_plugin/scripts/snapshot_sqlite.py +26 -0
  39. package/_bundled_plugin/scripts/validate_report_format.py +138 -0
  40. package/_bundled_plugin/scripts/validate_scan_contract.py +108 -0
  41. package/_bundled_plugin/scripts/validate_tracking_source.py +92 -0
  42. package/_bundled_plugin/scripts/windows_scan_local_files.py +612 -0
  43. package/_bundled_plugin/scripts/workbench/__init__.py +1 -0
  44. package/_bundled_plugin/scripts/workbench/handoff.py +238 -0
  45. package/_bundled_plugin/scripts/workbench_cli.py +325 -0
  46. package/_bundled_plugin/scripts/workbench_constants.py +81 -0
  47. package/_bundled_plugin/scripts/workbench_db.py +3728 -0
  48. package/_bundled_plugin/scripts/workbench_native_indexes.py +242 -0
  49. package/_bundled_plugin/scripts/workbench_progress.py +226 -0
  50. package/_bundled_plugin/scripts/workbench_remediation.py +125 -0
  51. package/_bundled_plugin/scripts/workbench_scan_history.py +829 -0
  52. package/_bundled_plugin/scripts/workbench_scan_start.py +149 -0
  53. package/_bundled_plugin/scripts/workbench_schema.py +714 -0
  54. package/_bundled_plugin/scripts/workbench_source_excerpt.py +99 -0
  55. package/_bundled_plugin/scripts/workbench_target.py +469 -0
  56. package/_bundled_plugin/scripts/workbench_target_state.py +63 -0
  57. package/_bundled_plugin/scripts/workbench_validation.py +294 -0
  58. package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +117 -0
  59. package/_bundled_plugin/skills/attack-path-analysis/agents/openai.yaml +4 -0
  60. package/_bundled_plugin/skills/attack-path-analysis/references/attack-path-facts.md +76 -0
  61. package/_bundled_plugin/skills/attack-path-analysis/references/severity-policy.md +153 -0
  62. package/_bundled_plugin/skills/deep-security-scan/SKILL.md +166 -0
  63. package/_bundled_plugin/skills/deep-security-scan/agents/openai.yaml +4 -0
  64. package/_bundled_plugin/skills/define-security-policy/SKILL.md +93 -0
  65. package/_bundled_plugin/skills/define-security-policy/agents/openai.yaml +4 -0
  66. package/_bundled_plugin/skills/finding-discovery/SKILL.md +155 -0
  67. package/_bundled_plugin/skills/finding-discovery/agents/openai.yaml +4 -0
  68. package/_bundled_plugin/skills/fix-finding/SKILL.md +112 -0
  69. package/_bundled_plugin/skills/fix-finding/agents/openai.yaml +4 -0
  70. package/_bundled_plugin/skills/propose-security-hardening/SKILL.md +240 -0
  71. package/_bundled_plugin/skills/propose-security-hardening/agents/openai.yaml +4 -0
  72. package/_bundled_plugin/skills/propose-security-hardening/references/proposal-format.md +424 -0
  73. package/_bundled_plugin/skills/security-diff-scan/SKILL.md +167 -0
  74. package/_bundled_plugin/skills/security-diff-scan/agents/openai.yaml +4 -0
  75. package/_bundled_plugin/skills/security-scan/SKILL.md +42 -0
  76. package/_bundled_plugin/skills/security-scan/agents/openai.yaml +4 -0
  77. package/_bundled_plugin/skills/security-scan/references/repository-wide-scan.md +48 -0
  78. package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +85 -0
  79. package/_bundled_plugin/skills/threat-model/SKILL.md +59 -0
  80. package/_bundled_plugin/skills/threat-model/agents/openai.yaml +4 -0
  81. package/_bundled_plugin/skills/threat-model/references/threat-model-guidance.md +48 -0
  82. package/_bundled_plugin/skills/track-findings/SKILL.md +222 -0
  83. package/_bundled_plugin/skills/track-findings/agents/openai.yaml +6 -0
  84. package/_bundled_plugin/skills/track-findings/references/github-security-advisories.md +54 -0
  85. package/_bundled_plugin/skills/track-findings/references/jira.md +77 -0
  86. package/_bundled_plugin/skills/triage-finding/SKILL.md +342 -0
  87. package/_bundled_plugin/skills/triage-finding/agents/openai.yaml +4 -0
  88. package/_bundled_plugin/skills/triage-finding/references/github-rest-intake.md +168 -0
  89. package/_bundled_plugin/skills/triage-finding/references/ticket-intake.md +62 -0
  90. package/_bundled_plugin/skills/triage-finding/references/triage-result-contract.md +108 -0
  91. package/_bundled_plugin/skills/validation/SKILL.md +110 -0
  92. package/_bundled_plugin/skills/validation/agents/openai.yaml +4 -0
  93. package/_bundled_plugin/skills/validation/references/validation-guidance.md +122 -0
  94. package/_bundled_plugin/skills/vulnerability-writeup/SKILL.md +263 -0
  95. package/_bundled_plugin/skills/vulnerability-writeup/agents/openai.yaml +4 -0
  96. package/_bundled_plugin/skills/vulnerability-writeup/references/report-format.md +104 -0
  97. package/bin/codex-security.mjs +26 -0
  98. package/dist/api.d.ts +112 -0
  99. package/dist/api.d.ts.map +1 -0
  100. package/dist/api.js +1051 -0
  101. package/dist/api.js.map +1 -0
  102. package/dist/auth.d.ts +29 -0
  103. package/dist/auth.d.ts.map +1 -0
  104. package/dist/auth.js +246 -0
  105. package/dist/auth.js.map +1 -0
  106. package/dist/bulk-scan-discovery.d.ts +35 -0
  107. package/dist/bulk-scan-discovery.d.ts.map +1 -0
  108. package/dist/bulk-scan-discovery.js +217 -0
  109. package/dist/bulk-scan-discovery.js.map +1 -0
  110. package/dist/cli.d.ts +67 -0
  111. package/dist/cli.d.ts.map +1 -0
  112. package/dist/cli.js +2128 -0
  113. package/dist/cli.js.map +1 -0
  114. package/dist/config.d.ts +19 -0
  115. package/dist/config.d.ts.map +1 -0
  116. package/dist/config.js +199 -0
  117. package/dist/config.js.map +1 -0
  118. package/dist/contract.d.ts +21 -0
  119. package/dist/contract.d.ts.map +1 -0
  120. package/dist/contract.js +848 -0
  121. package/dist/contract.js.map +1 -0
  122. package/dist/cost.d.ts +30 -0
  123. package/dist/cost.d.ts.map +1 -0
  124. package/dist/cost.js +280 -0
  125. package/dist/cost.js.map +1 -0
  126. package/dist/errors.d.ts +38 -0
  127. package/dist/errors.d.ts.map +1 -0
  128. package/dist/errors.js +52 -0
  129. package/dist/errors.js.map +1 -0
  130. package/dist/index.d.ts +22 -0
  131. package/dist/index.d.ts.map +1 -0
  132. package/dist/index.js +11 -0
  133. package/dist/index.js.map +1 -0
  134. package/dist/knowledge-base.d.ts +7 -0
  135. package/dist/knowledge-base.d.ts.map +1 -0
  136. package/dist/knowledge-base.js +181 -0
  137. package/dist/knowledge-base.js.map +1 -0
  138. package/dist/models.d.ts +231 -0
  139. package/dist/models.d.ts.map +1 -0
  140. package/dist/models.js +3 -0
  141. package/dist/models.js.map +1 -0
  142. package/dist/multiscan.d.ts +30 -0
  143. package/dist/multiscan.d.ts.map +1 -0
  144. package/dist/multiscan.js +397 -0
  145. package/dist/multiscan.js.map +1 -0
  146. package/dist/result.d.ts +39 -0
  147. package/dist/result.d.ts.map +1 -0
  148. package/dist/result.js +71 -0
  149. package/dist/result.js.map +1 -0
  150. package/dist/runtime.d.ts +69 -0
  151. package/dist/runtime.d.ts.map +1 -0
  152. package/dist/runtime.js +997 -0
  153. package/dist/runtime.js.map +1 -0
  154. package/dist/scan-comparison.d.ts +42 -0
  155. package/dist/scan-comparison.d.ts.map +1 -0
  156. package/dist/scan-comparison.js +153 -0
  157. package/dist/scan-comparison.js.map +1 -0
  158. package/dist/scan-history-renderer.d.ts +13 -0
  159. package/dist/scan-history-renderer.d.ts.map +1 -0
  160. package/dist/scan-history-renderer.js +297 -0
  161. package/dist/scan-history-renderer.js.map +1 -0
  162. package/dist/targets.d.ts +39 -0
  163. package/dist/targets.d.ts.map +1 -0
  164. package/dist/targets.js +295 -0
  165. package/dist/targets.js.map +1 -0
  166. package/dist/trusted-executable.d.ts +6 -0
  167. package/dist/trusted-executable.d.ts.map +1 -0
  168. package/dist/trusted-executable.js +77 -0
  169. package/dist/trusted-executable.js.map +1 -0
  170. package/dist/version.d.ts +6 -0
  171. package/dist/version.d.ts.map +1 -0
  172. package/dist/version.js +42 -0
  173. package/dist/version.js.map +1 -0
  174. package/dist/worker-progress.d.ts +13 -0
  175. package/dist/worker-progress.d.ts.map +1 -0
  176. package/dist/worker-progress.js +113 -0
  177. package/dist/worker-progress.js.map +1 -0
  178. package/package.json +74 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 OpenAI
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,306 @@
1
+ # `@openai/codex-security`
2
+
3
+ Open-source TypeScript SDK and CLI for running Codex Security scans. The
4
+ ESM-only package includes TypeScript declarations, the `codex-security`
5
+ executable, and the matching Codex runtime.
6
+
7
+ > [!NOTE]
8
+ > This package follows semantic versioning. Its public API may change between
9
+ > minor versions before `1.0.0`.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @openai/codex-security
15
+ npx codex-security --version
16
+ ```
17
+
18
+ The package supports macOS, Linux, and Windows and requires Node.js 22 or
19
+ later. Scanning and exporting findings also require Python 3.10 or later. If
20
+ you use Python 3.10, install the `tomli` package. Select another interpreter
21
+ with `--python`, `pythonPath`, or `PYTHON` when needed.
22
+
23
+ ## Run a scan from TypeScript
24
+
25
+ Sign in with `npx codex-security login` or set `OPENAI_API_KEY` or
26
+ `CODEX_API_KEY`. Then create a client and scan a repository you own or have
27
+ permission to assess:
28
+
29
+ ```ts
30
+ import { CodexSecurity } from "@openai/codex-security";
31
+
32
+ const security = new CodexSecurity();
33
+
34
+ try {
35
+ const result = await security.run("/path/to/repository", {
36
+ outputDir: "/path/outside/repository/results",
37
+ });
38
+
39
+ console.log(result.reportPath);
40
+ console.log(result.findings.findings.length);
41
+ } finally {
42
+ await security.close();
43
+ }
44
+ ```
45
+
46
+ The SDK supports repository, path, committed-diff, and working-tree targets.
47
+ Use `security.preflight()` to validate local inputs, `onWorkerStatus` and
48
+ `onReconnect` to observe long-running scans, and an `AbortSignal` to cancel a
49
+ scan.
50
+
51
+ Results can contain source excerpts, vulnerability details, and reproduction
52
+ steps. Keep result directories and saved reports outside the repository and
53
+ limit access to authorized reviewers.
54
+
55
+ ## Authentication
56
+
57
+ For local use, sign in with ChatGPT:
58
+
59
+ ```bash
60
+ npx codex-security login
61
+ npx codex-security scan .
62
+ ```
63
+
64
+ On a remote or headless machine, use device authentication:
65
+
66
+ ```bash
67
+ npx codex-security login --device-auth
68
+ ```
69
+
70
+ For CI, set `OPENAI_API_KEY` or `CODEX_API_KEY`. To store an API key instead,
71
+ pass it on stdin:
72
+
73
+ ```bash
74
+ printenv OPENAI_API_KEY | npx codex-security login --with-api-key
75
+ ```
76
+
77
+ On Windows, set the API key in PowerShell:
78
+
79
+ ```powershell
80
+ $env:OPENAI_API_KEY = "<your-api-key>"
81
+ npx codex-security scan C:\code\repository
82
+ ```
83
+
84
+ Check or remove the stored sign-in with `npx codex-security login status` and
85
+ `npx codex-security logout`. Codex Security reuses an existing file-based Codex
86
+ sign-in. If Codex stores credentials in the system keyring, run
87
+ `npx codex-security login` once before scanning.
88
+
89
+ An environment API key takes precedence over a stored sign-in. Unset both
90
+ `OPENAI_API_KEY` and `CODEX_API_KEY` to use your ChatGPT sign-in. When an
91
+ environment key is configured, `codex-security login status` identifies the
92
+ effective credential source without printing its value, including when no
93
+ stored sign-in exists.
94
+
95
+ ## CLI
96
+
97
+ ```bash
98
+ npx codex-security scan /path/to/repository
99
+ npx codex-security scan /path/to/repository --model gpt-5.6-terra
100
+ npx codex-security scan /path/to/repository --path src --path tests
101
+ npx codex-security scan /path/to/repository --knowledge-base /path/to/threat-models --knowledge-base /path/to/architecture.pdf
102
+ npx codex-security scan /path/to/repository --diff origin/main --json
103
+ npx codex-security scan /path/to/repository --output-dir /path/outside/repository/results
104
+ npx codex-security scan /path/to/repository --output-dir /path/outside/repository/results --archive-existing
105
+ npx codex-security scan /path/to/repository --dry-run
106
+ npx codex-security scan /path/to/repository --fail-on-severity high
107
+ npx codex-security scan /path/to/repository --max-cost 5
108
+ npx codex-security install-hook
109
+ npx codex-security bulk-scan
110
+ npx codex-security bulk-scan repositories.csv --output-dir /path/outside/repositories/security-scans --workers 4
111
+ npx codex-security scans list /path/to/repository
112
+ npx codex-security scans list --scan-root /path/outside/repository/results
113
+ npx codex-security scans show SCAN_ID
114
+ npx codex-security scans rerun SCAN_ID
115
+ npx codex-security scans match PREVIOUS_SCAN_ID CURRENT_SCAN_ID
116
+ npx codex-security scans match --all
117
+ npx codex-security scans compare PREVIOUS_SCAN_ID CURRENT_SCAN_ID
118
+ npx codex-security export /path/outside/repository/results --export-format sarif --output /path/outside/repository/results.sarif
119
+ npx codex-security export /path/outside/repository/results --export-format csv --output /path/outside/repository/findings.csv
120
+ npx codex-security export /path/outside/repository/results --export-format json --output /path/outside/repository/findings.json
121
+ npx codex-security validate /path/outside/repository/findings.json "Possible SQL injection in src/query.ts:42"
122
+ npx codex-security patch /path/outside/repository/findings.json "Missing authorization check in src/routes.ts:18"
123
+ ```
124
+
125
+ Run `npx codex-security --version` for the installed CLI version or
126
+ `npx codex-security info --json` for the package, bundled plugin, Codex runtime,
127
+ default model, reasoning effort, and first-scan command. A scan with `--dry-run`
128
+ also reports its effective model and reasoning effort, including `--codex`
129
+ overrides, without starting Codex or contacting the network.
130
+
131
+ `install-hook` scans staged and unstaged changes before each commit. It respects
132
+ `core.hooksPath`, does not replace an existing hook, and blocks high-severity
133
+ findings or failed scans. Set `--fail-on-severity` to change the threshold.
134
+
135
+ `--path` scopes a scan to one or more paths, `--diff` scans committed changes,
136
+ and `--working-tree` scans staged and unstaged changes. Deep scans support
137
+ repository and path targets. The output directory must be outside the scanned
138
+ directory and any enclosing Git worktree. When SARIF is produced, it is written
139
+ to
140
+ `<scan-dir>/exports/results.sarif`.
141
+
142
+ Repeat `--knowledge-base PATH` for multiple files or directories. Directories are
143
+ searched recursively for Markdown, text, PDF, and Word (`.docx`) files.
144
+
145
+ On macOS/Linux, an existing output directory must be private to the current
146
+ user (`chmod 700`).
147
+
148
+ If the output directory already contains results, add `--archive-existing`.
149
+ The CLI moves them to `<output-dir>.previous-<timestamp>-<id>` and starts the
150
+ scan in a new, empty directory at the original path. Add `--dry-run` to see
151
+ the destination without moving files.
152
+
153
+ Scans are report-only by default. Use `--fail-on-severity` in CI to exit 1 when
154
+ a completed scan contains a finding at or above the selected severity.
155
+ Incomplete coverage and CLI/runtime errors exit 2 so they cannot be mistaken
156
+ for a passing policy. Incomplete scans still write the available human or JSON
157
+ result to stdout and a coverage warning to stderr, including in report-only
158
+ mode.
159
+
160
+ Scans use `gpt-5.6-sol` with extra-high reasoning effort by default. Use
161
+ `--model gpt-5.6-terra` to switch models. Use repeatable `--codex KEY=VALUE`
162
+ options for other Codex settings, such as
163
+ `--codex 'model_reasoning_effort="high"'`.
164
+
165
+ Scan progress identifies the requested paths and reports actual ranking,
166
+ file-review, validation, and attack-path phases as they become available.
167
+ Completion summarizes findings, severity, coverage, elapsed time, available
168
+ token and worker counts, estimated cost, the results directory, and the next
169
+ useful command.
170
+ Progress and summaries use stderr; structured scan results remain on stdout.
171
+
172
+ Each scan records its model, tokens, and estimated cost in its JSON result,
173
+ scan history, and bulk-scan receipt. Estimates use
174
+ [standard API token prices](https://developers.openai.com/api/docs/models/compare),
175
+ including cached input and cache writes; fees and surcharges are not included.
176
+
177
+ Use `--max-cost USD` to stop a scan, including its delegated workers, when its
178
+ running cost exceeds the limit. Partial results are preserved. Requests
179
+ already in progress can finish above the limit.
180
+
181
+ Run `npx codex-security scan --help` or `npx codex-security bulk-scan --help`
182
+ for the complete CLI references.
183
+
184
+ Sign in with `gh auth login`, then run `npx codex-security bulk-scan` to discover
185
+ GitHub repositories pushed in the last 90 days. Archived
186
+ repositories and forks are excluded. Search the repository list, select the
187
+ repositories to scan, and confirm before scanning.
188
+ Private checkouts reuse your GitHub CLI sign-in without changing your global Git
189
+ configuration. The selected repositories are saved to
190
+ `<output-dir>/repositories.csv` for review or resumption.
191
+
192
+ To use an existing repository list or run in CI, pass a CSV with required `id`,
193
+ `repository`, and `revision` columns. Revisions must be full commit hashes;
194
+ optional `scope` and `mode` columns narrow individual scans:
195
+
196
+ ```csv
197
+ id,repository,revision,scope,mode
198
+ service,https://github.com/acme/service.git,0123456789abcdef0123456789abcdef01234567,src,standard
199
+ ```
200
+
201
+ `--workers` limits concurrent scans and `--max-attempts` retries failures.
202
+ Results remain under `--output-dir`; rerun the same command to resume.
203
+
204
+ ### Scan history and reruns
205
+
206
+ `npx codex-security scans list` lists scans for the current repository. Pass a
207
+ repository path to inspect another checkout, `--scan-root DIR` to list scans
208
+ whose artifacts are under a particular root. `scans show SCAN_ID` includes the
209
+ scan configuration, results, coverage, and artifact locations.
210
+
211
+ Every scan history command accepts a full scan ID or a unique prefix of at
212
+ least eight characters.
213
+
214
+ Scan history uses the existing Codex Security workbench database at
215
+ `$CODEX_HOME/state/plugins/codex-security/workbench.sqlite3`. Set
216
+ `CODEX_SECURITY_STATE_DIR` to place the database elsewhere. Scan credentials
217
+ are never stored in the scan configuration.
218
+
219
+ `scans rerun SCAN_ID` repeats the original configuration against the current
220
+ checkout so a fixed vulnerability can be checked again.
221
+
222
+ `scans match BEFORE_SCAN_ID AFTER_SCAN_ID` links findings with the same root
223
+ cause; `scans match --all` matches all completed scans of the current repository,
224
+ including other worktrees and clones. Saved matches appear in `scans show` and
225
+ are reused unless `--force` is passed. Scans without sealed artifacts are skipped.
226
+
227
+ `scans compare BEFORE_SCAN_ID AFTER_SCAN_ID` reads saved matches and reports
228
+ findings as new, persisting, reopened, resolved, or unknown. Missing findings
229
+ are not treated as resolved when the later scan is incomplete or does not cover
230
+ their original scope.
231
+
232
+ The CLI uses [Incur](https://github.com/wevm/incur) for agent-friendly discovery
233
+ and structured output. Inspect the command manifest with `--llms`, inspect a
234
+ command schema with `scan --schema --format json`, register the CLI as an MCP
235
+ server with `mcp add`, sync agent skills with `skills add`, or generate shell
236
+ completions with `completions bash|zsh|fish`. Scan results support
237
+ `--format toon|json|yaml|jsonl` and `--full-output`.
238
+ Use `info --json` for SDK and bundled-plugin metadata. MCP exposes only this
239
+ read-only metadata command; scans, bulk repository scans,
240
+ authentication, exports, validation, and patching remain CLI-only because the
241
+ MCP transport cannot cancel active scans.
242
+
243
+ For CI, save machine-readable output outside the checked-out repository and
244
+ apply a severity policy. Incomplete coverage and runtime errors still exit
245
+ nonzero:
246
+
247
+ ```bash
248
+ SCAN_ROOT="$(mktemp -d)"
249
+ npx codex-security scan . \
250
+ --diff origin/main \
251
+ --output-dir "$SCAN_ROOT/results" \
252
+ --json \
253
+ --fail-on-severity high > "$SCAN_ROOT/findings.json"
254
+ ```
255
+
256
+ JSON scans never use interactive terminal controls, even when stderr is a TTY.
257
+ The `validate`, `patch`, `login`, and `logout` commands reject `--json` because
258
+ they do not produce structured CLI output. Sign-in commands remain interactive.
259
+ CSV exports cannot be written to stdout while JSON output is requested.
260
+
261
+ Use `export` to create CSV, JSON, or SARIF from a completed, sealed scan without
262
+ starting Codex or loading credentials. JSON preserves the sealed findings
263
+ document. CSV uses the portable findings columns, marks findings as open, and
264
+ does not include local workbench triage state. The exporter validates the seal
265
+ before writing, accepts `--output -` for stdout, and can use
266
+ `--source-root /path/to/repository` with SARIF to add source-line fingerprints.
267
+ Run `npx codex-security export --help` for all export options.
268
+
269
+ Use `validate` to run the bundled validation skill on candidate findings and
270
+ `patch` to run the bundled fix-finding skill on security issues. Each positional
271
+ input can be either a file, whose contents are read into the request, or literal
272
+ text. Both commands operate on the current directory, use the scan model
273
+ and reasoning defaults, ignore unrelated user configuration and plugins, and
274
+ print the final response without the underlying Codex event stream. Override
275
+ the model or reasoning effort with `--codex 'model="gpt-5.6-sol"'` or
276
+ `--codex 'model_reasoning_effort="high"'`. Inputs are limited to 64 items and
277
+ 1 MiB total.
278
+
279
+ Canonical scan documents are limited to 16 MiB for the manifest, 128 MiB for
280
+ findings, and 32 MiB for coverage. Oversized scans are rejected before sealing.
281
+
282
+ Exit codes are `0` for a completed report-only scan or a passing policy, `1`
283
+ for a completed policy violation, `2` for invalid input, incomplete coverage, or
284
+ a runtime/export error, `130` for interruption, and `143` for termination.
285
+
286
+ Use `--dry-run` or `await security.preflight(...)` to validate the repository,
287
+ target, mode, output location, and Codex overrides without initializing the
288
+ runtime or loading credentials. Dry runs do not inspect the plugin or probe its
289
+ Python interpreter. The preflight result includes the selected authentication
290
+ method and, for an environment API key, its variable name. Authentication and
291
+ model access remain unverified until a real scan starts.
292
+
293
+ Scan progress identifies the selected credential source before Codex starts.
294
+ Interactive terminals also show how to retry with ChatGPT when an environment
295
+ API key overrides the stored sign-in. Progress remains on stderr so JSON output
296
+ stays machine readable. Recoverable failures include safe retry causes and,
297
+ when available, the server-provided retry delay.
298
+
299
+ ## Documentation and security
300
+
301
+ - [CLI quickstart](https://developers.openai.com/codex/security/cli)
302
+ - [TypeScript SDK guide](https://developers.openai.com/codex/security/sdk)
303
+ - [GitHub issues](https://github.com/openai/codex-security/issues) for bugs and
304
+ feature requests
305
+ - [Security policy](https://github.com/openai/codex-security/blob/main/SECURITY.md)
306
+ for private vulnerability reporting and safe operation
@@ -0,0 +1,20 @@
1
+ {
2
+ "apps": {
3
+ "linear": {
4
+ "id": "asdk_app_69a089a326dc8191b32a3f2553f5be2c",
5
+ "category": "Work Tracking & Coordination"
6
+ },
7
+ "github": {
8
+ "id": "connector_76869538009648d5b282a4bb21c3d157",
9
+ "category": "Code Hosting & Security Findings"
10
+ },
11
+ "atlassian": {
12
+ "id": "connector_692de805e3ec8191834719067174a384",
13
+ "category": "Work Tracking & Coordination",
14
+ "capabilities": [
15
+ "read",
16
+ "write"
17
+ ]
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "codex-security",
3
+ "version": "0.1.14",
4
+ "description": "Codex Security workflows for security scans, analysis, and investigation.",
5
+ "author": {
6
+ "name": "OpenAI"
7
+ },
8
+ "homepage": "https://developers.openai.com/codex/security",
9
+ "repository": "https://github.com/openai/codex-security",
10
+ "license": "Apache-2.0",
11
+ "keywords": [
12
+ "security",
13
+ "code-review",
14
+ "diff-review",
15
+ "appsec",
16
+ "threat-modeling"
17
+ ],
18
+ "skills": "./skills/",
19
+ "apps": "./.app.json",
20
+ "mcpServers": "./.mcp.json",
21
+ "interface": {
22
+ "displayName": "Codex Security",
23
+ "shortDescription": "Security scanning for your codebase",
24
+ "longDescription": "Codex Security packages reusable workflows for security scans, analysis, validation, and investigation across code, diffs, and related artifacts.",
25
+ "developerName": "OpenAI",
26
+ "category": "Security",
27
+ "capabilities": ["Interactive", "Read", "Write"],
28
+ "websiteURL": "https://openai.com/",
29
+ "privacyPolicyURL": "https://openai.com/policies/row-privacy-policy/",
30
+ "termsOfServiceURL": "https://openai.com/policies/row-terms-of-use/",
31
+ "defaultPrompt": [
32
+ "Run a Codex Security scan on this repository.",
33
+ "Run a Codex Security diff scan on this PR, commit, branch diff, or working-tree patch.",
34
+ "Triage existing security findings against this repository."
35
+ ],
36
+ "brandColor": "#111111",
37
+ "composerIcon": "./assets/logo.png",
38
+ "logo": "./assets/logo.png",
39
+ "screenshots": []
40
+ }
41
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "mcpServers": {
3
+ "codex-security": {
4
+ "command": "node",
5
+ "args": ["./mcp/server.mjs", "--stdio"],
6
+ "cwd": ".",
7
+ "env_vars": [
8
+ "CODEX_HOME",
9
+ "CODEX_SQLITE_HOME",
10
+ "CODEX_API_KEY",
11
+ "CODEX_CLI_PATH",
12
+ "PYTHON",
13
+ "CODEX_SECURITY_KNOWLEDGE_BASE",
14
+ "CODEX_SECURITY_SCAN_ROOT",
15
+ "CODEX_SECURITY_STATE_DIR"
16
+ ],
17
+ "tool_timeout_sec": 86400
18
+ }
19
+ }
20
+ }
Binary file
@@ -0,0 +1,22 @@
1
+ {
2
+ "documentType": "codex-security.coverage",
3
+ "schemaVersion": "1.0",
4
+ "scanId": "scan_example_001",
5
+ "mode": "repository",
6
+ "completeness": "complete",
7
+ "inventoryStrategy": "repository",
8
+ "includePaths": [
9
+ "src/"
10
+ ],
11
+ "excludePaths": [],
12
+ "surfaces": [
13
+ {
14
+ "id": "surface_archive_extraction",
15
+ "label": "Archive extraction",
16
+ "disposition": "reported",
17
+ "receiptRefs": []
18
+ }
19
+ ],
20
+ "explicitExclusions": [],
21
+ "deferred": []
22
+ }
@@ -0,0 +1,51 @@
1
+ {
2
+ "documentType": "codex-security.findings",
3
+ "schemaVersion": "1.0",
4
+ "scanId": "scan_example_001",
5
+ "findings": [
6
+ {
7
+ "findingId": "csf_852f90d6e1177502ff113d4a",
8
+ "occurrenceId": "occ_e79cb19591e696572a1c22be",
9
+ "ruleId": "path-traversal.archive-extraction",
10
+ "identity": {
11
+ "anchor": "archive-entry-write-without-containment"
12
+ },
13
+ "fingerprints": {
14
+ "algorithm": "codex-security/v1",
15
+ "primary": "codex-security/v1:sha256:990a4a6a2ec18440dd47eac4d7256c0ee2c02db1b43104720cab3cbe9db706ca"
16
+ },
17
+ "title": "Unsafe archive extraction can escape the output directory",
18
+ "summary": "An attacker-controlled path reaches a filesystem write without containment validation.",
19
+ "severity": {
20
+ "level": "high",
21
+ "score": 8.1,
22
+ "scoringSystem": "CVSS:3.1"
23
+ },
24
+ "confidence": {
25
+ "level": "high",
26
+ "rationale": "Direct source trace reaches the filesystem write without a containment check."
27
+ },
28
+ "taxonomy": {
29
+ "category": "path-traversal",
30
+ "cwe": [
31
+ "CWE-22"
32
+ ]
33
+ },
34
+ "locations": [
35
+ {
36
+ "path": "src/extract.py",
37
+ "startLine": 41,
38
+ "endLine": 44,
39
+ "role": "sink"
40
+ }
41
+ ],
42
+ "remediation": "Normalize destinations and reject entries that escape the extraction root.",
43
+ "validation": null,
44
+ "attackPath": null,
45
+ "provenance": {
46
+ "source": "local_plugin"
47
+ },
48
+ "extensions": {}
49
+ }
50
+ ]
51
+ }