@openai/codex-security 0.1.24 → 0.1.26
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 +399 -27
- package/_bundled_plugin/.app.json +0 -5
- package/_bundled_plugin/.codex-plugin/plugin.json +1 -1
- 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/config-preflight.md +2 -2
- package/_bundled_plugin/references/final-report.md +5 -3
- package/_bundled_plugin/references/scan-artifacts.md +5 -1
- package/_bundled_plugin/references/scan-contract.md +7 -3
- package/_bundled_plugin/schemas/tools/deep-reducer.schema.json +27 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +6 -1
- package/_bundled_plugin/scripts/finalize_scan_contract.py +2 -5
- package/_bundled_plugin/scripts/rank_preview.py +11 -1
- package/_bundled_plugin/scripts/report_projection.py +1 -1
- package/_bundled_plugin/scripts/workbench_cli.py +11 -1
- package/_bundled_plugin/scripts/workbench_db.py +55 -4
- package/_bundled_plugin/scripts/workbench_saved_results.py +41 -22
- package/_bundled_plugin/scripts/workbench_scan_history.py +374 -66
- package/_bundled_plugin/scripts/workbench_scan_usage.py +7 -6
- package/_bundled_plugin/scripts/workbench_schema.py +46 -0
- package/_bundled_plugin/scripts/workbench_severity.py +119 -0
- package/_bundled_plugin/scripts/workbench_target.py +86 -12
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +5 -3
- package/_bundled_plugin/skills/verify-fix/SKILL.md +5 -1
- package/dist/api.d.ts +15 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +333 -32
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +35 -3
- package/dist/auth.js.map +1 -1
- package/dist/classify-scan-severity.d.ts +16 -0
- package/dist/classify-scan-severity.d.ts.map +1 -0
- package/dist/classify-scan-severity.js +96 -0
- package/dist/classify-scan-severity.js.map +1 -0
- package/dist/classify-severity.d.ts +38 -0
- package/dist/classify-severity.d.ts.map +1 -0
- package/dist/classify-severity.js +185 -0
- package/dist/classify-severity.js.map +1 -0
- package/dist/cli.d.ts +7 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +403 -116
- package/dist/cli.js.map +1 -1
- package/dist/component-plan.d.ts.map +1 -1
- package/dist/component-plan.js +4 -2
- package/dist/component-plan.js.map +1 -1
- package/dist/component-scan.d.ts.map +1 -1
- package/dist/component-scan.js +21 -6
- package/dist/component-scan.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +46 -2
- package/dist/config.js.map +1 -1
- package/dist/cost.d.ts +1 -0
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +43 -17
- package/dist/cost.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -1
- package/dist/deduplication/checkpointed-review.js +2 -1
- package/dist/deduplication/checkpointed-review.js.map +1 -1
- package/dist/deduplication/codex-review.d.ts +3 -0
- package/dist/deduplication/codex-review.d.ts.map +1 -1
- package/dist/deduplication/codex-review.js +122 -36
- package/dist/deduplication/codex-review.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +4 -3
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +18 -9
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/deduplication-reviewer.d.ts +2 -7
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -1
- package/dist/deduplication/deduplication-reviewer.js +47 -25
- package/dist/deduplication/deduplication-reviewer.js.map +1 -1
- package/dist/deduplication/deduplication.d.ts.map +1 -1
- package/dist/deduplication/deduplication.js +186 -23
- package/dist/deduplication/deduplication.js.map +1 -1
- package/dist/deduplication/scan.d.ts +9 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +24 -7
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +7 -0
- package/dist/errors.js.map +1 -1
- package/dist/finding-catalogue.d.ts +11 -0
- package/dist/finding-catalogue.d.ts.map +1 -0
- package/dist/finding-catalogue.js +150 -0
- package/dist/finding-catalogue.js.map +1 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/mock-scan.d.ts +4 -0
- package/dist/mock-scan.d.ts.map +1 -0
- package/dist/mock-scan.js +210 -0
- package/dist/mock-scan.js.map +1 -0
- package/dist/patch-tui.js +1 -1
- package/dist/patch-tui.js.map +1 -1
- package/dist/publication-store.d.ts.map +1 -1
- package/dist/publication-store.js +9 -4
- package/dist/publication-store.js.map +1 -1
- package/dist/publication.d.ts +9 -0
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +45 -5
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts +4 -2
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +4 -4
- package/dist/publish.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +49 -14
- package/dist/runtime.js.map +1 -1
- package/dist/scan-comparison.d.ts +44 -30
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +673 -101
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts +3 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +70 -3
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +26 -0
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/server/api.d.ts +6 -0
- package/dist/server/api.d.ts.map +1 -0
- package/dist/server/api.js +4 -0
- package/dist/server/api.js.map +1 -0
- package/dist/server/dashboard/app.css +1 -1
- package/dist/server/embeddings.d.ts +2 -1
- package/dist/server/embeddings.d.ts.map +1 -1
- package/dist/server/embeddings.js +8 -3
- package/dist/server/embeddings.js.map +1 -1
- package/dist/server/serve.d.ts.map +1 -1
- package/dist/server/serve.js +1 -1
- package/dist/server/serve.js.map +1 -1
- package/dist/severity-store.d.ts +2 -0
- package/dist/severity-store.d.ts.map +1 -0
- package/dist/severity-store.js +111 -0
- package/dist/severity-store.js.map +1 -0
- package/dist/targets.d.ts.map +1 -1
- package/dist/targets.js +3 -5
- package/dist/targets.js.map +1 -1
- package/dist/thread-source.d.ts +1 -0
- package/dist/thread-source.d.ts.map +1 -1
- package/dist/thread-source.js +1 -0
- package/dist/thread-source.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +11 -6
package/dist/api.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
-
import {
|
|
2
|
+
import { statSync } from "node:fs";
|
|
3
|
+
import { chmod, lstat, mkdir, mkdtemp, readFile, realpath, rm, writeFile, } from "node:fs/promises";
|
|
3
4
|
import { randomUUID } from "node:crypto";
|
|
4
5
|
import { homedir, tmpdir } from "node:os";
|
|
5
|
-
import { basename, dirname, isAbsolute, join, relative, resolve, sep, } from "node:path";
|
|
6
|
+
import { basename, delimiter, dirname, isAbsolute, join, relative, resolve, sep, } from "node:path";
|
|
6
7
|
import { Codex, } from "@openai/codex-sdk";
|
|
7
8
|
import { parse as parseToml, stringify as stringifyToml, } from "smol-toml";
|
|
8
9
|
import { z } from "incur";
|
|
9
|
-
import { accountStatus, CodexLoginHandle, loginApiKey as persistApiKey, logout as codexLogout, } from "./auth.js";
|
|
10
|
+
import { accountStatus, configuredCodexHome, CodexLoginHandle, loginApiKey as persistApiKey, logout as codexLogout, } from "./auth.js";
|
|
10
11
|
import { jsonForPrompt, pluginPythonCommand, shellEnvironmentReference, } from "./codex-prompt.js";
|
|
11
|
-
import { EXTERNAL_CODEX_PROVIDERS, isExternalModelProvider, mergedCodexConfig, scanApprovalPolicy, scanModelConfiguration, scanModelProvider, writeCodexConfig, } from "./config.js";
|
|
12
|
-
import { estimateScanCost, ScanCostTracker,
|
|
12
|
+
import { DEFAULT_CODEX_CONFIG, EXTERNAL_CODEX_PROVIDERS, isExternalModelProvider, hasCommandAuth, mergedCodexConfig, modelProviderConfigOverride, resolveCommandAuthConfig, scanApprovalPolicy, scanModelConfiguration, scanModelProvider, writeCodexConfig, } from "./config.js";
|
|
13
|
+
import { estimateScanCost, ScanCostTracker, } from "./cost.js";
|
|
13
14
|
import { DeepScanProgressTracker, } from "./deep-progress.js";
|
|
14
15
|
import { loadContract, readScanFile, requireScanFile, } from "./contract.js";
|
|
15
16
|
import { runCustomValidation, writeCustomValidationStatus, } from "./custom-validation.js";
|
|
@@ -18,12 +19,13 @@ import { AuthenticationRequiredError, CodexSecurityError, ConfigurationError, In
|
|
|
18
19
|
import { prepareKnowledgeBase, } from "./knowledge-base.js";
|
|
19
20
|
import { FindingWorkflow, workflowDigest } from "./finding-workflow.js";
|
|
20
21
|
import { ScanResult, } from "./result.js";
|
|
22
|
+
import { writeMockScanDraft } from "./mock-scan.js";
|
|
21
23
|
import { scanActivitiesFromEvent } from "./scan-activity.js";
|
|
22
24
|
import { matchCompletedScan, matchScanFindingsInternal, } from "./scan-comparison.js";
|
|
23
25
|
import { scanProgressUpdatesFromEvent, workerStatusFromEvent, } from "./worker-progress.js";
|
|
24
26
|
import { CODEX_SECURITY_THREAD_SOURCES } from "./thread-source.js";
|
|
25
27
|
import { CODEX_EXECUTABLE_VERSION, CODEX_SDK_VERSION } from "./version.js";
|
|
26
|
-
import { acquireCodexSecurityCredentialHomeLock, bootstrapPlugin, bundledPluginRoot, cleanupSdkDirectory, codexSecurityCredentialAllowsAmbientImport, codexSecurityCredentialHome, codexSecurityHasStoredFileCredentials, codexSecurityStateDirectory, createIsolatedHome, expandHome, importAmbientAuth, prepareCodexSecurityCredentialHome, preserveCodexSecurityPluginRegistration, pluginExecutionEnvironment, planOutputArchive, prepareScanArtifactRestorer, prepareOutputDir, preparePersistentOutputRoot, requireModelSafeOutputDir, requireOutputOutsideRepository, resolveCodexCommand, resolvePluginPath, resolvePluginPython, runWorkbench, setCodexSecurityCredentialLogout, validateOutputDir, } from "./runtime.js";
|
|
28
|
+
import { acquireCodexSecurityCredentialHomeLock, bootstrapPlugin, bundledPluginRoot, cleanupSdkDirectory, codexSecurityCredentialAllowsAmbientImport, codexSecurityCredentialHome, codexSecurityHasStoredFileCredentials, codexSecurityStateDirectory, createIsolatedHome, executablePathForSpawn, expandHome, importAmbientAuth, prepareCodexSecurityCredentialHome, preserveCodexSecurityPluginRegistration, pluginExecutionEnvironment, pluginMetadata, planOutputArchive, prepareScanArtifactRestorer, prepareOutputDir, preparePersistentOutputRoot, requireModelSafeOutputDir, requireOutputOutsideRepository, resolveCodexCommand, resolvePluginPath, resolvePluginPython, runWorkbench, setCodexSecurityCredentialLogout, validateOutputDir, } from "./runtime.js";
|
|
27
29
|
import { enclosingGitWorktreeRoot, normalizeRepository, normalizeTarget, repositoryRevision, resolveRepositoryPath, validatedGitEnvironment, validateCommittedDiffCheckout, validateMode, } from "./targets.js";
|
|
28
30
|
const DEEP_SCAN_CONFIG_PATH_ENVIRONMENT = "CODEX_SECURITY_DEEP_SCAN_CONFIG_PATH";
|
|
29
31
|
const VALIDATION_DISPOSITIONS = [
|
|
@@ -278,7 +280,7 @@ export class CodexSecurity {
|
|
|
278
280
|
: {}),
|
|
279
281
|
outputDir: inputs.outputDir,
|
|
280
282
|
...(archiveDir === null ? {} : { archiveDir }),
|
|
281
|
-
authentication: scanAuthentication(this.#dependencies.environment, options.auth, modelProvider),
|
|
283
|
+
authentication: scanAuthentication(this.#dependencies.environment, options.auth, modelProvider, hasCommandAuth(configuration)),
|
|
282
284
|
...model,
|
|
283
285
|
...(typeof modelProvider === "string" ? { modelProvider } : {}),
|
|
284
286
|
...(options.maxCostUsd === undefined
|
|
@@ -288,12 +290,22 @@ export class CodexSecurity {
|
|
|
288
290
|
}
|
|
289
291
|
async #run(repository, options) {
|
|
290
292
|
this.#requireOpen();
|
|
293
|
+
if (options.mock)
|
|
294
|
+
return await this.#runMock(repository, options);
|
|
291
295
|
const costAbortController = new AbortController();
|
|
292
296
|
const signal = AbortSignal.any([
|
|
293
297
|
this.#abortController.signal,
|
|
294
298
|
costAbortController.signal,
|
|
295
299
|
...(options.signal === undefined ? [] : [options.signal]),
|
|
296
300
|
]);
|
|
301
|
+
const budgetAbortController = new AbortController();
|
|
302
|
+
const budgetSignal = AbortSignal.any([
|
|
303
|
+
signal,
|
|
304
|
+
budgetAbortController.signal,
|
|
305
|
+
]);
|
|
306
|
+
let maxCostUsd = options.maxCostUsd;
|
|
307
|
+
let latestCost = null;
|
|
308
|
+
let notifiedLimit;
|
|
297
309
|
let scanDir = "";
|
|
298
310
|
let archivedScanDir = null;
|
|
299
311
|
let targetPathsFile = null;
|
|
@@ -430,11 +442,56 @@ export class CodexSecurity {
|
|
|
430
442
|
onCost: options.onCost === undefined && options.maxCostUsd === undefined
|
|
431
443
|
? undefined
|
|
432
444
|
: (cost) => {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
445
|
+
latestCost = cost;
|
|
446
|
+
notifyObserver("onCost", options.onCost, options.onObserverError, cost, maxCostUsd);
|
|
447
|
+
if (maxCostUsd !== undefined &&
|
|
448
|
+
cost.estimatedUsd > maxCostUsd) {
|
|
449
|
+
costAbortController.abort(new ScanCostLimitExceededError(maxCostUsd, cost, scanDir));
|
|
450
|
+
return;
|
|
437
451
|
}
|
|
452
|
+
const request = options.onBudgetApproaching;
|
|
453
|
+
if (request === undefined ||
|
|
454
|
+
maxCostUsd === undefined ||
|
|
455
|
+
budgetSignal.aborted ||
|
|
456
|
+
notifiedLimit === maxCostUsd ||
|
|
457
|
+
cost.estimatedUsd < maxCostUsd * 0.8)
|
|
458
|
+
return;
|
|
459
|
+
const limit = maxCostUsd;
|
|
460
|
+
notifiedLimit = limit;
|
|
461
|
+
void Promise.resolve()
|
|
462
|
+
.then(async () => {
|
|
463
|
+
if (budgetSignal.aborted)
|
|
464
|
+
return;
|
|
465
|
+
const next = await request({
|
|
466
|
+
maxCostUsd: limit,
|
|
467
|
+
cost,
|
|
468
|
+
signal: budgetSignal,
|
|
469
|
+
});
|
|
470
|
+
if (next === undefined ||
|
|
471
|
+
budgetSignal.aborted ||
|
|
472
|
+
activeScan === null)
|
|
473
|
+
return;
|
|
474
|
+
if (!Number.isFinite(next) ||
|
|
475
|
+
next <= Math.max(limit, latestCost.estimatedUsd)) {
|
|
476
|
+
throw new CodexSecurityError("The new cost limit must exceed the current limit and estimated cost.");
|
|
477
|
+
}
|
|
478
|
+
await workbench({ ...activeScan.options, signal: budgetSignal }, [
|
|
479
|
+
"set-scan-cost-limit",
|
|
480
|
+
"--scan-id",
|
|
481
|
+
activeScan.id,
|
|
482
|
+
"--max-cost-usd",
|
|
483
|
+
String(next),
|
|
484
|
+
]);
|
|
485
|
+
if (budgetSignal.aborted)
|
|
486
|
+
return;
|
|
487
|
+
maxCostUsd = next;
|
|
488
|
+
notifyObserver("onCost", options.onCost, options.onObserverError, latestCost, maxCostUsd);
|
|
489
|
+
})
|
|
490
|
+
.catch((error) => {
|
|
491
|
+
if (!budgetSignal.aborted) {
|
|
492
|
+
notifyObserver("onWarning", options.onWarning, options.onObserverError, `Could not increase scan cost limit: ${errorMessage(error)}`);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
438
495
|
},
|
|
439
496
|
onError: reportTrackingError,
|
|
440
497
|
});
|
|
@@ -672,6 +729,9 @@ export class CodexSecurity {
|
|
|
672
729
|
},
|
|
673
730
|
onFinalize: async (usage) => {
|
|
674
731
|
if (options.validationPrompt !== undefined) {
|
|
732
|
+
tracker.recordUsage(usage);
|
|
733
|
+
await tracker.refresh().catch(reportTrackingError);
|
|
734
|
+
checkOpen();
|
|
675
735
|
await runCustomValidation({
|
|
676
736
|
repository: repo,
|
|
677
737
|
target: normalized,
|
|
@@ -706,12 +766,16 @@ export class CodexSecurity {
|
|
|
706
766
|
if (turn.status !== "completed")
|
|
707
767
|
throw new IncompleteScanError(turn.lastStreamError ??
|
|
708
768
|
"The custom validation turn did not complete.");
|
|
709
|
-
|
|
769
|
+
budgetAbortController.abort();
|
|
770
|
+
tracker.recordUsage(turn.usage, turn.threadId);
|
|
771
|
+
await tracker.refresh().catch(reportTrackingError);
|
|
772
|
+
checkOpen();
|
|
710
773
|
return turn.finalResponse;
|
|
711
774
|
},
|
|
712
775
|
});
|
|
713
776
|
customValidationComplete = true;
|
|
714
777
|
}
|
|
778
|
+
budgetAbortController.abort();
|
|
715
779
|
const snapshot = await tracker.stop(usage).catch((error) => {
|
|
716
780
|
if (options.maxCostUsd !== undefined)
|
|
717
781
|
throw error;
|
|
@@ -864,10 +928,10 @@ export class CodexSecurity {
|
|
|
864
928
|
falsePositives: falsePositiveExamples,
|
|
865
929
|
findings: result.findings.findings,
|
|
866
930
|
workbench: runWorkbench,
|
|
867
|
-
matchFindings: this.#dependencies.matchFindings ??
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
931
|
+
matchFindings: (input, comparisonOptions) => (this.#dependencies.matchFindings ?? matchScanFindingsInternal)(input, comparisonOptions, {
|
|
932
|
+
surface: this.#surface,
|
|
933
|
+
singleTurn: options.maxCostUsd !== undefined,
|
|
934
|
+
}),
|
|
871
935
|
environment,
|
|
872
936
|
model,
|
|
873
937
|
signal,
|
|
@@ -885,9 +949,14 @@ export class CodexSecurity {
|
|
|
885
949
|
// scan, and cleanup must treat all of those as a failure it is not allowed to mask.
|
|
886
950
|
scanFailure = true;
|
|
887
951
|
const snapshot = await costTracker?.stop().catch(() => null);
|
|
888
|
-
|
|
952
|
+
let failure = signal.reason instanceof ScanCostLimitExceededError
|
|
889
953
|
? signal.reason
|
|
890
954
|
: error;
|
|
955
|
+
if (failure instanceof ScanCostLimitExceededError &&
|
|
956
|
+
snapshot?.cost &&
|
|
957
|
+
snapshot.cost.estimatedUsd > failure.cost.estimatedUsd) {
|
|
958
|
+
failure = new ScanCostLimitExceededError(failure.maxCostUsd, snapshot.cost, scanDir);
|
|
959
|
+
}
|
|
891
960
|
if (failure instanceof ScanCostLimitExceededError &&
|
|
892
961
|
budgetRecovery !== null &&
|
|
893
962
|
budgetRecovery.threadId !== null &&
|
|
@@ -980,6 +1049,7 @@ export class CodexSecurity {
|
|
|
980
1049
|
throw failure;
|
|
981
1050
|
}
|
|
982
1051
|
finally {
|
|
1052
|
+
budgetAbortController.abort();
|
|
983
1053
|
deepProgressTracker?.stop();
|
|
984
1054
|
// Removing the temporary scan inputs is best effort. A throw here would replace the
|
|
985
1055
|
// outcome the try and catch blocks already produced, so these failures are reported
|
|
@@ -1050,6 +1120,9 @@ export class CodexSecurity {
|
|
|
1050
1120
|
}
|
|
1051
1121
|
const authentication = await this.#authentication();
|
|
1052
1122
|
this.#requireOpen();
|
|
1123
|
+
const ambientHome = environmentValue(this.#dependencies.environment, "CODEX_HOME") ??
|
|
1124
|
+
join(homedir(), ".codex");
|
|
1125
|
+
await initialCredentialsAvailable(this.#dependencies.environment, ambientHome, authentication.codexHome);
|
|
1053
1126
|
return await accountStatus(this.#codexCommand(), authentication.environment, this.#abortController.signal);
|
|
1054
1127
|
});
|
|
1055
1128
|
}
|
|
@@ -1148,8 +1221,11 @@ export class CodexSecurity {
|
|
|
1148
1221
|
}
|
|
1149
1222
|
#createSessionCodex(session, runtimePaths, auth = "auto") {
|
|
1150
1223
|
const { runtime, python, modelProvider, externalProvider, apiKey, sessionConfig, } = session;
|
|
1224
|
+
const commandAuth = hasCommandAuth(sessionConfig);
|
|
1151
1225
|
const environment = {
|
|
1152
|
-
...pluginExecutionEnvironment(python, withoutCodexHome(selectedScanEnvironment(
|
|
1226
|
+
...pluginExecutionEnvironment(python, withoutCodexHome(selectedScanEnvironment(commandAuth
|
|
1227
|
+
? withoutOpenAiApiKeys(runtime.environment)
|
|
1228
|
+
: runtime.environment, auth, modelProvider))),
|
|
1153
1229
|
...(externalProvider === null
|
|
1154
1230
|
? {}
|
|
1155
1231
|
: { [externalProvider.env_key]: apiKey }),
|
|
@@ -1168,17 +1244,29 @@ export class CodexSecurity {
|
|
|
1168
1244
|
// cannot safely encode their path and selector keys as dotted overrides.
|
|
1169
1245
|
delete sdkCodexConfig["projects"];
|
|
1170
1246
|
delete sdkCodexConfig["permissions"];
|
|
1247
|
+
if (commandAuth)
|
|
1248
|
+
delete sdkCodexConfig["model_providers"];
|
|
1171
1249
|
const configuredResponsesMetadata = isRecord(sdkCodexConfig["responses_api_metadata"])
|
|
1172
1250
|
? sdkCodexConfig["responses_api_metadata"]
|
|
1173
1251
|
: {};
|
|
1174
|
-
|
|
1252
|
+
let codexPathOverride = environmentValue(this.#dependencies.environment, "CODEX_CLI_PATH") ===
|
|
1175
1253
|
undefined
|
|
1176
1254
|
? undefined
|
|
1177
1255
|
: this.#codexCommand().command;
|
|
1256
|
+
let sdkEnvironment = definedEnvironment(withoutOpenAiApiKeys(environment));
|
|
1257
|
+
if (process.platform === "win32" && codexPathOverride === undefined) {
|
|
1258
|
+
codexPathOverride = environment["CODEX_CLI_PATH"];
|
|
1259
|
+
sdkEnvironment = bundledCodexSdkEnvironment(codexPathOverride, sdkEnvironment);
|
|
1260
|
+
}
|
|
1178
1261
|
const codex = this.#dependencies.createCodex({
|
|
1179
|
-
...(codexPathOverride === undefined
|
|
1262
|
+
...(codexPathOverride === undefined
|
|
1263
|
+
? {}
|
|
1264
|
+
: { codexPathOverride: executablePathForSpawn(codexPathOverride) }),
|
|
1180
1265
|
...(externalProvider !== null || apiKey === null ? {} : { apiKey }),
|
|
1181
|
-
|
|
1266
|
+
...(commandAuth
|
|
1267
|
+
? { configOverrides: modelProviderConfigOverride(sessionConfig) }
|
|
1268
|
+
: {}),
|
|
1269
|
+
env: sdkEnvironment,
|
|
1182
1270
|
config: {
|
|
1183
1271
|
...sdkCodexConfig,
|
|
1184
1272
|
responses_api_metadata: {
|
|
@@ -1196,19 +1284,22 @@ export class CodexSecurity {
|
|
|
1196
1284
|
throwIfAborted(signal);
|
|
1197
1285
|
};
|
|
1198
1286
|
try {
|
|
1199
|
-
const requestedConfig = await mergedCodexConfig(this.config);
|
|
1287
|
+
const requestedConfig = resolveCommandAuthConfig(await mergedCodexConfig(this.config), configuredCodexHome(this.#dependencies.environment));
|
|
1288
|
+
const commandAuth = hasCommandAuth(requestedConfig);
|
|
1200
1289
|
const modelProvider = scanModelProvider(requestedConfig);
|
|
1201
|
-
const externalProvider = isExternalModelProvider(modelProvider)
|
|
1290
|
+
const externalProvider = !commandAuth && isExternalModelProvider(modelProvider)
|
|
1202
1291
|
? EXTERNAL_CODEX_PROVIDERS[modelProvider]
|
|
1203
1292
|
: null;
|
|
1204
|
-
let authentication = scanAuthentication(this.#dependencies.environment, options.auth, modelProvider);
|
|
1293
|
+
let authentication = scanAuthentication(this.#dependencies.environment, options.auth, modelProvider, commandAuth);
|
|
1205
1294
|
const apiKey = authentication.method === "api_key"
|
|
1206
1295
|
? environmentApiKey(this.#dependencies.environment, modelProvider)
|
|
1207
1296
|
: null;
|
|
1208
1297
|
if (externalProvider !== null && apiKey === null) {
|
|
1209
1298
|
throw new AuthenticationRequiredError(`Set ${externalProvider.env_key} to run a scan through ${externalProvider.name}.`);
|
|
1210
1299
|
}
|
|
1211
|
-
const scanEnvironment = selectedScanEnvironment(
|
|
1300
|
+
const scanEnvironment = selectedScanEnvironment(commandAuth
|
|
1301
|
+
? withoutOpenAiApiKeys(this.#dependencies.environment)
|
|
1302
|
+
: this.#dependencies.environment, options.auth, modelProvider);
|
|
1212
1303
|
if (this.#dependencies.prepareRuntime === undefined) {
|
|
1213
1304
|
const credentialHome = await prepareCodexSecurityCredentialHome(scanEnvironment, (path) => requireOutputOutsideRepository(protectedRoot, path, "runtime"));
|
|
1214
1305
|
releaseCredentialHome = await acquireCodexSecurityCredentialHomeLock(credentialHome, signal);
|
|
@@ -1259,12 +1350,14 @@ export class CodexSecurity {
|
|
|
1259
1350
|
}
|
|
1260
1351
|
if (!runtime.credentialsAvailable &&
|
|
1261
1352
|
apiKey === null &&
|
|
1353
|
+
!commandAuth &&
|
|
1262
1354
|
authentication.method !== "aws_credentials") {
|
|
1263
1355
|
throw new AuthenticationRequiredError("No credentials were found. Run 'codex-security login', use " +
|
|
1264
1356
|
"'codex-security login --device-auth' on a remote or headless machine, or set " +
|
|
1265
1357
|
"OPENAI_API_KEY or CODEX_API_KEY for CI.");
|
|
1266
1358
|
}
|
|
1267
|
-
|
|
1359
|
+
if (!commandAuth)
|
|
1360
|
+
authentication = await runtimeScanAuthentication(this.#dependencies.environment, runtime.codexHome, options.auth, modelProvider);
|
|
1268
1361
|
if (options.safetyIdentifier !== undefined &&
|
|
1269
1362
|
authentication.method !== "api_key" &&
|
|
1270
1363
|
!(authentication.method === "stored_credentials" &&
|
|
@@ -1352,7 +1445,165 @@ export class CodexSecurity {
|
|
|
1352
1445
|
: undefined;
|
|
1353
1446
|
runtime.effectiveConfig = mergedConfig;
|
|
1354
1447
|
}
|
|
1448
|
+
async #runMock(repository, options) {
|
|
1449
|
+
const signal = AbortSignal.any([
|
|
1450
|
+
this.#abortController.signal,
|
|
1451
|
+
...(options.signal ? [options.signal] : []),
|
|
1452
|
+
]);
|
|
1453
|
+
const local = await this.#validateLocalInputs(repository, options, signal);
|
|
1454
|
+
const temporaryRoot = await realpath(tmpdir());
|
|
1455
|
+
requireOutputOutsideRepository(local.protectedRoot, temporaryRoot, "temporary");
|
|
1456
|
+
const workspace = await mkdtemp(join(temporaryRoot, "codex-security-mock-"));
|
|
1457
|
+
const workbench = this.#dependencies.runWorkbench ?? runWorkbench;
|
|
1458
|
+
let activeScan;
|
|
1459
|
+
let scanDir = "";
|
|
1460
|
+
try {
|
|
1461
|
+
const pluginRoot = await resolvePluginPath(this.config.pluginPath, workspace, signal);
|
|
1462
|
+
const plugin = await pluginMetadata(pluginRoot);
|
|
1463
|
+
if (options.expectedPluginVersion !== undefined &&
|
|
1464
|
+
options.expectedPluginVersion !== plugin.version) {
|
|
1465
|
+
throw new CodexSecurityError("The selected plugin version does not match the expected plugin version.");
|
|
1466
|
+
}
|
|
1467
|
+
const python = await (this.#dependencies.resolvePluginPython ?? resolvePluginPython)({
|
|
1468
|
+
configuredPath: this.config.pythonPath,
|
|
1469
|
+
environment: this.#dependencies.environment,
|
|
1470
|
+
protectedRoot: local.protectedRoot,
|
|
1471
|
+
signal,
|
|
1472
|
+
});
|
|
1473
|
+
if (options.knowledgeBasePaths?.length) {
|
|
1474
|
+
const knowledgeBase = await prepareKnowledgeBase(options.knowledgeBasePaths, signal);
|
|
1475
|
+
await knowledgeBase.cleanup();
|
|
1476
|
+
}
|
|
1477
|
+
const outputRoot = local.outputDir === null
|
|
1478
|
+
? await preparePersistentOutputRoot(local.stateDirectory, "scans", basename(local.repository))
|
|
1479
|
+
: undefined;
|
|
1480
|
+
let archivedScanDir;
|
|
1481
|
+
scanDir = await prepareOutputDir(local.outputDir ?? undefined, basename(local.repository), outputRoot, (path) => requireOutputOutsideRepository(local.protectedRoot, path), options.archiveExisting, (path) => {
|
|
1482
|
+
archivedScanDir = path;
|
|
1483
|
+
notifyObserver("onOutputArchived", options.onOutputArchived, options.onObserverError, path);
|
|
1484
|
+
});
|
|
1485
|
+
requireModelSafeOutputDir(scanDir);
|
|
1486
|
+
notifyObserver("onOutputDirReady", options.onOutputDirReady, options.onObserverError, scanDir);
|
|
1487
|
+
const revision = await repositoryRevision(local.repository, signal);
|
|
1488
|
+
const { model } = scanModelConfiguration({
|
|
1489
|
+
...DEFAULT_CODEX_CONFIG,
|
|
1490
|
+
...this.config.codexOverrides,
|
|
1491
|
+
});
|
|
1492
|
+
const workbenchOptions = {
|
|
1493
|
+
python,
|
|
1494
|
+
pluginRoot,
|
|
1495
|
+
environment: {
|
|
1496
|
+
...this.#dependencies.environment,
|
|
1497
|
+
CODEX_SECURITY_STATE_DIR: local.stateDirectory,
|
|
1498
|
+
},
|
|
1499
|
+
signal,
|
|
1500
|
+
failureMessage: "Could not save the mock scan",
|
|
1501
|
+
};
|
|
1502
|
+
const registration = await workbench(workbenchOptions, [
|
|
1503
|
+
"register-cli-scan",
|
|
1504
|
+
"--repository",
|
|
1505
|
+
local.repository,
|
|
1506
|
+
"--scan-dir",
|
|
1507
|
+
scanDir,
|
|
1508
|
+
"--registration-json-stdin",
|
|
1509
|
+
...(options.archiveExisting ? ["--archive-existing"] : []),
|
|
1510
|
+
...(archivedScanDir === undefined
|
|
1511
|
+
? []
|
|
1512
|
+
: ["--archived-scan-dir", archivedScanDir]),
|
|
1513
|
+
...(options.parentScanId === undefined
|
|
1514
|
+
? []
|
|
1515
|
+
: ["--parent-scan-id", options.parentScanId]),
|
|
1516
|
+
], JSON.stringify({
|
|
1517
|
+
recipe: {
|
|
1518
|
+
...scanRecipe(local.repository, local.target, local.mode, revision, plugin.version, { model }, options.failureSeverity, options.knowledgeBasePaths, options.maxCostUsd),
|
|
1519
|
+
mock: true,
|
|
1520
|
+
},
|
|
1521
|
+
userContext: options.scanPrompt,
|
|
1522
|
+
...(options.workflowId === undefined
|
|
1523
|
+
? {}
|
|
1524
|
+
: { workflowId: options.workflowId }),
|
|
1525
|
+
}));
|
|
1526
|
+
const scanId = registration["scanId"];
|
|
1527
|
+
const targetId = registration["targetId"];
|
|
1528
|
+
if (typeof scanId !== "string" ||
|
|
1529
|
+
typeof targetId !== "string" ||
|
|
1530
|
+
registration["scanDir"] !== scanDir) {
|
|
1531
|
+
throw new CodexSecurityError("The workbench returned an invalid mock scan registration.");
|
|
1532
|
+
}
|
|
1533
|
+
activeScan = { id: scanId, options: workbenchOptions };
|
|
1534
|
+
notifyObserver("onScanStarted", options.onScanStarted, options.onObserverError);
|
|
1535
|
+
await writeMockScanDraft(scanDir, scanId, local.target, registration, signal);
|
|
1536
|
+
const usage = {
|
|
1537
|
+
input_tokens: 0,
|
|
1538
|
+
cached_input_tokens: 0,
|
|
1539
|
+
output_tokens: 0,
|
|
1540
|
+
};
|
|
1541
|
+
const cost = estimateScanCost(model, usage);
|
|
1542
|
+
await workbench(workbenchOptions, [
|
|
1543
|
+
"prepare-scan-completion",
|
|
1544
|
+
"--scan-id",
|
|
1545
|
+
scanId,
|
|
1546
|
+
]);
|
|
1547
|
+
const completion = await workbench(workbenchOptions, [
|
|
1548
|
+
"complete-scan",
|
|
1549
|
+
"--scan-id",
|
|
1550
|
+
scanId,
|
|
1551
|
+
...(cost === null ? [] : ["--cost-json", JSON.stringify(cost)]),
|
|
1552
|
+
]);
|
|
1553
|
+
activeScan = undefined;
|
|
1554
|
+
const completedScan = completion["scan"];
|
|
1555
|
+
if (isRecord(completedScan) && Array.isArray(completedScan["warnings"])) {
|
|
1556
|
+
for (const warning of completedScan["warnings"]) {
|
|
1557
|
+
if (typeof warning === "string")
|
|
1558
|
+
notifyObserver("onWarning", options.onWarning, options.onObserverError, warning, Array.isArray(completion["targetWarnings"]) &&
|
|
1559
|
+
completion["targetWarnings"].includes(warning)
|
|
1560
|
+
? { kind: "target_changed" }
|
|
1561
|
+
: undefined);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
const result = await collectResult({
|
|
1565
|
+
status: "completed",
|
|
1566
|
+
model,
|
|
1567
|
+
usage,
|
|
1568
|
+
mock: true,
|
|
1569
|
+
finalResponse: "Synthetic mock scan; no security analysis was performed.",
|
|
1570
|
+
}, "", scanDir, pluginRoot, {
|
|
1571
|
+
repository: local.repository,
|
|
1572
|
+
repositoryRevision: revision,
|
|
1573
|
+
target: local.target,
|
|
1574
|
+
mode: local.mode,
|
|
1575
|
+
pluginVersion: plugin.version,
|
|
1576
|
+
}, signal, true);
|
|
1577
|
+
// Stable fixture identities are indexed by complete-scan without model matching.
|
|
1578
|
+
result.repositoryFindings = (await listRepositoryFindings((args) => workbench(workbenchOptions, args), targetId));
|
|
1579
|
+
return result;
|
|
1580
|
+
}
|
|
1581
|
+
catch (error) {
|
|
1582
|
+
if (activeScan !== undefined) {
|
|
1583
|
+
await workbench({ ...activeScan.options, signal: undefined }, [
|
|
1584
|
+
"fail-scan",
|
|
1585
|
+
"--scan-id",
|
|
1586
|
+
activeScan.id,
|
|
1587
|
+
"--message",
|
|
1588
|
+
safeErrorMessage(error).slice(0, 2400),
|
|
1589
|
+
]).catch(() => undefined);
|
|
1590
|
+
}
|
|
1591
|
+
if (this.#closed)
|
|
1592
|
+
this.#requireOpen();
|
|
1593
|
+
throwIfAborted(signal, scanDir);
|
|
1594
|
+
throw error;
|
|
1595
|
+
}
|
|
1596
|
+
finally {
|
|
1597
|
+
await cleanupSdkDirectory(workspace);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1355
1600
|
async #validateLocalInputs(repository, options, signal) {
|
|
1601
|
+
if (options.mock &&
|
|
1602
|
+
(options.mode === "deep" ||
|
|
1603
|
+
options.validationPrompt !== undefined ||
|
|
1604
|
+
options.postScanPrompt !== undefined)) {
|
|
1605
|
+
throw new CodexSecurityError("Mock scans support Standard mode without custom validation or post-scan prompts; those workflows require model calls.");
|
|
1606
|
+
}
|
|
1356
1607
|
deepScanOptions(options);
|
|
1357
1608
|
const identifier = options.safetyIdentifier;
|
|
1358
1609
|
if (identifier !== undefined &&
|
|
@@ -1423,7 +1674,9 @@ export class CodexSecurity {
|
|
|
1423
1674
|
const modelProvider = requestedConfig === undefined
|
|
1424
1675
|
? undefined
|
|
1425
1676
|
: scanModelProvider(requestedConfig);
|
|
1426
|
-
const processEnvironment = selectedScanEnvironment(
|
|
1677
|
+
const processEnvironment = selectedScanEnvironment(requestedConfig !== undefined && hasCommandAuth(requestedConfig)
|
|
1678
|
+
? withoutOpenAiApiKeys(this.#dependencies.environment)
|
|
1679
|
+
: this.#dependencies.environment, auth, modelProvider);
|
|
1427
1680
|
const codexHome = validateLocation === undefined
|
|
1428
1681
|
? await prepareCodexSecurityCredentialHome(processEnvironment)
|
|
1429
1682
|
: await realpath(codexSecurityCredentialHome(processEnvironment));
|
|
@@ -1448,7 +1701,8 @@ export class CodexSecurity {
|
|
|
1448
1701
|
const deepScanConfigPath = (await pluginSupportsIsolatedDeepScanConfig(plugin.pluginRoot))
|
|
1449
1702
|
? join(bootstrapWorkspace, "deep-scan-config.toml")
|
|
1450
1703
|
: undefined;
|
|
1451
|
-
const credentialsAvailable =
|
|
1704
|
+
const credentialsAvailable = hasCommandAuth(mergedConfig) ||
|
|
1705
|
+
isExternalModelProvider(modelProvider) ||
|
|
1452
1706
|
modelProvider === "amazon-bedrock"
|
|
1453
1707
|
? false
|
|
1454
1708
|
: await initialCredentialsAvailable(processEnvironment, ambientHome, codexHome);
|
|
@@ -1987,10 +2241,12 @@ async function collectResult(turnResult, threadId, scanDir, pluginRoot, expectat
|
|
|
1987
2241
|
sarifPath,
|
|
1988
2242
|
});
|
|
1989
2243
|
}
|
|
1990
|
-
export function scanAuthentication(environment, auth = "auto", modelProvider) {
|
|
2244
|
+
export function scanAuthentication(environment, auth = "auto", modelProvider, commandAuth = false) {
|
|
1991
2245
|
if (!SCAN_AUTH_MODES.includes(auth)) {
|
|
1992
2246
|
throw new TypeError("Scan authentication mode must be auto, chatgpt, or api-key.");
|
|
1993
2247
|
}
|
|
2248
|
+
if (commandAuth)
|
|
2249
|
+
return { method: "command", verified: false };
|
|
1994
2250
|
if (modelProvider === "amazon-bedrock") {
|
|
1995
2251
|
const sources = [
|
|
1996
2252
|
"AWS_BEARER_TOKEN_BEDROCK",
|
|
@@ -2021,6 +2277,19 @@ export function scanAuthentication(environment, auth = "auto", modelProvider) {
|
|
|
2021
2277
|
? { method: "stored_credentials", verified: false }
|
|
2022
2278
|
: { method: "api_key", source: key.source, verified: false };
|
|
2023
2279
|
}
|
|
2280
|
+
/** Shell-neutral guidance so PowerShell users are not told to run POSIX `unset`. */
|
|
2281
|
+
export function formatEnvironmentVariableRemovalGuidance(names) {
|
|
2282
|
+
if (names.length === 0) {
|
|
2283
|
+
return "remove OPENAI_API_KEY and CODEX_API_KEY from the environment";
|
|
2284
|
+
}
|
|
2285
|
+
if (names.length === 1) {
|
|
2286
|
+
return `remove ${names[0]} from the environment`;
|
|
2287
|
+
}
|
|
2288
|
+
if (names.length === 2) {
|
|
2289
|
+
return `remove ${names[0]} and ${names[1]} from the environment`;
|
|
2290
|
+
}
|
|
2291
|
+
return `remove ${names.slice(0, -1).join(", ")}, and ${names[names.length - 1]} from the environment`;
|
|
2292
|
+
}
|
|
2024
2293
|
async function runtimeScanAuthentication(environment, codexHome, auth = "auto", modelProvider) {
|
|
2025
2294
|
const authentication = scanAuthentication(environment, auth, modelProvider);
|
|
2026
2295
|
if (authentication.method !== "stored_credentials")
|
|
@@ -2051,10 +2320,8 @@ export function selectedScanEnvironment(environment, auth = "auto", modelProvide
|
|
|
2051
2320
|
if (auth !== "chatgpt" && selectedProviderKey === null && !bedrockProvider) {
|
|
2052
2321
|
return environment;
|
|
2053
2322
|
}
|
|
2054
|
-
return Object.fromEntries(Object.entries(environment).filter(([name]) => {
|
|
2323
|
+
return Object.fromEntries(Object.entries(withoutOpenAiApiKeys(environment)).filter(([name]) => {
|
|
2055
2324
|
const key = name.toUpperCase();
|
|
2056
|
-
if (key === "OPENAI_API_KEY" || key === "CODEX_API_KEY")
|
|
2057
|
-
return false;
|
|
2058
2325
|
if (key === "OPENROUTER_API_KEY" || key === "FIREWORKS_API_KEY") {
|
|
2059
2326
|
return (!bedrockProvider &&
|
|
2060
2327
|
(selectedProviderKey === null || key === selectedProviderKey));
|
|
@@ -2062,6 +2329,9 @@ export function selectedScanEnvironment(environment, auth = "auto", modelProvide
|
|
|
2062
2329
|
return true;
|
|
2063
2330
|
}));
|
|
2064
2331
|
}
|
|
2332
|
+
function withoutOpenAiApiKeys(environment) {
|
|
2333
|
+
return Object.fromEntries(Object.entries(environment).filter(([name]) => !["OPENAI_API_KEY", "CODEX_API_KEY"].includes(name.toUpperCase())));
|
|
2334
|
+
}
|
|
2065
2335
|
function notifyObserver(observerName, observer, onObserverError, ...args) {
|
|
2066
2336
|
void Promise.resolve()
|
|
2067
2337
|
.then(() => observer?.(...args))
|
|
@@ -2199,6 +2469,12 @@ function sharedCredentialCodexConfig(config, credentialHome) {
|
|
|
2199
2469
|
shared[key] = structuredClone(config[key]);
|
|
2200
2470
|
}
|
|
2201
2471
|
const modelProvider = scanModelProvider(config);
|
|
2472
|
+
if (hasCommandAuth(config)) {
|
|
2473
|
+
for (const key of ["profile", "profiles"]) {
|
|
2474
|
+
if (Object.hasOwn(config, key))
|
|
2475
|
+
shared[key] = structuredClone(config[key]);
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2202
2478
|
if (typeof modelProvider === "string" && modelProvider.length > 0) {
|
|
2203
2479
|
shared["model_provider"] = modelProvider;
|
|
2204
2480
|
const providers = config["model_providers"];
|
|
@@ -2373,6 +2649,31 @@ function throwIfAborted(signal, scanDir = "") {
|
|
|
2373
2649
|
: "Codex Security scan was interrupted during preparation.";
|
|
2374
2650
|
throw new ScanInterruptedError(message, scanDir, { cause: signal.reason });
|
|
2375
2651
|
}
|
|
2652
|
+
function bundledCodexSdkEnvironment(command, environment) {
|
|
2653
|
+
// An SDK executable override disables its bundled-tool PATH setup.
|
|
2654
|
+
const toolsDirectory = join(dirname(dirname(command)), "codex-path");
|
|
2655
|
+
try {
|
|
2656
|
+
if (!statSync(toolsDirectory).isDirectory())
|
|
2657
|
+
return environment;
|
|
2658
|
+
}
|
|
2659
|
+
catch {
|
|
2660
|
+
return environment;
|
|
2661
|
+
}
|
|
2662
|
+
const result = { ...environment };
|
|
2663
|
+
const pathKeys = Object.keys(result).filter((key) => key.toLowerCase() === "path");
|
|
2664
|
+
const pathKey = pathKeys.includes("Path")
|
|
2665
|
+
? "Path"
|
|
2666
|
+
: pathKeys.at(-1) ?? "PATH";
|
|
2667
|
+
for (const key of pathKeys) {
|
|
2668
|
+
if (key !== pathKey)
|
|
2669
|
+
delete result[key];
|
|
2670
|
+
}
|
|
2671
|
+
const entries = (result[pathKey] ?? "")
|
|
2672
|
+
.split(delimiter)
|
|
2673
|
+
.filter((entry) => entry.length > 0 && entry !== toolsDirectory);
|
|
2674
|
+
result[pathKey] = [toolsDirectory, ...entries].join(delimiter);
|
|
2675
|
+
return result;
|
|
2676
|
+
}
|
|
2376
2677
|
function definedEnvironment(environment) {
|
|
2377
2678
|
return Object.fromEntries(Object.entries(environment).filter((entry) => entry[1] !== undefined));
|
|
2378
2679
|
}
|