@openai/codex-security 0.5.0 → 0.5.1
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 +7 -0
- package/_bundled_plugin/mcp/helpers.mjs.br.part-000 +0 -0
- package/_bundled_plugin/mcp/native/win32-arm64/windows.node +0 -0
- package/_bundled_plugin/mcp/native/win32-x64/windows.node +0 -0
- package/_bundled_plugin/mcp/permission-profile-preflight.mjs +60 -9
- 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/schemas/definitions/artifact-common.schema.json +1 -1
- package/_bundled_plugin/scripts/finalize_scan_contract.py +12 -1
- package/_bundled_plugin/scripts/generate_in_scope_files.py +6 -6
- package/_bundled_plugin/scripts/generate_rank_input.py +12 -6
- package/_bundled_plugin/scripts/report_projection.py +2 -1
- package/_bundled_plugin/scripts/threat_model_projection.py +1 -3
- package/_bundled_plugin/scripts/workbench/saved_coverage.py +234 -0
- package/_bundled_plugin/scripts/workbench_cli.py +5 -7
- package/_bundled_plugin/scripts/workbench_db.py +12 -6
- package/_bundled_plugin/scripts/workbench_native_indexes.py +10 -7
- package/_bundled_plugin/scripts/workbench_publication.py +4 -3
- package/_bundled_plugin/scripts/workbench_remediation.py +5 -1
- package/_bundled_plugin/scripts/workbench_saved_results.py +542 -148
- package/_bundled_plugin/scripts/workbench_scan_history.py +79 -78
- package/_bundled_plugin/scripts/workbench_scan_usage.py +61 -13
- package/_bundled_plugin/scripts/workbench_target.py +21 -7
- package/_bundled_plugin/scripts/workbench_validation.py +21 -18
- package/_bundled_plugin/shared/workbench-migrations.json +10 -0
- package/dist/api.d.ts +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +161 -57
- package/dist/api.js.map +1 -1
- package/dist/classify-scan-severity.d.ts.map +1 -1
- package/dist/classify-scan-severity.js +16 -18
- package/dist/classify-scan-severity.js.map +1 -1
- package/dist/cli-daybreak.d.ts +5 -0
- package/dist/cli-daybreak.d.ts.map +1 -0
- package/dist/cli-daybreak.js +89 -0
- package/dist/cli-daybreak.js.map +1 -0
- package/dist/cli.d.ts +5 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +821 -591
- package/dist/cli.js.map +1 -1
- package/dist/codeowners.js +2 -2
- package/dist/codeowners.js.map +1 -1
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +3 -2
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.js +2 -2
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -1
- package/dist/config.js.map +1 -1
- package/dist/cost.d.ts +2 -1
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +17 -8
- package/dist/cost.js.map +1 -1
- package/dist/custom-validation.d.ts.map +1 -1
- package/dist/custom-validation.js +2 -5
- package/dist/custom-validation.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +8 -6
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/local.d.ts.map +1 -1
- package/dist/deduplication/local.js +5 -2
- package/dist/deduplication/local.js.map +1 -1
- package/dist/deduplication/retry.d.ts.map +1 -1
- package/dist/deduplication/retry.js +5 -0
- package/dist/deduplication/retry.js.map +1 -1
- package/dist/deduplication/scan.js +5 -1
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-scan.d.ts +6 -0
- package/dist/deep-scan.d.ts.map +1 -1
- package/dist/deep-scan.js +8 -6
- package/dist/deep-scan.js.map +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +23 -3
- package/dist/findings-import.js.map +1 -1
- package/dist/host-protocol.d.ts +1 -0
- package/dist/host-protocol.d.ts.map +1 -1
- package/dist/host-protocol.js +1 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/hosted-remediation-protocol.d.ts +5 -0
- package/dist/hosted-remediation-protocol.d.ts.map +1 -0
- package/dist/hosted-remediation-protocol.js +26 -0
- package/dist/hosted-remediation-protocol.js.map +1 -0
- package/dist/hosted-remediation.d.ts +89 -0
- package/dist/hosted-remediation.d.ts.map +1 -0
- package/dist/hosted-remediation.js +122 -0
- package/dist/hosted-remediation.js.map +1 -0
- package/dist/import-scan.d.ts +1 -0
- package/dist/import-scan.d.ts.map +1 -1
- package/dist/import-scan.js +5 -1
- package/dist/import-scan.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +3 -1
- package/dist/multiscan.js.map +1 -1
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +13 -9
- package/dist/project-config.js.map +1 -1
- package/dist/publish.d.ts +2 -0
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +9 -0
- package/dist/publish.js.map +1 -1
- package/dist/remediation.d.ts +63 -0
- package/dist/remediation.d.ts.map +1 -0
- package/dist/remediation.js +110 -0
- package/dist/remediation.js.map +1 -0
- package/dist/request-metadata.d.ts +17 -7
- package/dist/request-metadata.d.ts.map +1 -1
- package/dist/request-metadata.js +43 -8
- package/dist/request-metadata.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +21 -14
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan-bootstrap.d.ts +1 -0
- package/dist/saved-scan-bootstrap.d.ts.map +1 -1
- package/dist/saved-scan-bootstrap.js +16 -4
- package/dist/saved-scan-bootstrap.js.map +1 -1
- package/dist/scan-activity.js +8 -8
- package/dist/scan-activity.js.map +1 -1
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +15 -9
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +12 -6
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-executor.d.ts +5 -1
- package/dist/scan-executor.d.ts.map +1 -1
- package/dist/scan-executor.js +9 -8
- package/dist/scan-executor.js.map +1 -1
- package/dist/{deep-progress.d.ts → scan-progress.d.ts} +15 -7
- package/dist/scan-progress.d.ts.map +1 -0
- package/dist/scan-progress.js +138 -0
- package/dist/scan-progress.js.map +1 -0
- package/dist/security-policy.js +1 -1
- package/dist/security-policy.js.map +1 -1
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +4 -0
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/sqlite-store.d.ts.map +1 -1
- package/dist/server/sqlite-store.js +14 -2
- package/dist/server/sqlite-store.js.map +1 -1
- package/dist/severity-store.js +4 -1
- package/dist/severity-store.js.map +1 -1
- package/dist/timestamps.d.ts +3 -0
- package/dist/timestamps.d.ts.map +1 -0
- package/dist/timestamps.js +14 -0
- package/dist/timestamps.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +13 -2
- package/dist/version.js.map +1 -1
- package/dist/workbench-arguments.d.ts.map +1 -1
- package/dist/workbench-arguments.js +9 -3
- package/dist/workbench-arguments.js.map +1 -1
- package/dist/worker-progress.d.ts +11 -1
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +11 -1
- package/dist/worker-progress.js.map +1 -1
- package/docs/cli.md +86 -15
- package/docs/findings-service.md +7 -2
- package/docs/hosted-remediation.md +117 -0
- package/docs/hosted-scans.md +8 -3
- package/package.json +5 -4
- package/dist/deep-progress.d.ts.map +0 -1
- package/dist/deep-progress.js +0 -92
- package/dist/deep-progress.js.map +0 -1
package/dist/api.js
CHANGED
|
@@ -26,9 +26,9 @@ import { CODEX_AUTH_CONFIG_KEYS, NO_CREDENTIALS_MESSAGE, accountStatus, configur
|
|
|
26
26
|
import { jsonForPrompt, pluginPythonCommand, shellEnvironmentReference, } from "./codex-prompt.js";
|
|
27
27
|
import { DEFAULT_CODEX_CONFIG, EXTERNAL_CODEX_PROVIDERS, inlineToml, isExternalModelProvider, hasCommandAuth, mergedCodexConfig, resolveCodexProfile, resolveCommandAuthConfig, scanApprovalPolicy, scanCyberAccessConfig, scanModelConfiguration, scanModelProvider, structuredCodexConfig, writeCodexConfig, } from "./config.js";
|
|
28
28
|
import { estimateScanCost, ScanCostTracker, } from "./cost.js";
|
|
29
|
-
import {
|
|
29
|
+
import { ScanProgressTracker } from "./scan-progress.js";
|
|
30
30
|
import { findScanSession } from "./scan-logs.js";
|
|
31
|
-
import { runDeepScan } from "./deep-scan.js";
|
|
31
|
+
import { DIRECT_DEEP_SCAN_CONTROL_USAGE, runDeepScan } from "./deep-scan.js";
|
|
32
32
|
import { deepScanOptions, resolveDeepScanConfig, writeDeepScanConfig, } from "./deep-config.js";
|
|
33
33
|
import { DEFAULT_SCAN_AUTH, DEFAULT_SCAN_MODE, SCAN_AUTH_MODES, ScanSettingsSchema, } from "./scan-settings.js";
|
|
34
34
|
import { resolveScanPrompts } from "./prompt-files.js";
|
|
@@ -47,9 +47,9 @@ import { formatSecurityPolicyText, inspectSecurityPolicySources, readSecurityPol
|
|
|
47
47
|
import { writeMockScanDraft } from "./mock-scan.js";
|
|
48
48
|
import { scanActivitiesFromEvent } from "./scan-activity.js";
|
|
49
49
|
import { matchCompletedScan, matchScanFindingsInternal, } from "./scan-comparison.js";
|
|
50
|
-
import { scanProgressUpdatesFromEvent, workerStatusFromEvent, } from "./worker-progress.js";
|
|
50
|
+
import { scanProgressUpdatesFromEvent, scanPhaseSchema, workerStatusFromEvent, } from "./worker-progress.js";
|
|
51
51
|
import { CODEX_SECURITY_THREAD_SOURCES } from "./thread-source.js";
|
|
52
|
-
import {
|
|
52
|
+
import { codexSecurityRequestContext } from "./request-metadata.js";
|
|
53
53
|
import { CODEX_EXECUTABLE_VERSION, CODEX_SDK_VERSION } from "./version.js";
|
|
54
54
|
import { bundledCodexSdkEnvironment } from "./codex-sdk-environment.js";
|
|
55
55
|
import { canonicalConfigPath, acquireCodexSecurityCredentialHomeLock, withCredentialHomeLock, bootstrapPlugin, bundledPluginRoot, cleanupSdkDirectory, codexSecurityCredentialAllowsAmbientImport, codexSecurityCredentialHome, codexSecurityHasStoredFileCredentials, codexSecurityStateDirectory, codexExecutableReadPaths, createIsolatedHome, executablePathForSpawn, expandHome, importAmbientAuth, prepareCodexSecurityCredentialHome, preserveCodexSecurityPluginRegistration, pluginExecutionEnvironment, environmentWithGit, pluginMetadata, planOutputArchive, prepareScanArtifactRestorer, prepareOutputDir, prepareScanRegistrationOutput, preparePersistentOutputRoot, probeCodexSandbox, requireModelSafeOutputDir, requireOutputOutsideRepositories, requireOutputOutsideRepository, requirePrivateCredentialHome, requirePrivatePolicyOutputDirectory, resolveCodexCommand, resolvePluginPath, resolvePluginPython, runWorkbench, setCodexSecurityCredentialLogout, validateOutputDir, } from "./runtime.js";
|
|
@@ -294,7 +294,7 @@ export class CodexSecurity {
|
|
|
294
294
|
VALIDATION_PERMISSION_PROFILE;
|
|
295
295
|
session.sessionConfig["web_search"] = "disabled";
|
|
296
296
|
session.sessionConfig["approval_policy"] = "never";
|
|
297
|
-
const { codex } = await this.#createSessionCodex(session, "validate", {
|
|
297
|
+
const { codex } = await this.#createSessionCodex(session, { command: "validate" }, {
|
|
298
298
|
CODEX_SECURITY_REPOSITORY: inputs.repository,
|
|
299
299
|
CODEX_SECURITY_PLUGIN_ROOT: runtime.plugin.pluginRoot,
|
|
300
300
|
CODEX_SECURITY_SURFACE: this.#surface,
|
|
@@ -379,7 +379,7 @@ export class CodexSecurity {
|
|
|
379
379
|
...session.sessionConfig["features"],
|
|
380
380
|
plugins: false,
|
|
381
381
|
};
|
|
382
|
-
const { codex } = await this.#createSessionCodex(session, "patch", {
|
|
382
|
+
const { codex } = await this.#createSessionCodex(session, { command: "patch" }, {
|
|
383
383
|
CODEX_SECURITY_REPOSITORY: repository,
|
|
384
384
|
CODEX_SECURITY_PLUGIN_ROOT: session.runtime.plugin.pluginRoot,
|
|
385
385
|
CODEX_SECURITY_SURFACE: this.#surface,
|
|
@@ -400,7 +400,10 @@ export class CodexSecurity {
|
|
|
400
400
|
: notifyObserver(options, "onSessionEvent"),
|
|
401
401
|
onCost: options.onCost === undefined
|
|
402
402
|
? undefined
|
|
403
|
-
:
|
|
403
|
+
: (cost, complete) => {
|
|
404
|
+
if (complete)
|
|
405
|
+
notifyObserver(options, "onCost")(cost);
|
|
406
|
+
},
|
|
404
407
|
onError: reportTrackingError,
|
|
405
408
|
});
|
|
406
409
|
const thread = codex.startThread({
|
|
@@ -613,8 +616,27 @@ export class CodexSecurity {
|
|
|
613
616
|
runtime.plugin.pluginRoot,
|
|
614
617
|
...(knowledgeBase === null ? [] : [knowledgeBase.path]),
|
|
615
618
|
].filter((path, index, roots) => roots.indexOf(path) === index);
|
|
616
|
-
const
|
|
617
|
-
|
|
619
|
+
const ambientHome = process.platform === "win32"
|
|
620
|
+
? await canonicalConfigPath(scanCodexHome(this.#dependencies.environment))
|
|
621
|
+
: undefined;
|
|
622
|
+
const ambientCredentials = ambientHome === undefined
|
|
623
|
+
? []
|
|
624
|
+
: await Promise.all(["auth.json", "config.toml"].map((name) => realpath(join(ambientHome, name)).catch((error) => {
|
|
625
|
+
if (error.code === "ENOENT")
|
|
626
|
+
return null;
|
|
627
|
+
throw error;
|
|
628
|
+
})));
|
|
629
|
+
const policyFilesystem = policyFilesystemPermissions([
|
|
630
|
+
session.runtimeHome,
|
|
631
|
+
...ambientCredentials.filter((path) => path !== null),
|
|
632
|
+
...(runtime.configPath === undefined ? [] : [runtime.configPath]),
|
|
633
|
+
...(runtime.deepScanConfigPath === undefined ||
|
|
634
|
+
runtime.deepScanConfigDirectory !== undefined
|
|
635
|
+
? []
|
|
636
|
+
: [runtime.deepScanConfigPath]),
|
|
637
|
+
...inputs.gitMetadataPaths,
|
|
638
|
+
], await codexExecutableReadPaths(this.#codexCommand().command), ambientHome);
|
|
639
|
+
const { codex } = await this.#createSessionCodex(session, { command: "policy" }, {
|
|
618
640
|
CODEX_SECURITY_REPOSITORY: target.repository,
|
|
619
641
|
CODEX_SECURITY_PLUGIN_ROOT: runtime.plugin.pluginRoot,
|
|
620
642
|
CODEX_SECURITY_STATE_DIR: inputs.stateDirectory,
|
|
@@ -626,9 +648,9 @@ export class CodexSecurity {
|
|
|
626
648
|
// CLI override keys split on dots, so keep paths inside the TOML value.
|
|
627
649
|
`permissions.${POLICY_PERMISSION_PROFILE}.filesystem=${inlineToml(policyFilesystem)}`,
|
|
628
650
|
]);
|
|
629
|
-
const reportCost = (current) => {
|
|
651
|
+
const reportCost = (current, complete = true) => {
|
|
630
652
|
const total = addScanCosts(accumulatedCost, current);
|
|
631
|
-
if (completeCost)
|
|
653
|
+
if (completeCost && complete)
|
|
632
654
|
notifyObserver(options, "onCost")(total);
|
|
633
655
|
if (options.maxCostUsd !== undefined &&
|
|
634
656
|
total.estimatedUsd > options.maxCostUsd) {
|
|
@@ -777,12 +799,13 @@ export class CodexSecurity {
|
|
|
777
799
|
]);
|
|
778
800
|
let maxCostUsd = options.maxCostUsd;
|
|
779
801
|
let latestCost = null;
|
|
802
|
+
let latestCostComplete = false;
|
|
780
803
|
let notifiedLimit;
|
|
781
804
|
let scanDir = "";
|
|
782
805
|
let targetPathsFile = null;
|
|
783
806
|
let knowledgeBase = null;
|
|
784
807
|
let costTracker = null;
|
|
785
|
-
let
|
|
808
|
+
let scanProgressTracker = null;
|
|
786
809
|
let artifactRestorationFailure = null;
|
|
787
810
|
let customValidationComplete = false;
|
|
788
811
|
let completionCost = null;
|
|
@@ -913,12 +936,12 @@ export class CodexSecurity {
|
|
|
913
936
|
: {};
|
|
914
937
|
const workerSnapshot = {
|
|
915
938
|
...workerRuntimeConfig,
|
|
916
|
-
responses_api_metadata: {
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
},
|
|
939
|
+
responses_api_metadata: codexSecurityRequestContext(effectiveConfig, {
|
|
940
|
+
surface: this.#surface,
|
|
941
|
+
command: "scan",
|
|
942
|
+
pluginVersion: runtime.plugin.version,
|
|
943
|
+
mode,
|
|
944
|
+
}).metadata,
|
|
922
945
|
...(workerEnvironment === undefined
|
|
923
946
|
? {}
|
|
924
947
|
: { environment: workerEnvironment }),
|
|
@@ -984,6 +1007,8 @@ export class CodexSecurity {
|
|
|
984
1007
|
}
|
|
985
1008
|
let scopeFileCount = null;
|
|
986
1009
|
let reviewedFileCount = 0;
|
|
1010
|
+
let latestPhase = "preflight";
|
|
1011
|
+
let reviewItems;
|
|
987
1012
|
const reportProgress = (progress) => {
|
|
988
1013
|
if (scopeFileCount === null ||
|
|
989
1014
|
progress.filesTotal > scopeFileCount ||
|
|
@@ -991,7 +1016,29 @@ export class CodexSecurity {
|
|
|
991
1016
|
return;
|
|
992
1017
|
}
|
|
993
1018
|
reviewedFileCount = progress.filesCompleted;
|
|
994
|
-
|
|
1019
|
+
if (mode === "deep" ||
|
|
1020
|
+
scanPhaseSchema.options.indexOf(progress.phase) >
|
|
1021
|
+
scanPhaseSchema.options.indexOf(latestPhase)) {
|
|
1022
|
+
latestPhase = progress.phase;
|
|
1023
|
+
}
|
|
1024
|
+
notifyObserver(options, "onProgress")({
|
|
1025
|
+
...progress,
|
|
1026
|
+
phase: latestPhase,
|
|
1027
|
+
filesTotal: scopeFileCount,
|
|
1028
|
+
...(reviewItems === undefined ? {} : { reviewItems }),
|
|
1029
|
+
});
|
|
1030
|
+
};
|
|
1031
|
+
const reportWorkerStatus = (status) => {
|
|
1032
|
+
if (mode !== "deep") {
|
|
1033
|
+
const phase = status.phase === "ranking" || status.phase === "file_review"
|
|
1034
|
+
? "discovery"
|
|
1035
|
+
: status.phase;
|
|
1036
|
+
if (scanPhaseSchema.options.indexOf(phase) <
|
|
1037
|
+
scanPhaseSchema.options.indexOf(latestPhase))
|
|
1038
|
+
return;
|
|
1039
|
+
latestPhase = phase;
|
|
1040
|
+
}
|
|
1041
|
+
notifyObserver(options, "onWorkerStatus")(status);
|
|
995
1042
|
};
|
|
996
1043
|
const reportedInaccessibleSessionLogs = new Set();
|
|
997
1044
|
const reportTrackingError = (error) => {
|
|
@@ -1028,12 +1075,20 @@ export class CodexSecurity {
|
|
|
1028
1075
|
onSessionEvent: options.onSessionEvent === undefined
|
|
1029
1076
|
? undefined
|
|
1030
1077
|
: (event) => notifyObserver(options, "onSessionEvent")(event),
|
|
1031
|
-
onProgress: options.onProgress === undefined
|
|
1078
|
+
onProgress: options.onProgress === undefined
|
|
1079
|
+
? undefined
|
|
1080
|
+
: (progress) => reportProgress({
|
|
1081
|
+
...progress,
|
|
1082
|
+
// Worker counts belong to the parent scan's current phase.
|
|
1083
|
+
phase: mode === "deep" ? progress.phase : latestPhase,
|
|
1084
|
+
}),
|
|
1032
1085
|
onCost: options.onCost === undefined && options.maxCostUsd === undefined
|
|
1033
1086
|
? undefined
|
|
1034
|
-
: (cost) => {
|
|
1087
|
+
: (cost, complete) => {
|
|
1035
1088
|
latestCost = cost;
|
|
1036
|
-
|
|
1089
|
+
latestCostComplete = complete;
|
|
1090
|
+
if (complete)
|
|
1091
|
+
notifyObserver(options, "onCost")(cost, maxCostUsd);
|
|
1037
1092
|
if (maxCostUsd !== undefined &&
|
|
1038
1093
|
cost.estimatedUsd > maxCostUsd) {
|
|
1039
1094
|
costAbortController.abort(new ScanCostLimitExceededError(maxCostUsd, cost, scanDir));
|
|
@@ -1072,7 +1127,8 @@ export class CodexSecurity {
|
|
|
1072
1127
|
if (budgetSignal.aborted)
|
|
1073
1128
|
return;
|
|
1074
1129
|
maxCostUsd = next;
|
|
1075
|
-
|
|
1130
|
+
if (latestCostComplete)
|
|
1131
|
+
notifyObserver(options, "onCost")(latestCost, maxCostUsd);
|
|
1076
1132
|
})
|
|
1077
1133
|
.catch((error) => {
|
|
1078
1134
|
if (!budgetSignal.aborted) {
|
|
@@ -1238,22 +1294,42 @@ export class CodexSecurity {
|
|
|
1238
1294
|
notifyObserver(options, "onOutputDirReady")(scanDir);
|
|
1239
1295
|
}
|
|
1240
1296
|
throwIfAborted(signal, scanDir);
|
|
1241
|
-
if (
|
|
1297
|
+
if (this.#dependencies.hostedScan === undefined &&
|
|
1298
|
+
((mode !== "deep" && options.onProgress !== undefined) ||
|
|
1299
|
+
(mode === "deep" && options.onDeepProgress !== undefined))) {
|
|
1242
1300
|
let progressWarningReported = false;
|
|
1243
|
-
|
|
1301
|
+
scanProgressTracker = new ScanProgressTracker({
|
|
1244
1302
|
read: (progressSignal) => workbench({
|
|
1245
1303
|
...workbenchOptions,
|
|
1246
1304
|
signal: AbortSignal.any([signal, progressSignal]),
|
|
1247
1305
|
}, workbenchArgs("get-scan", { scanId })),
|
|
1248
|
-
onProgress:
|
|
1306
|
+
onProgress: mode === "deep"
|
|
1307
|
+
? undefined
|
|
1308
|
+
: (progress) => {
|
|
1309
|
+
reviewItems = progress.reviewItems;
|
|
1310
|
+
if (scopeFileCount === null && progress.filesTotal !== null) {
|
|
1311
|
+
scopeFileCount = progress.filesTotal;
|
|
1312
|
+
tracker.setExpectedFilesTotal(scopeFileCount);
|
|
1313
|
+
}
|
|
1314
|
+
if (scopeFileCount === null)
|
|
1315
|
+
return;
|
|
1316
|
+
reportProgress({
|
|
1317
|
+
phase: progress.phase,
|
|
1318
|
+
filesCompleted: reviewedFileCount,
|
|
1319
|
+
filesTotal: scopeFileCount,
|
|
1320
|
+
});
|
|
1321
|
+
},
|
|
1322
|
+
onDeepProgress: mode === "deep"
|
|
1323
|
+
? (progress) => notifyObserver(options, "onDeepProgress")(progress)
|
|
1324
|
+
: undefined,
|
|
1249
1325
|
onError: (error) => {
|
|
1250
1326
|
if (progressWarningReported)
|
|
1251
1327
|
return;
|
|
1252
1328
|
progressWarningReported = true;
|
|
1253
|
-
notifyObserver(options, "onWarning")(`Could not track Deep Scan progress: ${errorMessage(error)}`);
|
|
1329
|
+
notifyObserver(options, "onWarning")(`Could not track ${mode === "deep" ? "Deep Scan" : "scan"} progress: ${errorMessage(error)}`);
|
|
1254
1330
|
},
|
|
1255
1331
|
});
|
|
1256
|
-
|
|
1332
|
+
scanProgressTracker.start();
|
|
1257
1333
|
}
|
|
1258
1334
|
if (options.validationPrompt !== undefined) {
|
|
1259
1335
|
await writeCustomValidationStatus(scanDir, { scanId, status: "pending" }, signal);
|
|
@@ -1339,7 +1415,7 @@ export class CodexSecurity {
|
|
|
1339
1415
|
? {}
|
|
1340
1416
|
: { CODEX_SECURITY_TARGET_PATHS_FILE: targetPathsFile }),
|
|
1341
1417
|
};
|
|
1342
|
-
const { codex, environment, codexOptions } = await this.#createSessionCodex(session, "scan", runtimePaths, options.auth, git);
|
|
1418
|
+
const { codex, environment, codexOptions } = await this.#createSessionCodex(session, { command: "scan", mode }, runtimePaths, options.auth, git);
|
|
1343
1419
|
const threadOptions = {
|
|
1344
1420
|
threadSource: CODEX_SECURITY_THREAD_SOURCES.scan,
|
|
1345
1421
|
workingDirectory: scanDir,
|
|
@@ -1434,6 +1510,8 @@ export class CodexSecurity {
|
|
|
1434
1510
|
}
|
|
1435
1511
|
if (budgetRecovery !== null)
|
|
1436
1512
|
budgetRecovery.threadId = threadId;
|
|
1513
|
+
if (directDeepScan)
|
|
1514
|
+
tracker.recordUsage(DIRECT_DEEP_SCAN_CONTROL_USAGE, threadId);
|
|
1437
1515
|
tracker.start(threadId);
|
|
1438
1516
|
try {
|
|
1439
1517
|
await workbench(workbenchOptions, workbenchArgs("set-scan-thread", { scanId, threadId }));
|
|
@@ -1457,6 +1535,9 @@ export class CodexSecurity {
|
|
|
1457
1535
|
falsePositives: falsePositiveExamples,
|
|
1458
1536
|
signal,
|
|
1459
1537
|
run: async (validationPrompt, outputSchema) => {
|
|
1538
|
+
// This turn follows the primary scan's reporting phase.
|
|
1539
|
+
scanProgressTracker?.stop();
|
|
1540
|
+
latestPhase = "validation";
|
|
1460
1541
|
if (scopeFileCount !== null)
|
|
1461
1542
|
reportProgress({
|
|
1462
1543
|
phase: "validation",
|
|
@@ -1542,7 +1623,7 @@ export class CodexSecurity {
|
|
|
1542
1623
|
}
|
|
1543
1624
|
reportProgress(progress);
|
|
1544
1625
|
},
|
|
1545
|
-
onWorkerStatus:
|
|
1626
|
+
onWorkerStatus: reportWorkerStatus,
|
|
1546
1627
|
onWarning: options.onWarning,
|
|
1547
1628
|
onObserverError: options.onObserverError,
|
|
1548
1629
|
});
|
|
@@ -1582,6 +1663,7 @@ export class CodexSecurity {
|
|
|
1582
1663
|
}
|
|
1583
1664
|
}
|
|
1584
1665
|
}
|
|
1666
|
+
scanProgressTracker?.stop();
|
|
1585
1667
|
if (runPostScan !== null) {
|
|
1586
1668
|
const followUp = runPostScan;
|
|
1587
1669
|
runPostScan = null;
|
|
@@ -1654,7 +1736,10 @@ export class CodexSecurity {
|
|
|
1654
1736
|
const runWorkbench = (args, input) => workbench(workbenchOptions, args, input);
|
|
1655
1737
|
const previousFindings = await listRepositoryFindings(runWorkbench, targetId, "all");
|
|
1656
1738
|
if (previousFindings !== undefined) {
|
|
1657
|
-
const matchingRuntimeConfig =
|
|
1739
|
+
const matchingRuntimeConfig = {
|
|
1740
|
+
...structuredClone(workerRuntimeConfig),
|
|
1741
|
+
responses_api_metadata: workerSnapshot["responses_api_metadata"],
|
|
1742
|
+
};
|
|
1658
1743
|
const matchingFeatures = matchingRuntimeConfig["features"];
|
|
1659
1744
|
if (isRecord(matchingFeatures))
|
|
1660
1745
|
delete matchingFeatures["plugins"];
|
|
@@ -1792,6 +1877,7 @@ export class CodexSecurity {
|
|
|
1792
1877
|
catch { }
|
|
1793
1878
|
}
|
|
1794
1879
|
if (runPostScan !== null && !signal.aborted) {
|
|
1880
|
+
scanProgressTracker?.stop();
|
|
1795
1881
|
try {
|
|
1796
1882
|
for await (const event of (await runPostScan()).events) {
|
|
1797
1883
|
if (event.type === "turn.failed") {
|
|
@@ -1814,7 +1900,7 @@ export class CodexSecurity {
|
|
|
1814
1900
|
}
|
|
1815
1901
|
finally {
|
|
1816
1902
|
budgetAbortController.abort();
|
|
1817
|
-
|
|
1903
|
+
scanProgressTracker?.stop();
|
|
1818
1904
|
// Temporary-input cleanup must not replace the scan's outcome.
|
|
1819
1905
|
try {
|
|
1820
1906
|
for (const cleanup of await Promise.allSettled([
|
|
@@ -1975,7 +2061,7 @@ export class CodexSecurity {
|
|
|
1975
2061
|
activeOperation.resolve();
|
|
1976
2062
|
}
|
|
1977
2063
|
}
|
|
1978
|
-
async #createSessionCodex(session, command, runtimePaths, auth = "auto", git, config, configOverrides = []) {
|
|
2064
|
+
async #createSessionCodex(session, { command, mode }, runtimePaths, auth = "auto", git, config, configOverrides = []) {
|
|
1979
2065
|
const hosted = this.#dependencies.hostedScan;
|
|
1980
2066
|
if (hosted !== undefined) {
|
|
1981
2067
|
const environment = {
|
|
@@ -2090,9 +2176,13 @@ export class CodexSecurity {
|
|
|
2090
2176
|
...configOverrides,
|
|
2091
2177
|
];
|
|
2092
2178
|
}
|
|
2093
|
-
const
|
|
2094
|
-
|
|
2095
|
-
|
|
2179
|
+
const requestContext = codexSecurityRequestContext(config ?? sessionConfig, {
|
|
2180
|
+
surface: this.#surface,
|
|
2181
|
+
command,
|
|
2182
|
+
pluginVersion: runtime.plugin.version,
|
|
2183
|
+
mode,
|
|
2184
|
+
});
|
|
2185
|
+
delete sdkCodexConfig["responses_api_metadata"];
|
|
2096
2186
|
const configuredCodexPath = environmentValue(this.#dependencies.environment, "CODEX_CLI_PATH");
|
|
2097
2187
|
let codexPathOverride = configuredCodexPath === undefined
|
|
2098
2188
|
? undefined
|
|
@@ -2112,19 +2202,9 @@ export class CodexSecurity {
|
|
|
2112
2202
|
...(runtime.providerProfile === undefined
|
|
2113
2203
|
? {}
|
|
2114
2204
|
: { nativeProfile: runtime.providerProfile.name }),
|
|
2115
|
-
...
|
|
2116
|
-
? {
|
|
2117
|
-
configOverrides,
|
|
2118
|
-
}
|
|
2119
|
-
: {}),
|
|
2205
|
+
configOverrides: [...configOverrides, requestContext.configOverride],
|
|
2120
2206
|
env: sdkEnvironment,
|
|
2121
|
-
config:
|
|
2122
|
-
...sdkCodexConfig,
|
|
2123
|
-
responses_api_metadata: {
|
|
2124
|
-
...configuredResponsesMetadata,
|
|
2125
|
-
...codexSecurityRequestMetadata(this.#surface, command, runtime.plugin.version),
|
|
2126
|
-
},
|
|
2127
|
-
},
|
|
2207
|
+
config: sdkCodexConfig,
|
|
2128
2208
|
};
|
|
2129
2209
|
const codex = await this.#dependencies.createCodex(codexOptions);
|
|
2130
2210
|
return { codex, environment, codexOptions };
|
|
@@ -2631,7 +2711,10 @@ export class CodexSecurity {
|
|
|
2631
2711
|
let deepScanConfigDirectory;
|
|
2632
2712
|
try {
|
|
2633
2713
|
throwIfAborted(signal);
|
|
2634
|
-
bootstrapWorkspace = await createIsolatedHome(
|
|
2714
|
+
bootstrapWorkspace = await createIsolatedHome(
|
|
2715
|
+
// Windows sandboxes can grant replacement rights on TEMP. Keep private
|
|
2716
|
+
// staging beside the validated home, outside it so ZIP plugins are readable.
|
|
2717
|
+
process.platform === "win32" ? dirname(codexHome) : temporaryRoot, validateLocation);
|
|
2635
2718
|
await requirePrivateCredentialHome(await lstat(bootstrapWorkspace), bootstrapWorkspace);
|
|
2636
2719
|
const pluginRoot = await resolvePluginPath(this.config.pluginPath, bootstrapWorkspace, signal);
|
|
2637
2720
|
const ambientHome = scanCodexHome(processEnvironment);
|
|
@@ -2826,7 +2909,9 @@ export async function runScanEvents(options) {
|
|
|
2826
2909
|
}
|
|
2827
2910
|
// Managed scans reconcile saved checkpoints before admitting canonical artifacts.
|
|
2828
2911
|
if (options.workbenchValidated && options.onFinalize !== undefined) {
|
|
2829
|
-
|
|
2912
|
+
const finalizedUsage = await options.onFinalize(usage);
|
|
2913
|
+
if (finalizedUsage !== undefined)
|
|
2914
|
+
usage = finalizedUsage;
|
|
2830
2915
|
}
|
|
2831
2916
|
options.signal.throwIfAborted();
|
|
2832
2917
|
await requireScanArtifacts(options.scanDir, ["scan-manifest.json", "findings.json", "coverage.json"], options.signal);
|
|
@@ -2843,7 +2928,9 @@ export async function runScanEvents(options) {
|
|
|
2843
2928
|
throw new IncompleteScanError("Codex Security produced only an unfinished audit checkpoint.");
|
|
2844
2929
|
}
|
|
2845
2930
|
if (!options.workbenchValidated && options.onFinalize !== undefined) {
|
|
2846
|
-
|
|
2931
|
+
const finalizedUsage = await options.onFinalize(usage);
|
|
2932
|
+
if (finalizedUsage !== undefined)
|
|
2933
|
+
usage = finalizedUsage;
|
|
2847
2934
|
}
|
|
2848
2935
|
const result = await collectResult({
|
|
2849
2936
|
status,
|
|
@@ -3390,21 +3477,30 @@ export function scanRuntimeCodexConfig(config, protectedCredentialHome) {
|
|
|
3390
3477
|
},
|
|
3391
3478
|
},
|
|
3392
3479
|
[POLICY_PERMISSION_PROFILE]: {
|
|
3393
|
-
filesystem: policyFilesystemPermissions(
|
|
3480
|
+
filesystem: policyFilesystemPermissions(protectedCredentialHome === undefined
|
|
3481
|
+
? []
|
|
3482
|
+
: [protectedCredentialHome]),
|
|
3394
3483
|
network: { enabled: false },
|
|
3395
3484
|
},
|
|
3396
3485
|
},
|
|
3397
3486
|
};
|
|
3398
3487
|
}
|
|
3399
|
-
function policyFilesystemPermissions(
|
|
3400
|
-
|
|
3401
|
-
|
|
3488
|
+
function policyFilesystemPermissions(deniedPaths = [], codexPaths = [], ambientHome) {
|
|
3489
|
+
const filesystem = {
|
|
3490
|
+
// Windows' elevated sandbox requires root read access.
|
|
3491
|
+
[process.platform === "win32" ? ":root" : ":minimal"]: "read",
|
|
3402
3492
|
":workspace_roots": "read",
|
|
3403
3493
|
// Linux's sandbox re-executes Codex, including installations outside /usr.
|
|
3404
3494
|
...Object.fromEntries(codexPaths.map((path) => [path, { ".": "read" }])),
|
|
3405
3495
|
// A scoped "." keeps native permission paths literal, including glob characters.
|
|
3406
|
-
...Object.fromEntries(
|
|
3496
|
+
...Object.fromEntries(deniedPaths.map((path) => [path, { ".": "deny" }])),
|
|
3407
3497
|
};
|
|
3498
|
+
if (process.platform === "win32" && ambientHome !== undefined) {
|
|
3499
|
+
// A glob avoids materializing absent credentials as directories on Windows.
|
|
3500
|
+
// Absolute patterns also support literal metacharacters in the home path.
|
|
3501
|
+
filesystem[join(ambientHome.replace(/[*?[\]{}]/gu, "[$&]"), "{auth.json,config.toml,*.config.toml,.*.config.toml.tmp}")] = "deny";
|
|
3502
|
+
}
|
|
3503
|
+
return filesystem;
|
|
3408
3504
|
}
|
|
3409
3505
|
function rethrowPolicyOutputError(error) {
|
|
3410
3506
|
if (error instanceof OutputDirectoryNotEmptyError)
|
|
@@ -3474,6 +3570,7 @@ export function scanPreflightCodexConfig(config) {
|
|
|
3474
3570
|
"goals",
|
|
3475
3571
|
"multi_agent",
|
|
3476
3572
|
"enable_fanout",
|
|
3573
|
+
"cli_daybreak",
|
|
3477
3574
|
"api_key_cyber_access_programs",
|
|
3478
3575
|
"api_key_model_discovery",
|
|
3479
3576
|
]) {
|
|
@@ -3501,6 +3598,9 @@ export function scanPreflightCodexConfig(config) {
|
|
|
3501
3598
|
};
|
|
3502
3599
|
const executionConfig = (source) => {
|
|
3503
3600
|
const result = {};
|
|
3601
|
+
if (typeof source["daybreak"] === "boolean") {
|
|
3602
|
+
result["daybreak"] = source["daybreak"];
|
|
3603
|
+
}
|
|
3504
3604
|
for (const key of [
|
|
3505
3605
|
"model",
|
|
3506
3606
|
"model_reasoning_effort",
|
|
@@ -3552,8 +3652,12 @@ export function scanPreflightCodexConfig(config) {
|
|
|
3552
3652
|
if (safeString(value))
|
|
3553
3653
|
result[key] = value;
|
|
3554
3654
|
}
|
|
3655
|
+
if (typeof resolved["daybreak"] === "boolean") {
|
|
3656
|
+
result["daybreak"] = resolved["daybreak"];
|
|
3657
|
+
}
|
|
3555
3658
|
const resolvedFeatures = capabilityFeatures(resolved["features"]);
|
|
3556
3659
|
for (const key of [
|
|
3660
|
+
"cli_daybreak",
|
|
3557
3661
|
"api_key_cyber_access_programs",
|
|
3558
3662
|
"api_key_model_discovery",
|
|
3559
3663
|
]) {
|
|
@@ -3591,7 +3695,7 @@ export function scanPreflightCodexConfig(config) {
|
|
|
3591
3695
|
};
|
|
3592
3696
|
}
|
|
3593
3697
|
else if (modelProvider === "amazon-bedrock") {
|
|
3594
|
-
const providers =
|
|
3698
|
+
const providers = resolved["model_providers"];
|
|
3595
3699
|
const provider = isRecord(providers) ? providers[modelProvider] : undefined;
|
|
3596
3700
|
const aws = isRecord(provider) ? provider["aws"] : undefined;
|
|
3597
3701
|
if (isRecord(aws)) {
|