@openai/codex-security 0.1.17 → 0.1.19
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 +127 -18
- package/_bundled_plugin/.mcp.json +1 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/server.mjs.br.part-001 +0 -0
- package/_bundled_plugin/references/core-scan.md +1 -1
- package/_bundled_plugin/references/final-report.md +4 -2
- package/_bundled_plugin/references/scan-artifacts.md +1 -1
- package/_bundled_plugin/references/scan-contract.md +18 -7
- package/_bundled_plugin/schemas/scan-manifest.schema.json +2 -2
- package/_bundled_plugin/schemas/tools/scan-draft.schema.json +23 -0
- package/_bundled_plugin/scripts/deep_scan_workbench.py +88 -1
- package/_bundled_plugin/scripts/finalize_scan_contract.py +58 -18
- package/_bundled_plugin/scripts/report_projection.py +19 -8
- package/_bundled_plugin/scripts/workbench_cli.py +13 -0
- package/_bundled_plugin/scripts/workbench_db.py +149 -167
- package/_bundled_plugin/scripts/workbench_finding_index.py +101 -0
- package/_bundled_plugin/scripts/workbench_remediation.py +19 -0
- package/_bundled_plugin/scripts/workbench_saved_results.py +1289 -0
- package/_bundled_plugin/scripts/workbench_schema.py +28 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +4 -4
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/security-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +1 -1
- package/dist/api.d.ts +2 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +54 -7
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +247 -25
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.d.ts +16 -0
- package/dist/cloud-publish.d.ts.map +1 -0
- package/dist/cloud-publish.js +138 -0
- package/dist/cloud-publish.js.map +1 -0
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +4 -0
- package/dist/contract.js.map +1 -1
- package/dist/custom-validation-prompt.js +3 -3
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/linear.d.ts.map +1 -1
- package/dist/linear.js +17 -6
- package/dist/linear.js.map +1 -1
- package/dist/models.d.ts +1 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/models.js.map +1 -1
- package/dist/publication.d.ts +1 -0
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +1 -0
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +1 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js.map +1 -1
- package/package.json +2 -2
|
@@ -683,6 +683,20 @@ MIGRATIONS = (
|
|
|
683
683
|
WHERE project_id IS NULL;
|
|
684
684
|
""",
|
|
685
685
|
),
|
|
686
|
+
(
|
|
687
|
+
31,
|
|
688
|
+
"freeze stopped scan source digests",
|
|
689
|
+
"""
|
|
690
|
+
ALTER TABLE scans ADD COLUMN retained_source_digests_json TEXT;
|
|
691
|
+
""",
|
|
692
|
+
),
|
|
693
|
+
(
|
|
694
|
+
32,
|
|
695
|
+
"separate deep scan publication failures",
|
|
696
|
+
"""
|
|
697
|
+
ALTER TABLE deep_scan_runs ADD COLUMN publication_error_message TEXT;
|
|
698
|
+
""",
|
|
699
|
+
),
|
|
686
700
|
)
|
|
687
701
|
|
|
688
702
|
|
|
@@ -744,6 +758,20 @@ def apply_migrations(
|
|
|
744
758
|
"max_time_hours",
|
|
745
759
|
"REAL NOT NULL DEFAULT 96",
|
|
746
760
|
)
|
|
761
|
+
elif version == 31:
|
|
762
|
+
add_column_if_missing(
|
|
763
|
+
connection,
|
|
764
|
+
"scans",
|
|
765
|
+
"retained_source_digests_json",
|
|
766
|
+
"TEXT",
|
|
767
|
+
)
|
|
768
|
+
elif version == 32:
|
|
769
|
+
add_column_if_missing(
|
|
770
|
+
connection,
|
|
771
|
+
"deep_scan_runs",
|
|
772
|
+
"publication_error_message",
|
|
773
|
+
"TEXT",
|
|
774
|
+
)
|
|
747
775
|
continue
|
|
748
776
|
if version == 6:
|
|
749
777
|
repair_thread_scoped_workspaces_migration(connection)
|
|
@@ -5,7 +5,7 @@ description: Use when the user asks for a deep, exhaustive, multi-pass, or varia
|
|
|
5
5
|
|
|
6
6
|
# Deep Security Scan
|
|
7
7
|
|
|
8
|
-
Use `start_codex_security_deep_scan` to run repeated independent workers against the exact requested target and scope. Each worker loads `../../references/core-scan.md` directly and performs the complete ordinary Standard audit, including its own threat map, investigation, source-backed validation, and attack-path reasoning,
|
|
8
|
+
Use `start_codex_security_deep_scan` to run repeated independent workers against the exact requested target and scope. Each worker loads `../../references/core-scan.md` directly and performs the complete ordinary Standard audit, including its own threat map, investigation, source-backed validation, and attack-path reasoning, saving worker-bound checkpoints as results arrive and one final semantic scan draft when its audit finishes. The coordinator aggregates the finished Standard results and writes the parent scan's unsealed `scan-manifest.json`, `findings.json`, and `coverage.json` before returning `{ manifestPath }`.
|
|
9
9
|
|
|
10
10
|
## Phase Ownership
|
|
11
11
|
|
|
@@ -58,8 +58,8 @@ If the host represents the pending call as a running execution cell, keep waitin
|
|
|
58
58
|
Handle the result as follows:
|
|
59
59
|
|
|
60
60
|
- `{ manifestPath }`: this is the parent scan's already-authored, unsealed canonical `scan-manifest.json`, not a request for another parent workflow. Its complete Standard worker results have already been validated. Older generic or benchmark instructions describing discovery-only coordinator manifests, candidate lists, parent validation or attack-path phases, or another semantic draft do not apply to this canonical-manifest result. Confirm that the manifest, `findings.json`, and `coverage.json` exist in the authoritative scan directory. For native continuations, keep the existing authoritative `scanId`; for a first target-based CLI or headless call, use the authoritative scan ID explicitly returned in the successful tool result's text. The unsealed manifest may not contain an ID, so never infer one from it, reload global context, or start a replacement scan. Immediately complete that same scan. Do not rerun validation or attack-path analysis, list candidates, aggregate findings, submit another semantic draft, or start another scan.
|
|
61
|
-
- `status: "canceled"`: stop without
|
|
62
|
-
-
|
|
61
|
+
- `status: "canceled"`: stop all scan work and do not call completion. The workbench preserves saved findings and pending candidates; report those retained results with incomplete coverage without claiming a successful scan or generating a replacement report.
|
|
62
|
+
- Terminal scan failure: surface the exact stable MCP error, then read the existing scan context to report preserved findings and pending candidates with incomplete coverage. Do not start more scan work, call completion, cancel an already terminal scan, synthesize findings, or claim a successful/no-findings scan. An invocation failure before a scan starts is still a blocker; do not create a replacement scan or infer results.
|
|
63
63
|
|
|
64
64
|
The native Security workbench observes durable progress without another scan-start call.
|
|
65
65
|
|
|
@@ -71,4 +71,4 @@ Detailed finding write-ups and hardening proposals remain optional, exactly as i
|
|
|
71
71
|
|
|
72
72
|
Return user-facing or benchmark output only after completion succeeds and the generated `report.md` exists. Link the report and canonical artifacts. Include measured total, input, and cached input token counts; explicitly label partial coverage and state when measurement is unavailable instead of reporting zero or estimating. If the configured time limit elapsed before any source review completed, report the existing coverage as partial and never claim the repository is free of vulnerabilities. An empty finding set with completed review is the ordinary Codex Security no-findings result, not permission to skip completion.
|
|
73
73
|
|
|
74
|
-
If canonical coordinator artifacts are missing or malformed, stop and surface the exact blocker without calling completion, fabricating a report, or claiming success. If completion fails, surface its exact MCP error without retrying, canceling, failing the durable scan, or returning final, no-findings, structured, or benchmark output. Leave resumable work running and preserve its handoff claim. On explicit cancellation, call `cancel_codex_security_scan` and do not accept later progress or
|
|
74
|
+
If canonical coordinator artifacts are missing or malformed, stop and surface the exact blocker without calling completion, fabricating a report, or claiming success. If completion fails, surface its exact MCP error without retrying, canceling, failing the durable scan, or returning final, no-findings, structured, or benchmark output. Leave resumable work running and preserve its handoff claim. On explicit cancellation, call `cancel_codex_security_scan` and do not accept later scan progress or success. The host may preserve a final in-flight checkpoint after worker cleanup without resuming analysis. Never edit repository files, widen the target, expose internal worker bookkeeping unless requested, or call `fail_codex_security_scan` merely because a waiter detached, a turn ended, workers are still active, or partial artifacts exist.
|
|
@@ -25,7 +25,7 @@ Read `../../references/config-preflight.md` before dispatching the `security_dif
|
|
|
25
25
|
2. Prepare the file list with `prepare_codex_security_review_items` and read all pages from `list_codex_security_review_items`. Inspect deleted files at the baseline revision and unchanged files only when needed to explain the change.
|
|
26
26
|
3. Run `$finding-discovery` in compact diff mode across the existing file inventory. Do not create ranked worklists, per-finding ledgers, or discovery reports. Divide large changes among available workers without overlap; review any unassigned files yourself. Keep independently reachable bugs separate and record all candidates once with `record_codex_security_discovery_candidates`.
|
|
27
27
|
4. If candidates exist, run `$validation` once, then `$attack-path-analysis` once for candidates marked `reportable` or `deferred`. Preserve exact locations, evidence, affected instances, and unresolved questions.
|
|
28
|
-
5. Record findings
|
|
28
|
+
5. Record `complete: false` semantic checkpoints with `record_codex_security_scan_draft` as findings and validation decisions arrive, retaining unresolved candidates and original evidence in `coverage.deferred`. After the review settles, record one final `complete: true` semantic draft with the retained canonical model, findings, and coverage. Request detailed write-ups or hardening plans only when the user asks.
|
|
29
29
|
6. Call `complete_codex_security_scan` once, then read `get_codex_security_completed_scan`. Finalization creates `report.md` and SARIF. Include measured token usage when available and identify incomplete coverage.
|
|
30
30
|
|
|
31
31
|
For terminal scans without a `scanId`, generate the changed-file list with:
|
|
@@ -23,7 +23,7 @@ When an SDK or terminal host sets `CODEX_SECURITY_SCAN_ID`, emit its standalone
|
|
|
23
23
|
|
|
24
24
|
1. Resolve the repository, requested scope, and output scan directory from the host-provided scan context when available; otherwise use the requested output directory or `<platform_temp>/codex-security-scans/<repo_name>/<scan_id>`. Preserve the exact user context, supplied threat model, applicable inherited `SECURITY.md` guidance, and optional `CODEX_SECURITY_KNOWLEDGE_BASE` for the core audit. Resolve `<python_command>` from the configured interpreter (`"$PYTHON"` in POSIX shells or `& "$env:PYTHON"` in PowerShell), otherwise use `python3` on Unix-like hosts or `python` on Windows. Only when `CODEX_SECURITY_TARGET_PATHS_FILE` is supplied, resolve every authorized source path before review with `<python_command> <plugin_dir>/scripts/generate_rank_input.py make-repo-scope-input --repo <repo_root> --scopes-file <target_paths_file> --out <scan_dir>/scoped-source-input.jsonl`; use `"$CODEX_SECURITY_TARGET_PATHS_FILE"` in POSIX shells or `"$env:CODEX_SECURITY_TARGET_PATHS_FILE"` in PowerShell and honor repository ignore rules for directory descendants while retaining every directly requested file. Never print, modify, or treat the scope input as shell syntax; pass it to the core audit without widening the authorized target or scope.
|
|
25
25
|
2. Read `../../references/core-scan.md` once and perform its complete source-backed security audit against the resolved target, authorized scope, exact user context, supplied threat model, inherited security policy, optional knowledge base, available workers, and any resolved scoped-source inventory. Retain the resulting complete semantic `scope`, `threatModel`, `findings`, and `coverage`; preserve every finding's source evidence, calibrated severity, confidence, root cause, validation, attack path, and honest coverage.
|
|
26
|
-
3. For a host-backed scan, submit one accepted semantic draft with `record_codex_security_scan_draft({ scanId, handoffClaimToken?, scope?, threatModel, findings, coverage })`; let the workbench derive its authoritative target, scope, coverage metadata, surface IDs, finding identities, and fingerprints. If the draft is explicitly rejected before writing, correct only the identified fields without dropping valid findings or evidence and retry the same scan at most twice. For an SDK-owned or prompt-only headless scan, write unsealed canonical `scan-manifest.json`, `findings.json`, and `coverage.json`; use `scoped_path` for both coverage fields when a scope was requested, otherwise set `coverage.mode` to `repository` and `coverage.inventoryStrategy` to `directory` for a non-Git directory or `repository` for a Git-backed target. Omit `scan.sealedAt` and `scan.artifacts`; an SDK scan preserves its exact registered directory and all SDK-provided scan and target values. When `CODEX_SECURITY_TARGET_PATHS_FILE` is supplied on either file-authored path, bind its exact requested paths with `<python_command> <plugin_dir>/scripts/generate_rank_input.py bind-repo-scopes --scopes-file <target_paths_file> --manifest <scan_dir>/scan-manifest.json --coverage <scan_dir>/coverage.json`, using the same shell-specific target-paths reference.
|
|
26
|
+
3. For a host-backed scan, save `complete: false` checkpoints during the core audit, then submit one accepted final semantic draft with `record_codex_security_scan_draft({ scanId, complete: true, handoffClaimToken?, scope?, threatModel, findings, coverage })`; let the workbench derive its authoritative target, scope, coverage metadata, surface IDs, finding identities, and fingerprints. If the draft is explicitly rejected before writing, correct only the identified fields without dropping valid findings or evidence and retry the same scan at most twice. For an SDK-owned or prompt-only headless scan, write unsealed canonical `scan-manifest.json`, `findings.json`, and `coverage.json`; use `scoped_path` for both coverage fields when a scope was requested, otherwise set `coverage.mode` to `repository` and `coverage.inventoryStrategy` to `directory` for a non-Git directory or `repository` for a Git-backed target. Omit `scan.sealedAt` and `scan.artifacts`; an SDK scan preserves its exact registered directory and all SDK-provided scan and target values. When `CODEX_SECURITY_TARGET_PATHS_FILE` is supplied on either file-authored path, bind its exact requested paths with `<python_command> <plugin_dir>/scripts/generate_rank_input.py bind-repo-scopes --scopes-file <target_paths_file> --manifest <scan_dir>/scan-manifest.json --coverage <scan_dir>/coverage.json`, using the same shell-specific target-paths reference.
|
|
27
27
|
4. Verify all three canonical JSON files exist. For an SDK-owned scan, return control without finalizing, sealing, generating `report.md`, or starting another scan; the SDK owns completion. For another host-backed scan, call `complete_codex_security_scan({ scanId, handoffClaimToken? })` once. For a prompt-only headless scan, run `<python_command> <plugin_dir>/scripts/finalize_scan_contract.py --scan-dir <scan_dir> --source-root <repo_root>`. Outside the SDK path, return only after completion succeeds and the generated `report.md` exists; never write the report by hand or reread the complete canonical findings unless the user explicitly requests them. Report measured token counts when returned and label partial measurement or unavailable usage honestly.
|
|
28
28
|
|
|
29
29
|
Keep discovery, validation, and attack-path reasoning within this Standard workflow; do not invoke separate phase skills or load Deep or diff references. Never call Deep-only tools. Do not create ranking phases, per-file or per-candidate ledgers, separate phase worker pools, repeated phase reports, or receipt files.
|
|
@@ -16,7 +16,7 @@ Use the existing desktop phase labels for work that actually occurs: threat mapp
|
|
|
16
16
|
|
|
17
17
|
## Complete The Same Scan
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Save `complete: false` checkpoints as results arrive and validation decisions are made. Preserve pending candidates with their original evidence in `coverage.deferred`; they are not validated findings. When the audit finishes, record the final semantic scan draft once with `record_codex_security_scan_draft({ scanId, complete: true, handoffClaimToken?, scope?, threatModel?, findings, coverage })`. Supply the actual findings, source-backed coverage, and preserved threat model; let the workbench write the unsealed canonical artifacts and derive authoritative target, scope, coverage metadata, finding identities, and fingerprints.
|
|
20
20
|
|
|
21
21
|
Honor desktop handoff requirements for any per-finding write-ups before completion. After the semantic draft succeeds and all three canonical JSON files exist, call `complete_codex_security_scan` exactly once with the same authoritative scan ID and handoff token. Return only after completion succeeds and `report.md` exists, linking the generated report and canonical artifacts; retrieve the complete findings only when the user explicitly requests them. Include measured token usage when available and explicitly label partial or unavailable measurement.
|
|
22
22
|
|
package/dist/api.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export interface DeepScanOptions {
|
|
|
17
17
|
}
|
|
18
18
|
export interface ScanOptions extends DeepScanOptions {
|
|
19
19
|
auth?: ScanAuthMode;
|
|
20
|
+
/** Stable, privacy-preserving end-user ID for this scan's model requests. */
|
|
21
|
+
safetyIdentifier?: string;
|
|
20
22
|
target?: ScanTarget;
|
|
21
23
|
mode?: ScanMode;
|
|
22
24
|
knowledgeBasePaths?: string[];
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AA2BA,OAAO,EAEL,gBAAgB,EAGhB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAMnB,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";AA2BA,OAAO,EAEL,gBAAgB,EAGhB,KAAK,aAAa,EACnB,MAAM,WAAW,CAAC;AAMnB,OAAO,EAOL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,W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AE,MAAM,GAC/B,UAAU,CAuCZ;AA+BD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAyHvE;AAsDD,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,kBAAkB,EAC/B,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,SAAS,CAcpB"}
|
package/dist/api.js
CHANGED
|
@@ -13,7 +13,7 @@ import { estimateScanCost, ScanCostTracker, sumTokenUsage, } from "./cost.js";
|
|
|
13
13
|
import { loadContract, requireScanFile, } from "./contract.js";
|
|
14
14
|
import { runCustomValidation, writeCustomValidationStatus, } from "./custom-validation.js";
|
|
15
15
|
import { customDiscoveryPrompt, customValidationConfig, } from "./custom-validation-prompt.js";
|
|
16
|
-
import { AuthenticationRequiredError, CodexSecurityError, IncompleteScanError, OutputDirectoryError, errorMessage, safeErrorMessage, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
16
|
+
import { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, IncompleteScanError, OutputDirectoryError, errorMessage, safeErrorMessage, ScanCostLimitExceededError, ScanInterruptedError, } from "./errors.js";
|
|
17
17
|
import { prepareKnowledgeBase, } from "./knowledge-base.js";
|
|
18
18
|
import { ScanResult, } from "./result.js";
|
|
19
19
|
import { scanActivitiesFromEvent } from "./scan-activity.js";
|
|
@@ -41,6 +41,7 @@ const DEFAULT_DEPENDENCIES = {
|
|
|
41
41
|
environment: process.env,
|
|
42
42
|
};
|
|
43
43
|
const SCAN_PERMISSION_PROFILE = "codex_security_scan";
|
|
44
|
+
const SAFETY_IDENTIFIER_ENV = "CODEX_SAFETY_IDENTIFIER";
|
|
44
45
|
const PERSONAL_TRUSTED_ACCESS_URL = "https://chatgpt.com/cyber";
|
|
45
46
|
const ORGANIZATIONAL_TRUSTED_ACCESS_URL = "https://openai.com/form/enterprise-trusted-access-for-cyber/";
|
|
46
47
|
const DEEP_SCAN_SETTINGS = [
|
|
@@ -74,7 +75,7 @@ export class CodexSecurity {
|
|
|
74
75
|
this.#surface = runtimeOptions.surface;
|
|
75
76
|
}
|
|
76
77
|
async run(repository, options = {}) {
|
|
77
|
-
return await this.#trackOperation(() => this.#run(repository, options));
|
|
78
|
+
return await this.#trackOperation(() => this.#run(repository, { ...options }));
|
|
78
79
|
}
|
|
79
80
|
async validate(options) {
|
|
80
81
|
return await this.#trackOperation(() => this.#validate(options));
|
|
@@ -603,11 +604,35 @@ export class CodexSecurity {
|
|
|
603
604
|
notifyObserver("onWarning", options.onWarning, options.onObserverError, "Scan completed, but its cost limit could not be verified because model pricing or token usage is unavailable.");
|
|
604
605
|
}
|
|
605
606
|
completionCost = snapshot.cost;
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
607
|
+
let preparation;
|
|
608
|
+
try {
|
|
609
|
+
preparation = await workbench(workbenchOptions, [
|
|
610
|
+
"prepare-scan-completion",
|
|
611
|
+
"--scan-id",
|
|
612
|
+
scanId,
|
|
613
|
+
]);
|
|
614
|
+
}
|
|
615
|
+
catch (error) {
|
|
616
|
+
const saved = await workbench(workbenchOptions, [
|
|
617
|
+
"get-scan",
|
|
618
|
+
"--scan-id",
|
|
619
|
+
scanId,
|
|
620
|
+
]).catch(() => null);
|
|
621
|
+
const savedScan = isRecord(saved) ? saved["scan"] : undefined;
|
|
622
|
+
const progress = isRecord(savedScan)
|
|
623
|
+
? savedScan["progress"]
|
|
624
|
+
: undefined;
|
|
625
|
+
const failureMessage = isRecord(savedScan)
|
|
626
|
+
? savedScan["failureMessage"]
|
|
627
|
+
: undefined;
|
|
628
|
+
if (isRecord(progress) &&
|
|
629
|
+
progress["status"] === "failed" &&
|
|
630
|
+
typeof failureMessage === "string" &&
|
|
631
|
+
failureMessage.trim() !== "") {
|
|
632
|
+
throw new IncompleteScanError(failureMessage);
|
|
633
|
+
}
|
|
634
|
+
throw error;
|
|
635
|
+
}
|
|
611
636
|
preparedTargetWarnings = Array.isArray(preparation["targetWarnings"])
|
|
612
637
|
? preparation["targetWarnings"].filter((warning) => typeof warning === "string")
|
|
613
638
|
: [];
|
|
@@ -1026,6 +1051,13 @@ export class CodexSecurity {
|
|
|
1026
1051
|
CODEX_HOME: runtime.codexHome,
|
|
1027
1052
|
...runtimePaths,
|
|
1028
1053
|
};
|
|
1054
|
+
for (const name of Object.keys(environment)) {
|
|
1055
|
+
if (name.toUpperCase() === SAFETY_IDENTIFIER_ENV)
|
|
1056
|
+
delete environment[name];
|
|
1057
|
+
}
|
|
1058
|
+
if (session.safetyIdentifier !== undefined) {
|
|
1059
|
+
environment[SAFETY_IDENTIFIER_ENV] = session.safetyIdentifier;
|
|
1060
|
+
}
|
|
1029
1061
|
const sdkCodexConfig = { ...sessionConfig };
|
|
1030
1062
|
// Projects and permissions already live in generated TOML files; the SDK
|
|
1031
1063
|
// cannot safely encode their path and selector keys as dotted overrides.
|
|
@@ -1128,6 +1160,12 @@ export class CodexSecurity {
|
|
|
1128
1160
|
"OPENAI_API_KEY or CODEX_API_KEY for CI.");
|
|
1129
1161
|
}
|
|
1130
1162
|
authentication = await runtimeScanAuthentication(this.#dependencies.environment, runtime.codexHome, options.auth, modelProvider);
|
|
1163
|
+
if (options.safetyIdentifier !== undefined &&
|
|
1164
|
+
authentication.method !== "api_key" &&
|
|
1165
|
+
!(authentication.method === "stored_credentials" &&
|
|
1166
|
+
authentication.credentialType === "api_key")) {
|
|
1167
|
+
throw new ConfigurationError("safetyIdentifier requires API-key authentication.");
|
|
1168
|
+
}
|
|
1131
1169
|
notifyObserver("onAuthentication", options.onAuthentication, options.onObserverError, authentication);
|
|
1132
1170
|
const python = await (this.#dependencies.resolvePluginPython ?? resolvePluginPython)({
|
|
1133
1171
|
configuredPath: this.config.pythonPath,
|
|
@@ -1138,6 +1176,7 @@ export class CodexSecurity {
|
|
|
1138
1176
|
checkOpen();
|
|
1139
1177
|
return {
|
|
1140
1178
|
runtime,
|
|
1179
|
+
safetyIdentifier: options.safetyIdentifier,
|
|
1141
1180
|
runtimeHome,
|
|
1142
1181
|
effectiveConfig,
|
|
1143
1182
|
preflightConfig,
|
|
@@ -1210,6 +1249,14 @@ export class CodexSecurity {
|
|
|
1210
1249
|
}
|
|
1211
1250
|
async #validateLocalInputs(repository, options, signal) {
|
|
1212
1251
|
deepScanOptions(options);
|
|
1252
|
+
const identifier = options.safetyIdentifier;
|
|
1253
|
+
if (identifier !== undefined &&
|
|
1254
|
+
(typeof identifier !== "string" ||
|
|
1255
|
+
identifier.trim().length === 0 ||
|
|
1256
|
+
identifier.includes("\0") ||
|
|
1257
|
+
[...identifier].length > 64)) {
|
|
1258
|
+
throw new ConfigurationError("safetyIdentifier must contain 1 to 64 characters, must not be blank, and must not contain NUL.");
|
|
1259
|
+
}
|
|
1213
1260
|
if (options.maxCostUsd !== undefined &&
|
|
1214
1261
|
(!Number.isFinite(options.maxCostUsd) || options.maxCostUsd <= 0)) {
|
|
1215
1262
|
throw new CodexSecurityError("The scan cost limit must be a positive USD amount.");
|