@openai/codex-security 0.1.3 → 0.1.4
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.
- package/README.md +176 -9
- package/_bundled_plugin/references/scan-contract.md +2 -0
- package/_bundled_plugin/scripts/workbench_cli.py +4 -0
- package/_bundled_plugin/scripts/workbench_db.py +39 -22
- package/_bundled_plugin/scripts/workbench_scan_start.py +13 -0
- package/dist/api.d.ts +2 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +173 -51
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts +3 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +106 -43
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +29 -1
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +19 -22
- package/dist/contract.js.map +1 -1
- package/dist/runtime.d.ts +11 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +462 -8
- package/dist/runtime.js.map +1 -1
- package/dist/scan-comparison.d.ts +2 -0
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +26 -2
- package/dist/scan-comparison.js.map +1 -1
- package/dist/trusted-executable.js +1 -1
- package/dist/trusted-executable.js.map +1 -1
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -15,10 +15,11 @@ npm install @openai/codex-security
|
|
|
15
15
|
npx @openai/codex-security --version
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
The package supports macOS, Linux, and Windows and requires Node.js 22 or
|
|
19
|
-
later
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
The package supports macOS, Linux, and Windows and requires Node.js 22.13.0 or
|
|
19
|
+
later in the 22.x release line, Node.js 24.x, or Node.js 26.x. Scanning and
|
|
20
|
+
exporting findings also require Python 3.10 or later. If you use Python 3.10,
|
|
21
|
+
install the `tomli` package. Select another interpreter with `--python`,
|
|
22
|
+
`pythonPath`, or `PYTHON` when needed.
|
|
22
23
|
|
|
23
24
|
When a newer version is available, the CLI shows the update command for your
|
|
24
25
|
installation method. Set `CODEX_SECURITY_NO_UPDATE_NOTICE=1` to hide the
|
|
@@ -56,6 +57,39 @@ Results can contain source excerpts, vulnerability details, and reproduction
|
|
|
56
57
|
steps. Keep result directories and saved reports outside the repository and
|
|
57
58
|
limit access to authorized reviewers.
|
|
58
59
|
|
|
60
|
+
### SDK configuration and scan options
|
|
61
|
+
|
|
62
|
+
Pass runtime configuration to the `CodexSecurity` constructor:
|
|
63
|
+
|
|
64
|
+
| Option | Description |
|
|
65
|
+
| ---------------- | --------------------------------------------------------------------------- |
|
|
66
|
+
| `pluginPath` | Use a Codex Security plugin directory or ZIP instead of the bundled plugin. |
|
|
67
|
+
| `pythonPath` | Select the Python interpreter before consulting `PYTHON`. |
|
|
68
|
+
| `codexOverrides` | Deep-merge supported settings into the isolated Codex configuration. |
|
|
69
|
+
|
|
70
|
+
Pass scan configuration to `security.run(repository, options)` or
|
|
71
|
+
`security.preflight(repository, options)`:
|
|
72
|
+
|
|
73
|
+
| Option | Description |
|
|
74
|
+
| ----------------------- | ------------------------------------------------------------------------------------- |
|
|
75
|
+
| `auth` | Select `"auto"`, `"chatgpt"`, or `"api-key"`. |
|
|
76
|
+
| `target` | Select a repository, repository-relative paths, committed diff, or working-tree diff. |
|
|
77
|
+
| `mode` | Select `"standard"` or `"deep"`; deep mode supports repositories and paths. |
|
|
78
|
+
| `knowledgeBasePaths` | Add architecture documents, security policies, threat models, or directories. |
|
|
79
|
+
| `outputDir` | Choose an artifact directory outside the enclosing Git worktree. |
|
|
80
|
+
| `archiveExisting` | Archive results already in `outputDir` before starting a scan. |
|
|
81
|
+
| `maxCostUsd` | Stop after the estimated model cost exceeds a positive USD amount. |
|
|
82
|
+
| `failureSeverity` | Record a finding-severity policy in the saved scan recipe. |
|
|
83
|
+
| `parentScanId` | Link a rerun to an existing parent scan. |
|
|
84
|
+
| `expectedPluginVersion` | Require the original plugin version when replaying a scan. |
|
|
85
|
+
| `signal` | Cancel a scan with an `AbortSignal`. |
|
|
86
|
+
|
|
87
|
+
Progress and lifecycle callbacks are `onAuthentication`, `onCost`,
|
|
88
|
+
`onOutputArchived`, `onOutputDirReady`, `onScanStarted`, `onReconnect`,
|
|
89
|
+
`onWorkerStatus`, `onWarning`, and `onObserverError`. Preflight does not start
|
|
90
|
+
the runtime, authenticate, resolve Python, inspect the plugin, or run those
|
|
91
|
+
scan-lifecycle callbacks.
|
|
92
|
+
|
|
59
93
|
## Authentication
|
|
60
94
|
|
|
61
95
|
For local use, sign in with ChatGPT:
|
|
@@ -78,6 +112,14 @@ pass it on stdin:
|
|
|
78
112
|
printenv OPENAI_API_KEY | npx @openai/codex-security login --with-api-key
|
|
79
113
|
```
|
|
80
114
|
|
|
115
|
+
Environment API keys are supplied directly to the current scan and are never
|
|
116
|
+
saved to the Codex credential home or system keyring. Only an explicit
|
|
117
|
+
`login --with-api-key` stores an API key.
|
|
118
|
+
|
|
119
|
+
To pass a Codex access token explicitly, use
|
|
120
|
+
`login --with-access-token` and provide the token on stdin. An access token
|
|
121
|
+
environment variable is not automatically used as a scan API key.
|
|
122
|
+
|
|
81
123
|
On Windows, set the API key in PowerShell:
|
|
82
124
|
|
|
83
125
|
```powershell
|
|
@@ -85,10 +127,16 @@ $env:OPENAI_API_KEY = "<your-api-key>"
|
|
|
85
127
|
npx @openai/codex-security scan C:\code\repository
|
|
86
128
|
```
|
|
87
129
|
|
|
88
|
-
Check or remove the stored sign-in with `npx @openai/codex-security login status`
|
|
89
|
-
`npx @openai/codex-security logout`. Codex Security
|
|
90
|
-
|
|
91
|
-
|
|
130
|
+
Check or remove the stored sign-in with `npx @openai/codex-security login status`
|
|
131
|
+
and `npx @openai/codex-security logout`. Codex Security keeps its sign-in in a
|
|
132
|
+
private, stable Codex home at `$CODEX_SECURITY_STATE_DIR/codex-home`, or at
|
|
133
|
+
`$CODEX_HOME/state/plugins/codex-security/codex-home` when no state directory is
|
|
134
|
+
configured. Login, status, logout, and scans use the same home. Codex manages
|
|
135
|
+
credentials using its configured file or system-keyring backend and honors
|
|
136
|
+
managed-device policies. An existing file-based Codex sign-in is imported only
|
|
137
|
+
when the dedicated home does not already contain stored credentials. Logging
|
|
138
|
+
out prevents later scans from automatically reimporting that ambient sign-in
|
|
139
|
+
until you explicitly log in again.
|
|
92
140
|
|
|
93
141
|
An environment API key takes precedence over a stored sign-in by default.
|
|
94
142
|
When both a stored ChatGPT sign-in and an environment API key are available, an
|
|
@@ -197,9 +245,127 @@ the implied provider. Use `--model gpt-5.6-terra` to switch models and
|
|
|
197
245
|
`--codex KEY=VALUE` for other Codex settings; existing
|
|
198
246
|
`--codex 'model_reasoning_effort="high"'` overrides remain supported.
|
|
199
247
|
|
|
248
|
+
### Runtime configuration and worker limits
|
|
249
|
+
|
|
250
|
+
The standalone CLI and SDK do not load an unrelated user or repository Codex
|
|
251
|
+
configuration. Each scan starts with a private runtime and these Codex
|
|
252
|
+
defaults:
|
|
253
|
+
|
|
254
|
+
```toml
|
|
255
|
+
cli_auth_credentials_store = "file"
|
|
256
|
+
model = "gpt-5.6-sol"
|
|
257
|
+
model_reasoning_effort = "xhigh"
|
|
258
|
+
|
|
259
|
+
[features]
|
|
260
|
+
plugins = true
|
|
261
|
+
goals = true
|
|
262
|
+
|
|
263
|
+
[features.multi_agent_v2]
|
|
264
|
+
enabled = true
|
|
265
|
+
max_concurrent_threads_per_session = 9
|
|
266
|
+
|
|
267
|
+
[windows]
|
|
268
|
+
sandbox = "unelevated"
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Use `--model` and `--effort` for model selection. Repeat
|
|
272
|
+
`--codex KEY=VALUE` to deep-merge other TOML values into this isolated
|
|
273
|
+
configuration:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
npx @openai/codex-security scan . \
|
|
277
|
+
--model gpt-5.6-terra \
|
|
278
|
+
--effort high \
|
|
279
|
+
--codex features.multi_agent_v2.max_concurrent_threads_per_session=4
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The session thread limit includes the parent agent: the default of `9`
|
|
283
|
+
provides up to eight delegated worker slots. This limit is separate from
|
|
284
|
+
`bulk-scan --workers`, which controls how many repositories run concurrently.
|
|
285
|
+
A configured limit is a maximum, not evidence that every worker started.
|
|
286
|
+
|
|
287
|
+
Quote string values as TOML, for example
|
|
288
|
+
`--codex 'model_reasoning_effort="high"'`. Do not pass both `--model` and
|
|
289
|
+
`--codex 'model="..."'`, or both `--effort` and
|
|
290
|
+
`--codex 'model_reasoning_effort="..."'`: conflicting or repeated keys are
|
|
291
|
+
rejected.
|
|
292
|
+
|
|
293
|
+
Plugin and marketplace loading belong to Codex Security. Overrides of
|
|
294
|
+
`plugins`, `marketplaces`, or `features.plugins`, including profile-specific
|
|
295
|
+
plugin overrides, are rejected; choose `--plugin-path` instead. Native
|
|
296
|
+
multi-agent v2 must remain enabled. The legacy `agents.max_threads` setting
|
|
297
|
+
and `features.multi_agent_v2.enabled=false` are incompatible and rejected.
|
|
298
|
+
`validate` and `patch` accept `--effort` and only the `model` and
|
|
299
|
+
`model_reasoning_effort` `--codex` keys; they do not accept general scan
|
|
300
|
+
runtime overrides.
|
|
301
|
+
|
|
200
302
|
These overrides do not change the scan's approval policy or filesystem
|
|
201
303
|
permissions. See [Local security model](#local-security-model).
|
|
202
304
|
|
|
305
|
+
### Deep-scan engine configuration
|
|
306
|
+
|
|
307
|
+
When the bundled plugin runs in a normal Codex host, its repeated-discovery
|
|
308
|
+
engine reads `$CODEX_HOME/codex-security/config.toml`, defaulting to
|
|
309
|
+
`~/.codex/codex-security/config.toml`:
|
|
310
|
+
|
|
311
|
+
```toml
|
|
312
|
+
[deep_scan]
|
|
313
|
+
workers = "auto"
|
|
314
|
+
subagents = 3
|
|
315
|
+
stop_after_no_new = 6
|
|
316
|
+
max_discovery_runs = 60
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
`workers = "auto"` uses half the available parallelism, with a minimum of one
|
|
320
|
+
and a maximum of six discovery workers. Set `workers` to a positive integer to
|
|
321
|
+
choose an explicit count. `subagents` must be a nonnegative integer;
|
|
322
|
+
`stop_after_no_new` and `max_discovery_runs` must be positive integers. Unknown
|
|
323
|
+
`[deep_scan]` keys are rejected.
|
|
324
|
+
|
|
325
|
+
These settings are separate from Codex's
|
|
326
|
+
`features.multi_agent_v2.max_concurrent_threads_per_session` and
|
|
327
|
+
`bulk-scan --workers`. Importantly, standalone CLI and SDK scans create an
|
|
328
|
+
isolated `CODEX_HOME` and do not import the ambient deep-scan configuration
|
|
329
|
+
file. Consequently, `scan --mode deep` currently uses the deep engine's
|
|
330
|
+
defaults; there are no standalone CLI flags for these four settings. Use
|
|
331
|
+
`--codex` to adjust the Codex session thread limit, not to set `[deep_scan]`
|
|
332
|
+
values.
|
|
333
|
+
|
|
334
|
+
### Environment variables
|
|
335
|
+
|
|
336
|
+
The CLI and SDK recognize the following user-configurable environment:
|
|
337
|
+
|
|
338
|
+
| Variable | Effect |
|
|
339
|
+
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
340
|
+
| `OPENAI_API_KEY`, `CODEX_API_KEY` | Scan authentication; `OPENAI_API_KEY` wins when both are present. |
|
|
341
|
+
| `CODEX_SECURITY_STATE_DIR` | Override the private scan-history, workbench, and default artifact directory. |
|
|
342
|
+
| `CODEX_HOME` | Set the ambient Codex home for file-backed sign-in and default state; defaults to `~/.codex`. |
|
|
343
|
+
| `PYTHON` | Select a Python interpreter when `--python` or SDK `pythonPath` is not set. |
|
|
344
|
+
| `GH_HOST` | Select a GitHub Enterprise host during interactive `bulk-scan` discovery. |
|
|
345
|
+
| `CODEX_SECURITY_NO_UPDATE_NOTICE`, `NO_UPDATE_NOTIFIER` | Disable interactive update notices when either variable is defined. |
|
|
346
|
+
| `CODEX_SECURITY_NPM_REGISTRY`, `npm_config_registry`, `NPM_CONFIG_REGISTRY` | Select the update-check registry, in the listed precedence order. |
|
|
347
|
+
| `CI` | Disable interactive update notices in automated environments. |
|
|
348
|
+
| `NO_COLOR`, `TERM` | Disable colored scan-history output when `NO_COLOR` is defined or `TERM=dumb`. |
|
|
349
|
+
|
|
350
|
+
Interpreter discovery uses `--python` or `pythonPath` first, then `PYTHON`,
|
|
351
|
+
the managed Codex runtime, and finally `python3` or `python` from `PATH`.
|
|
352
|
+
`CODEX_SECURITY_STATE_DIR` takes precedence over `CODEX_HOME`; keep both
|
|
353
|
+
state and result paths outside the scanned repository.
|
|
354
|
+
|
|
355
|
+
The repository's Docker Compose workflow additionally recognizes
|
|
356
|
+
`CODEX_SECURITY_IMAGE`, `CODEX_SECURITY_USER`, `CODEX_SECURITY_SECCOMP`,
|
|
357
|
+
`CODEX_SECURITY_CSV`, `CODEX_SECURITY_RESULTS`, and `CODEX_SECURITY_STATE` for
|
|
358
|
+
its image, runtime user, seccomp profile, input, results, and state mounts.
|
|
359
|
+
Provide `GH_TOKEN` or `GITHUB_TOKEN` for private GitHub checkouts and
|
|
360
|
+
`CODEX_SECURITY_GIT_HOST` for a GitHub Enterprise host in the container.
|
|
361
|
+
These container settings are distinct from standalone CLI flags and
|
|
362
|
+
interactive discovery's `GH_HOST`.
|
|
363
|
+
|
|
364
|
+
Variables such as `CODEX_SECURITY_SCAN_ID`, `CODEX_SECURITY_SCAN_DIR`,
|
|
365
|
+
`CODEX_SECURITY_PLUGIN_ROOT`, `CODEX_SECURITY_CONFIG_PATH`, and
|
|
366
|
+
`CODEX_SECURITY_TARGET_PATHS_FILE` are generated by an active scan. They are
|
|
367
|
+
internal runtime data, not supported user configuration.
|
|
368
|
+
|
|
203
369
|
Scan progress identifies the requested paths and reports actual ranking,
|
|
204
370
|
file-review, validation, and attack-path phases as they become available.
|
|
205
371
|
Completion summarizes findings, severity, coverage, elapsed time, available
|
|
@@ -244,7 +410,8 @@ Results remain under `--output-dir`; rerun the same command to resume.
|
|
|
244
410
|
`npx @openai/codex-security scans list` lists scans for the current repository. Pass a
|
|
245
411
|
repository path to inspect another checkout, `--scan-root DIR` to list scans
|
|
246
412
|
whose artifacts are under a particular root. `scans show SCAN_ID` includes the
|
|
247
|
-
scan configuration, results, coverage, and artifact locations.
|
|
413
|
+
scan configuration, results, coverage, and artifact locations. Add
|
|
414
|
+
`--show-linked-findings` to include finding links from previous scans.
|
|
248
415
|
|
|
249
416
|
Every scan history command accepts a full scan ID or a unique prefix of at
|
|
250
417
|
least eight characters.
|
|
@@ -31,6 +31,8 @@ A sealed manifest records the completed timestamp and hashes for the canonical d
|
|
|
31
31
|
Choose the target kind based on the reviewed content, not the scan invocation:
|
|
32
32
|
`git_worktree` for a checked-out Git workspace, `directory_snapshot` for a non-Git directory, `git_diff` for a Git-backed change set, and `git_revision` for an exact immutable Git tree.
|
|
33
33
|
|
|
34
|
+
For a workbench-backed scan, use the recorded target contract instead of inferring the kind from the checkout. A clean Git checkout has `allowedKinds: ["git_revision"]`: use its recorded revision and omit `snapshotDigest`. A dirty checkout has `allowedKinds: ["git_worktree"]`: copy `requiredSnapshotDigest` exactly.
|
|
35
|
+
|
|
34
36
|
| Kind | Required snapshot fields |
|
|
35
37
|
| --- | --- |
|
|
36
38
|
| `git_revision` | `revision` |
|
|
@@ -210,6 +210,10 @@ def parse_args(description: str) -> argparse.Namespace:
|
|
|
210
210
|
update_progress.add_argument("--deep-review-pass", type=positive_int)
|
|
211
211
|
update_progress.add_argument("--claim-token")
|
|
212
212
|
|
|
213
|
+
prepare_scan_completion = subparsers.add_parser("prepare-scan-completion")
|
|
214
|
+
prepare_scan_completion.add_argument("--scan-id", required=True)
|
|
215
|
+
prepare_scan_completion.add_argument("--claim-token")
|
|
216
|
+
|
|
213
217
|
complete_scan = subparsers.add_parser("complete-scan")
|
|
214
218
|
complete_scan.add_argument("--scan-id", required=True)
|
|
215
219
|
complete_scan.add_argument("--claim-token")
|
|
@@ -86,6 +86,7 @@ from workbench_scan_start import (
|
|
|
86
86
|
safe_segment,
|
|
87
87
|
scan_diff_identity,
|
|
88
88
|
scan_target_identity,
|
|
89
|
+
stored_diff_target,
|
|
89
90
|
)
|
|
90
91
|
from workbench_schema import MIGRATIONS, normalize_pre_release_migrations, sql_statements
|
|
91
92
|
from workbench_source_excerpt import finding_source_excerpt
|
|
@@ -504,19 +505,6 @@ def expected_target_kinds(scan: sqlite3.Row) -> list[str]:
|
|
|
504
505
|
return ["git_worktree"]
|
|
505
506
|
|
|
506
507
|
|
|
507
|
-
def stored_diff_target(row: sqlite3.Row) -> dict[str, str] | None:
|
|
508
|
-
if not row["diff_target_kind"]:
|
|
509
|
-
return None
|
|
510
|
-
target = {
|
|
511
|
-
"baseRevision": row["diff_base_revision"],
|
|
512
|
-
"headRevision": row["diff_head_revision"],
|
|
513
|
-
"kind": row["diff_target_kind"],
|
|
514
|
-
}
|
|
515
|
-
if row["diff_content_digest"]:
|
|
516
|
-
target["contentDigest"] = row["diff_content_digest"]
|
|
517
|
-
return target
|
|
518
|
-
|
|
519
|
-
|
|
520
508
|
def requested_scan_paths(scan: sqlite3.Row) -> list[str]:
|
|
521
509
|
if "recipe_json" in scan.keys() and scan["recipe_json"] is not None:
|
|
522
510
|
recipe = json.loads(scan["recipe_json"], parse_constant=reject_non_finite_json)
|
|
@@ -1374,11 +1362,15 @@ def pin_legacy_manifest_digest(
|
|
|
1374
1362
|
raise
|
|
1375
1363
|
|
|
1376
1364
|
|
|
1377
|
-
def complete_scan(
|
|
1365
|
+
def complete_scan(
|
|
1366
|
+
connection: sqlite3.Connection, args: argparse.Namespace, *, prepare_only: bool = False
|
|
1367
|
+
) -> dict[str, Any]:
|
|
1378
1368
|
scan_id = require_uuid(args.scan_id, "scan-id")
|
|
1379
|
-
cost_json = parse_scan_cost(args.cost_json)
|
|
1369
|
+
cost_json = None if prepare_only else parse_scan_cost(args.cost_json)
|
|
1380
1370
|
with scan_completion_lock(scan_id):
|
|
1381
|
-
return complete_scan_locked(
|
|
1371
|
+
return complete_scan_locked(
|
|
1372
|
+
connection, scan_id, args.claim_token, cost_json, prepare_only=prepare_only
|
|
1373
|
+
)
|
|
1382
1374
|
|
|
1383
1375
|
|
|
1384
1376
|
def complete_scan_locked(
|
|
@@ -1386,6 +1378,8 @@ def complete_scan_locked(
|
|
|
1386
1378
|
scan_id: str,
|
|
1387
1379
|
claim_token: str | None,
|
|
1388
1380
|
cost_json: str | None,
|
|
1381
|
+
*,
|
|
1382
|
+
prepare_only: bool = False,
|
|
1389
1383
|
) -> dict[str, Any]:
|
|
1390
1384
|
scan = require_scan(connection, scan_id)
|
|
1391
1385
|
if scan["status"] == "complete":
|
|
@@ -1412,9 +1406,9 @@ def complete_scan_locked(
|
|
|
1412
1406
|
)
|
|
1413
1407
|
if scan["recipe_json"] is None:
|
|
1414
1408
|
deep_scan.require_deep_scan_ready_for_parent_completion(connection, scan)
|
|
1415
|
-
warnings = []
|
|
1409
|
+
warnings = json.loads(scan["completion_warnings_json"])
|
|
1416
1410
|
warning = scan_target_warning(scan)
|
|
1417
|
-
if warning is not None:
|
|
1411
|
+
if warning is not None and warning not in warnings:
|
|
1418
1412
|
warnings.append(warning)
|
|
1419
1413
|
scan_dir = require_canonical_scan_directory(Path(scan["scan_dir"]))
|
|
1420
1414
|
completion_timestamp = now()
|
|
@@ -1443,9 +1437,23 @@ def complete_scan_locked(
|
|
|
1443
1437
|
for kind, filename in ARTIFACTS.items()
|
|
1444
1438
|
}
|
|
1445
1439
|
manifest_digest = published_manifest_digest(scan_dir, manifest)
|
|
1440
|
+
if prepare_only:
|
|
1441
|
+
connection.execute("BEGIN IMMEDIATE")
|
|
1442
|
+
try:
|
|
1443
|
+
updated = connection.execute(
|
|
1444
|
+
"UPDATE scans SET completion_warnings_json = ? WHERE id = ? AND status = 'running'",
|
|
1445
|
+
(json.dumps(warnings), scan["id"]),
|
|
1446
|
+
)
|
|
1447
|
+
if updated.rowcount != 1:
|
|
1448
|
+
raise SystemExit("Only a running scan can be prepared for completion.")
|
|
1449
|
+
connection.commit()
|
|
1450
|
+
except BaseException:
|
|
1451
|
+
connection.rollback()
|
|
1452
|
+
raise
|
|
1453
|
+
return scan_context(connection, scan["id"])
|
|
1446
1454
|
connection.execute("BEGIN IMMEDIATE")
|
|
1447
1455
|
try:
|
|
1448
|
-
timestamp =
|
|
1456
|
+
timestamp = manifest["scan"]["completedAt"]
|
|
1449
1457
|
scan = require_scan(connection, scan["id"])
|
|
1450
1458
|
if scan["status"] == "complete":
|
|
1451
1459
|
connection.commit()
|
|
@@ -1609,7 +1617,14 @@ def register_cli_scan(connection: sqlite3.Connection, args: argparse.Namespace)
|
|
|
1609
1617
|
except BaseException:
|
|
1610
1618
|
connection.rollback()
|
|
1611
1619
|
raise
|
|
1612
|
-
|
|
1620
|
+
scan = require_scan(connection, scan_id)
|
|
1621
|
+
return {
|
|
1622
|
+
"contract": scan_contract(scan),
|
|
1623
|
+
"scanDir": str(scan_dir),
|
|
1624
|
+
"scanId": scan_id,
|
|
1625
|
+
"targetId": target_id,
|
|
1626
|
+
"targetRevision": scan["target_revision"],
|
|
1627
|
+
}
|
|
1613
1628
|
|
|
1614
1629
|
|
|
1615
1630
|
def parse_scan_recipe(value: str, repository: Path) -> dict[str, Any]:
|
|
@@ -3596,8 +3611,10 @@ def main() -> None:
|
|
|
3596
3611
|
require_scan=require_scan,
|
|
3597
3612
|
scan_context=scan_context,
|
|
3598
3613
|
)
|
|
3599
|
-
elif args.command
|
|
3600
|
-
result = complete_scan(
|
|
3614
|
+
elif args.command in {"prepare-scan-completion", "complete-scan"}:
|
|
3615
|
+
result = complete_scan(
|
|
3616
|
+
connection, args, prepare_only=args.command == "prepare-scan-completion"
|
|
3617
|
+
)
|
|
3601
3618
|
elif args.command == "cancel-scan":
|
|
3602
3619
|
result = cancel_scan(connection, args)
|
|
3603
3620
|
elif args.command == "fail-scan":
|
|
@@ -72,6 +72,19 @@ def scan_diff_identity(
|
|
|
72
72
|
)
|
|
73
73
|
|
|
74
74
|
|
|
75
|
+
def stored_diff_target(row: sqlite3.Row) -> dict[str, str] | None:
|
|
76
|
+
if not row["diff_target_kind"]:
|
|
77
|
+
return None
|
|
78
|
+
target = {
|
|
79
|
+
"baseRevision": row["diff_base_revision"],
|
|
80
|
+
"headRevision": row["diff_head_revision"],
|
|
81
|
+
"kind": row["diff_target_kind"],
|
|
82
|
+
}
|
|
83
|
+
if row["diff_content_digest"]:
|
|
84
|
+
target["contentDigest"] = row["diff_content_digest"]
|
|
85
|
+
return target
|
|
86
|
+
|
|
87
|
+
|
|
75
88
|
def archive_scan(
|
|
76
89
|
connection: sqlite3.Connection,
|
|
77
90
|
args: argparse.Namespace,
|
package/dist/api.d.ts
CHANGED
|
@@ -97,6 +97,7 @@ interface ScanEventRunOptions {
|
|
|
97
97
|
scanDir: string;
|
|
98
98
|
pluginRoot: string;
|
|
99
99
|
expectation: ScanExpectation;
|
|
100
|
+
workbenchValidated?: boolean;
|
|
100
101
|
model?: string;
|
|
101
102
|
onFinalize?: (usage: unknown) => Promise<unknown>;
|
|
102
103
|
onThreadStarted?: (threadId: string) => void;
|
|
@@ -108,7 +109,7 @@ interface ScanEventRunOptions {
|
|
|
108
109
|
export declare function runScanEvents(options: ScanEventRunOptions): Promise<ScanResult>;
|
|
109
110
|
export declare function scanAuthentication(environment: ProcessEnvironment, auth?: ScanAuthMode): ScanAuthentication;
|
|
110
111
|
export declare function classifyConnectionFailure(error: unknown): "rate_limited" | "unauthorized" | "forbidden" | "network_error" | "timeout" | "unknown";
|
|
111
|
-
export declare function scanRuntimeCodexConfig(config: JsonObject, stateDirectory: string): JsonObject;
|
|
112
|
+
export declare function scanRuntimeCodexConfig(config: JsonObject, stateDirectory: string, protectedCredentialHome?: string): JsonObject;
|
|
112
113
|
export declare function scanPreflightCodexConfig(config: JsonObject): JsonObject;
|
|
113
114
|
export declare function environmentValue(environment: ProcessEnvironment, requested: string): string | undefined;
|
|
114
115
|
export {};
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAOA,OAAO,EAEL,gBAAgB,EAGhB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAevB,OAAO,EAAE,UAAU,EAA2B,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AAOA,OAAO,EAEL,gBAAgB,EAGhB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AACnB,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAqC,KAAK,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAevB,OAAO,EAAE,UAAU,EAA2B,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAQL,iBAAiB,EAejB,KAAK,kBAAkB,EAGxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAML,KAAK,gBAAgB,EACrB,KAAK,QAAQ,EACb,KAAK,UAAU,EAGhB,MAAM,cAAc,CAAC;AAEtB,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CACT,KAAK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