Skip to content

Commit b1e2af9

Browse files
fix: make scan authentication and state failures actionable (#22)
1 parent 5b2b216 commit b1e2af9

11 files changed

Lines changed: 958 additions & 45 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,26 @@ npx codex-security scan .
1616

1717
For CI, set `OPENAI_API_KEY` instead of signing in.
1818

19+
If both a ChatGPT sign-in and an API key are available, interactive scans ask
20+
which credential to use. CI and other noninteractive scans keep the existing
21+
API-key precedence. Select a credential explicitly when needed:
22+
23+
```bash
24+
npx codex-security scan . --auth chatgpt
25+
npx codex-security scan . --auth api-key
26+
```
27+
28+
To make your ChatGPT sign-in the automatic default, unset any configured API
29+
keys:
30+
31+
```bash
32+
unset OPENAI_API_KEY CODEX_API_KEY
33+
```
34+
35+
Scan history is stored in the Codex Security workbench state directory. If that
36+
directory cannot be written, set `CODEX_SECURITY_STATE_DIR` to a writable
37+
directory outside the repository.
38+
1939
## TypeScript SDK
2040

2141
```ts

sdk/typescript/README.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,36 @@ Check or remove the stored sign-in with `npx codex-security login status` and
8686
sign-in. If Codex stores credentials in the system keyring, run
8787
`npx codex-security login` once before scanning.
8888

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.
89+
An environment API key takes precedence over a stored sign-in by default.
90+
When both a stored ChatGPT sign-in and an environment API key are available, an
91+
interactive scan asks which credential to use. JSON output, dry runs, CI, and
92+
other noninteractive scans never prompt and retain automatic API-key
93+
precedence. Select the credential source explicitly with `--auth`:
94+
95+
```bash
96+
npx codex-security scan . --auth chatgpt
97+
npx codex-security scan . --auth api-key
98+
```
99+
100+
`--auth chatgpt` uses the stored sign-in and ignores `OPENAI_API_KEY` and
101+
`CODEX_API_KEY`. `--auth api-key` requires one of those environment variables.
102+
Omit `--auth`, or pass `--auth auto`, to preserve automatic API-key precedence
103+
for existing CI and unattended scans. The SDK accepts the same selection as
104+
`security.run(repository, { auth: "chatgpt" })` and
105+
`security.preflight(repository, { auth: "chatgpt" })`.
106+
107+
To make the stored ChatGPT sign-in the automatic default instead, unset any
108+
configured API-key variables:
109+
110+
```bash
111+
unset OPENAI_API_KEY CODEX_API_KEY
112+
```
113+
114+
The interactive choice applies only to the current scan and is not persisted.
115+
116+
When an environment key is configured, ChatGPT login and
117+
`codex-security login status` identify the effective scan credential source
118+
without printing its value, including when no stored sign-in exists.
94119

95120
## CLI
96121

@@ -216,6 +241,14 @@ Scan history uses the existing Codex Security workbench database at
216241
`CODEX_SECURITY_STATE_DIR` to place the database elsewhere. Scan credentials
217242
are never stored in the scan configuration.
218243

244+
The scan sandbox permits writes to the selected state directory so SQLite can
245+
maintain its database and journal files. If the host itself cannot write to the
246+
default directory, select a writable directory outside the scanned repository:
247+
248+
```bash
249+
export CODEX_SECURITY_STATE_DIR=/path/to/writable/codex-security-state
250+
```
251+
219252
`scans rerun SCAN_ID` repeats the original configuration against the current
220253
checkout so a fixed vulnerability can be checked again.
221254

@@ -291,10 +324,11 @@ method and, for an environment API key, its variable name. Authentication and
291324
model access remain unverified until a real scan starts.
292325

293326
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.
327+
Terminals and noninteractive CI logs also show how to retry with
328+
`--auth chatgpt` when an environment API key overrides the stored sign-in.
329+
Progress remains on stderr so JSON output stays machine readable. Network
330+
failures and rate limits remain retryable; definitive authentication and model
331+
authorization failures stop immediately.
298332

299333
## Documentation and security
300334

0 commit comments

Comments
 (0)