Skip to content

Commit 1a9fc9b

Browse files
fix: document CLI help and deep-scan configuration (#105)
* fix: document CLI options and isolated scan configuration * fix: clarify interactive JSON and JSONL errors
1 parent 8d9eb30 commit 1a9fc9b

4 files changed

Lines changed: 479 additions & 61 deletions

File tree

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`@openai/codex-security` is a CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities in your code.
44

5-
**See the [Codex Security Documentation](http://learn.chatgpt.com/docs/security/cli)** for more details.
5+
**See the [Codex Security documentation](https://learn.chatgpt.com/docs/security/cli)** for more details.
66

77
> Note: for best results, we recommend that your account is verified for [Trusted Access](https://chatgpt.com/cyber).
88
@@ -17,7 +17,7 @@ npx @openai/codex-security scan .
1717
npx @openai/codex-security scan . --model gpt-5.6-terra --effort high
1818
```
1919

20-
For CI, set `OPENAI_API_KEY` instead of signing in.
20+
For CI, set `OPENAI_API_KEY` or `CODEX_API_KEY` instead of signing in.
2121

2222
If both a ChatGPT sign-in and an API key are available, interactive scans ask
2323
which credential to use. CI and other noninteractive scans keep the existing
@@ -51,4 +51,7 @@ console.log(result.reportPath);
5151
await security.close();
5252
```
5353

54-
For installation, authentication, scan options, and CI setup, see the [official documentation](http://learn.chatgpt.com/docs/security/cli).
54+
For complete command help, runtime defaults, native multi-agent worker limits,
55+
environment variables, deep-scan configuration, and SDK options, see the
56+
[package README](sdk/typescript/README.md) and the
57+
[official CLI reference](https://learn.chatgpt.com/docs/security/cli/reference).

sdk/typescript/README.md

Lines changed: 157 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,39 @@ Results can contain source excerpts, vulnerability details, and reproduction
5656
steps. Keep result directories and saved reports outside the repository and
5757
limit access to authorized reviewers.
5858

59+
### SDK configuration and scan options
60+
61+
Pass runtime configuration to the `CodexSecurity` constructor:
62+
63+
| Option | Description |
64+
| ---------------- | --------------------------------------------------------------------------- |
65+
| `pluginPath` | Use a Codex Security plugin directory or ZIP instead of the bundled plugin. |
66+
| `pythonPath` | Select the Python interpreter before consulting `PYTHON`. |
67+
| `codexOverrides` | Deep-merge supported settings into the isolated Codex configuration. |
68+
69+
Pass scan configuration to `security.run(repository, options)` or
70+
`security.preflight(repository, options)`:
71+
72+
| Option | Description |
73+
| ----------------------- | ------------------------------------------------------------------------------------- |
74+
| `auth` | Select `"auto"`, `"chatgpt"`, or `"api-key"`. |
75+
| `target` | Select a repository, repository-relative paths, committed diff, or working-tree diff. |
76+
| `mode` | Select `"standard"` or `"deep"`; deep mode supports repositories and paths. |
77+
| `knowledgeBasePaths` | Add architecture documents, security policies, threat models, or directories. |
78+
| `outputDir` | Choose an artifact directory outside the enclosing Git worktree. |
79+
| `archiveExisting` | Archive results already in `outputDir` before starting a scan. |
80+
| `maxCostUsd` | Stop after the estimated model cost exceeds a positive USD amount. |
81+
| `failureSeverity` | Record a finding-severity policy in the saved scan recipe. |
82+
| `parentScanId` | Link a rerun to an existing parent scan. |
83+
| `expectedPluginVersion` | Require the original plugin version when replaying a scan. |
84+
| `signal` | Cancel a scan with an `AbortSignal`. |
85+
86+
Progress and lifecycle callbacks are `onAuthentication`, `onCost`,
87+
`onOutputArchived`, `onOutputDirReady`, `onScanStarted`, `onReconnect`,
88+
`onWorkerStatus`, `onWarning`, and `onObserverError`. Preflight does not start
89+
the runtime, authenticate, resolve Python, inspect the plugin, or run those
90+
scan-lifecycle callbacks.
91+
5992
## Authentication
6093

6194
For local use, sign in with ChatGPT:
@@ -78,6 +111,10 @@ pass it on stdin:
78111
printenv OPENAI_API_KEY | npx @openai/codex-security login --with-api-key
79112
```
80113

114+
To pass a Codex access token explicitly, use
115+
`login --with-access-token` and provide the token on stdin. An access token
116+
environment variable is not automatically used as a scan API key.
117+
81118
On Windows, set the API key in PowerShell:
82119

83120
```powershell
@@ -197,9 +234,127 @@ the implied provider. Use `--model gpt-5.6-terra` to switch models and
197234
`--codex KEY=VALUE` for other Codex settings; existing
198235
`--codex 'model_reasoning_effort="high"'` overrides remain supported.
199236

237+
### Runtime configuration and worker limits
238+
239+
The standalone CLI and SDK do not load an unrelated user or repository Codex
240+
configuration. Each scan starts with a private runtime and these Codex
241+
defaults:
242+
243+
```toml
244+
cli_auth_credentials_store = "file"
245+
model = "gpt-5.6-sol"
246+
model_reasoning_effort = "xhigh"
247+
248+
[features]
249+
plugins = true
250+
goals = true
251+
252+
[features.multi_agent_v2]
253+
enabled = true
254+
max_concurrent_threads_per_session = 9
255+
256+
[windows]
257+
sandbox = "unelevated"
258+
```
259+
260+
Use `--model` and `--effort` for model selection. Repeat
261+
`--codex KEY=VALUE` to deep-merge other TOML values into this isolated
262+
configuration:
263+
264+
```bash
265+
npx @openai/codex-security scan . \
266+
--model gpt-5.6-terra \
267+
--effort high \
268+
--codex features.multi_agent_v2.max_concurrent_threads_per_session=4
269+
```
270+
271+
The session thread limit includes the parent agent: the default of `9`
272+
provides up to eight delegated worker slots. This limit is separate from
273+
`bulk-scan --workers`, which controls how many repositories run concurrently.
274+
A configured limit is a maximum, not evidence that every worker started.
275+
276+
Quote string values as TOML, for example
277+
`--codex 'model_reasoning_effort="high"'`. Do not pass both `--model` and
278+
`--codex 'model="..."'`, or both `--effort` and
279+
`--codex 'model_reasoning_effort="..."'`: conflicting or repeated keys are
280+
rejected.
281+
282+
Plugin and marketplace loading belong to Codex Security. Overrides of
283+
`plugins`, `marketplaces`, or `features.plugins`, including profile-specific
284+
plugin overrides, are rejected; choose `--plugin-path` instead. Native
285+
multi-agent v2 must remain enabled. The legacy `agents.max_threads` setting
286+
and `features.multi_agent_v2.enabled=false` are incompatible and rejected.
287+
`validate` and `patch` accept `--effort` and only the `model` and
288+
`model_reasoning_effort` `--codex` keys; they do not accept general scan
289+
runtime overrides.
290+
200291
These overrides do not change the scan's approval policy or filesystem
201292
permissions. See [Local security model](#local-security-model).
202293

294+
### Deep-scan engine configuration
295+
296+
When the bundled plugin runs in a normal Codex host, its repeated-discovery
297+
engine reads `$CODEX_HOME/codex-security/config.toml`, defaulting to
298+
`~/.codex/codex-security/config.toml`:
299+
300+
```toml
301+
[deep_scan]
302+
workers = "auto"
303+
subagents = 3
304+
stop_after_no_new = 6
305+
max_discovery_runs = 60
306+
```
307+
308+
`workers = "auto"` uses half the available parallelism, with a minimum of one
309+
and a maximum of six discovery workers. Set `workers` to a positive integer to
310+
choose an explicit count. `subagents` must be a nonnegative integer;
311+
`stop_after_no_new` and `max_discovery_runs` must be positive integers. Unknown
312+
`[deep_scan]` keys are rejected.
313+
314+
These settings are separate from Codex's
315+
`features.multi_agent_v2.max_concurrent_threads_per_session` and
316+
`bulk-scan --workers`. Importantly, standalone CLI and SDK scans create an
317+
isolated `CODEX_HOME` and do not import the ambient deep-scan configuration
318+
file. Consequently, `scan --mode deep` currently uses the deep engine's
319+
defaults; there are no standalone CLI flags for these four settings. Use
320+
`--codex` to adjust the Codex session thread limit, not to set `[deep_scan]`
321+
values.
322+
323+
### Environment variables
324+
325+
The CLI and SDK recognize the following user-configurable environment:
326+
327+
| Variable | Effect |
328+
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
329+
| `OPENAI_API_KEY`, `CODEX_API_KEY` | Scan authentication; `OPENAI_API_KEY` wins when both are present. |
330+
| `CODEX_SECURITY_STATE_DIR` | Override the private scan-history, workbench, and default artifact directory. |
331+
| `CODEX_HOME` | Set the ambient Codex home for file-backed sign-in and default state; defaults to `~/.codex`. |
332+
| `PYTHON` | Select a Python interpreter when `--python` or SDK `pythonPath` is not set. |
333+
| `GH_HOST` | Select a GitHub Enterprise host during interactive `bulk-scan` discovery. |
334+
| `CODEX_SECURITY_NO_UPDATE_NOTICE`, `NO_UPDATE_NOTIFIER` | Disable interactive update notices when either variable is defined. |
335+
| `CODEX_SECURITY_NPM_REGISTRY`, `npm_config_registry`, `NPM_CONFIG_REGISTRY` | Select the update-check registry, in the listed precedence order. |
336+
| `CI` | Disable interactive update notices in automated environments. |
337+
| `NO_COLOR`, `TERM` | Disable colored scan-history output when `NO_COLOR` is defined or `TERM=dumb`. |
338+
339+
Interpreter discovery uses `--python` or `pythonPath` first, then `PYTHON`,
340+
the managed Codex runtime, and finally `python3` or `python` from `PATH`.
341+
`CODEX_SECURITY_STATE_DIR` takes precedence over `CODEX_HOME`; keep both
342+
state and result paths outside the scanned repository.
343+
344+
The repository's Docker Compose workflow additionally recognizes
345+
`CODEX_SECURITY_IMAGE`, `CODEX_SECURITY_USER`, `CODEX_SECURITY_SECCOMP`,
346+
`CODEX_SECURITY_CSV`, `CODEX_SECURITY_RESULTS`, and `CODEX_SECURITY_STATE` for
347+
its image, runtime user, seccomp profile, input, results, and state mounts.
348+
Provide `GH_TOKEN` or `GITHUB_TOKEN` for private GitHub checkouts and
349+
`CODEX_SECURITY_GIT_HOST` for a GitHub Enterprise host in the container.
350+
These container settings are distinct from standalone CLI flags and
351+
interactive discovery's `GH_HOST`.
352+
353+
Variables such as `CODEX_SECURITY_SCAN_ID`, `CODEX_SECURITY_SCAN_DIR`,
354+
`CODEX_SECURITY_PLUGIN_ROOT`, `CODEX_SECURITY_CONFIG_PATH`, and
355+
`CODEX_SECURITY_TARGET_PATHS_FILE` are generated by an active scan. They are
356+
internal runtime data, not supported user configuration.
357+
203358
Scan progress identifies the requested paths and reports actual ranking,
204359
file-review, validation, and attack-path phases as they become available.
205360
Completion summarizes findings, severity, coverage, elapsed time, available
@@ -244,7 +399,8 @@ Results remain under `--output-dir`; rerun the same command to resume.
244399
`npx @openai/codex-security scans list` lists scans for the current repository. Pass a
245400
repository path to inspect another checkout, `--scan-root DIR` to list scans
246401
whose artifacts are under a particular root. `scans show SCAN_ID` includes the
247-
scan configuration, results, coverage, and artifact locations.
402+
scan configuration, results, coverage, and artifact locations. Add
403+
`--show-linked-findings` to include finding links from previous scans.
248404

249405
Every scan history command accepts a full scan ID or a unique prefix of at
250406
least eight characters.

0 commit comments

Comments
 (0)