@openai/codex-security 0.4.0 → 0.5.0
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 +45 -9
- package/_bundled_plugin/.mcp.json +1 -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/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 +2 -0
- package/_bundled_plugin/references/final-report.md +5 -1
- package/_bundled_plugin/references/investigation-time-budget.md +11 -0
- package/_bundled_plugin/references/sarif-adapter.md +1 -0
- package/_bundled_plugin/references/scan-prologue.md +2 -6
- package/_bundled_plugin/references/scan-runtime.md +15 -0
- package/_bundled_plugin/references/threat-model.md +2 -0
- package/_bundled_plugin/schemas/definitions/artifact-common.schema.json +5 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +7 -0
- package/_bundled_plugin/scripts/finalize_scan_contract.py +80 -43
- package/_bundled_plugin/scripts/finding_preview.py +5 -3
- package/_bundled_plugin/scripts/generate_rank_input.py +1 -0
- package/_bundled_plugin/scripts/launch_codex_security_mcp +39 -4
- package/_bundled_plugin/scripts/snapshot_sqlite.py +7 -0
- package/_bundled_plugin/scripts/windows_scan_local_files.py +43 -1
- package/_bundled_plugin/scripts/workbench_cli.py +0 -3
- package/_bundled_plugin/scripts/workbench_constants.py +4 -0
- package/_bundled_plugin/scripts/workbench_db.py +56 -33
- package/_bundled_plugin/scripts/workbench_progress.py +0 -50
- package/_bundled_plugin/scripts/workbench_scan_history.py +3 -2
- package/_bundled_plugin/scripts/workbench_scan_start.py +12 -4
- package/_bundled_plugin/scripts/workbench_scan_usage.py +190 -30
- package/_bundled_plugin/scripts/workbench_schema.py +1 -1
- package/_bundled_plugin/scripts/workbench_source_excerpt.py +74 -51
- package/_bundled_plugin/scripts/workbench_source_scopes.py +388 -0
- package/_bundled_plugin/scripts/workbench_target.py +7 -5
- package/_bundled_plugin/scripts/workbench_validation.py +37 -1
- package/_bundled_plugin/shared/workbench-history-repairs.json +19 -0
- package/_bundled_plugin/shared/workbench-migrations.json +5 -0
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +1 -1
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +4 -2
- package/_bundled_plugin/skills/security-scan/SKILL.md +3 -1
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +2 -2
- package/dist/api.d.ts +3 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +54 -36
- package/dist/api.js.map +1 -1
- package/dist/artifact-export.d.ts +2 -1
- package/dist/artifact-export.d.ts.map +1 -1
- package/dist/artifact-export.js +38 -23
- package/dist/artifact-export.js.map +1 -1
- package/dist/classify-severity-records.d.ts +76 -0
- package/dist/classify-severity-records.d.ts.map +1 -0
- package/dist/classify-severity-records.js +141 -0
- package/dist/classify-severity-records.js.map +1 -0
- package/dist/classify-severity.d.ts +1 -23
- package/dist/classify-severity.d.ts.map +1 -1
- package/dist/classify-severity.js +3 -24
- package/dist/classify-severity.js.map +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +2 -0
- package/dist/cli-help.js.map +1 -1
- package/dist/cli.d.ts +4 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +136 -147
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +1 -1
- package/dist/cloud-publish.js.map +1 -1
- package/dist/codex-sdk-environment.js +1 -1
- package/dist/codex-sdk-environment.js.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +10 -4
- package/dist/config.js.map +1 -1
- package/dist/contract.d.ts +5 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +65 -17
- package/dist/contract.js.map +1 -1
- package/dist/cost-model.d.ts.map +1 -1
- package/dist/cost-model.js +7 -2
- package/dist/cost-model.js.map +1 -1
- package/dist/custom-validation-prompt.js +3 -3
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts +1 -1
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -1
- package/dist/deduplication/deduplication-prompts.js +2 -2
- package/dist/deduplication/deduplication-prompts.js.map +1 -1
- package/dist/deduplication/records.js +1 -1
- package/dist/deduplication/records.js.map +1 -1
- package/dist/deduplication/scan.d.ts.map +1 -1
- package/dist/deduplication/scan.js +10 -9
- package/dist/deduplication/scan.js.map +1 -1
- package/dist/deep-config.d.ts +4 -1
- package/dist/deep-config.d.ts.map +1 -1
- package/dist/deep-config.js +21 -1
- package/dist/deep-config.js.map +1 -1
- package/dist/findings-import.d.ts +1 -1
- package/dist/findings-import.d.ts.map +1 -1
- package/dist/findings-import.js +3 -3
- package/dist/findings-import.js.map +1 -1
- package/dist/git-remote.d.ts +10 -0
- package/dist/git-remote.d.ts.map +1 -0
- package/dist/git-remote.js +24 -0
- package/dist/git-remote.js.map +1 -0
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +5 -7
- package/dist/github.js.map +1 -1
- package/dist/host-protocol.js +1 -1
- package/dist/host-protocol.js.map +1 -1
- package/dist/host-records-protocol.d.ts +15 -0
- package/dist/host-records-protocol.d.ts.map +1 -0
- package/dist/host-records-protocol.js +15 -0
- package/dist/host-records-protocol.js.map +1 -0
- package/dist/hosted-scan.d.ts +1 -6
- package/dist/hosted-scan.d.ts.map +1 -1
- package/dist/hosted-scan.js +2 -2
- package/dist/hosted-scan.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.d.ts.map +1 -1
- package/dist/knowledge-base.js +87 -7
- package/dist/knowledge-base.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +62 -28
- package/dist/multiscan.js.map +1 -1
- package/dist/patch-publication.d.ts +26 -0
- package/dist/patch-publication.d.ts.map +1 -0
- package/dist/patch-publication.js +105 -0
- package/dist/patch-publication.js.map +1 -0
- package/dist/patch-tui.d.ts.map +1 -1
- package/dist/patch-tui.js +4 -1
- package/dist/patch-tui.js.map +1 -1
- package/dist/project-config-schema.d.ts +2 -0
- package/dist/project-config-schema.d.ts.map +1 -1
- package/dist/project-config-schema.js +1 -0
- package/dist/project-config-schema.js.map +1 -1
- package/dist/project-config.d.ts +1 -0
- package/dist/project-config.d.ts.map +1 -1
- package/dist/project-config.js +16 -6
- package/dist/project-config.js.map +1 -1
- package/dist/publication.d.ts.map +1 -1
- package/dist/publication.js +135 -19
- package/dist/publication.js.map +1 -1
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js +39 -25
- package/dist/publish.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +83 -22
- package/dist/runtime.js.map +1 -1
- package/dist/scan-settings.d.ts +1 -0
- package/dist/scan-settings.d.ts.map +1 -1
- package/dist/scan-settings.js +7 -1
- package/dist/scan-settings.js.map +1 -1
- package/dist/scan-time-budget.d.ts +9 -0
- package/dist/scan-time-budget.d.ts.map +1 -0
- package/dist/scan-time-budget.js +16 -0
- package/dist/scan-time-budget.js.map +1 -0
- package/dist/severity-review.d.ts +29 -0
- package/dist/severity-review.d.ts.map +1 -0
- package/dist/severity-review.js +47 -0
- package/dist/severity-review.js.map +1 -0
- package/dist/validation-records.d.ts +38 -0
- package/dist/validation-records.d.ts.map +1 -0
- package/dist/validation-records.js +76 -0
- package/dist/validation-records.js.map +1 -0
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +4 -2
- package/dist/version.js.map +1 -1
- package/dist/worker-progress.d.ts +2 -6
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +1 -43
- package/dist/worker-progress.js.map +1 -1
- package/docs/classify-severity-records.md +89 -0
- package/docs/cli.md +269 -33
- package/docs/validate-records.md +69 -0
- package/package.json +12 -10
- package/schemas/project-config.schema.json +7 -1
- package/_bundled_plugin/preflight/capability-profiles.toml +0 -76
- package/_bundled_plugin/references/config-preflight.md +0 -93
- package/_bundled_plugin/references/desktop-config-preflight.md +0 -11
- package/_bundled_plugin/scripts/config_preflight.py +0 -911
package/dist/runtime.js
CHANGED
|
@@ -9,7 +9,7 @@ import { chmodSync, constants, createWriteStream, } from "node:fs";
|
|
|
9
9
|
import { chmod, cp, copyFile, link, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, rmdir, stat, utimes, writeFile, } from "node:fs/promises";
|
|
10
10
|
import { homedir, tmpdir } from "node:os";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
12
|
-
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep, } from "node:path";
|
|
12
|
+
import { basename, dirname, extname, isAbsolute, join, relative, resolve, sep, win32, } from "node:path";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
14
|
import { promisify } from "node:util";
|
|
15
15
|
import { pipeline } from "node:stream/promises";
|
|
@@ -55,6 +55,7 @@ const PLUGIN_HELPER_SECRET_ENVIRONMENT_VARIABLES = new Set([
|
|
|
55
55
|
"CODEX_API_KEY",
|
|
56
56
|
"OPENROUTER_API_KEY",
|
|
57
57
|
"FIREWORKS_API_KEY",
|
|
58
|
+
"CHEAPER_INFERENCE_API_KEY",
|
|
58
59
|
]);
|
|
59
60
|
const PREPARE_SCAN_ARTIFACT_RESTORER_PROGRAM = `
|
|
60
61
|
from pathlib import Path
|
|
@@ -217,10 +218,7 @@ function windowsCredentialAclFailure(error) {
|
|
|
217
218
|
const detail = typeof stderr === "string" && stderr.trim() !== ""
|
|
218
219
|
? stderr
|
|
219
220
|
: errorMessage(error);
|
|
220
|
-
const normalized = errorMessage(detail)
|
|
221
|
-
.replace(/\s+/gu, " ")
|
|
222
|
-
.trim()
|
|
223
|
-
.slice(0, 512);
|
|
221
|
+
const normalized = errorMessage(detail).replace(/\s+/gu, " ").trim();
|
|
224
222
|
return normalized === "" ? "" : `. ${normalized}`;
|
|
225
223
|
}
|
|
226
224
|
const WINDOWS_SYSTEM_SID = "S-1-5-18";
|
|
@@ -525,9 +523,9 @@ export async function streamWindowsCredentialAclDescriptors(command, args, inspe
|
|
|
525
523
|
}
|
|
526
524
|
}
|
|
527
525
|
export async function inspectWindowsCredentialAclSnapshot(path, currentUserSid, options) {
|
|
528
|
-
|
|
526
|
+
const ancestors = [];
|
|
529
527
|
for (let ancestor = dirname(path);; ancestor = dirname(ancestor)) {
|
|
530
|
-
ancestors
|
|
528
|
+
ancestors.push(ancestor);
|
|
531
529
|
if (ancestor === dirname(ancestor))
|
|
532
530
|
break;
|
|
533
531
|
}
|
|
@@ -552,17 +550,26 @@ export async function inspectWindowsCredentialAclSnapshot(path, currentUserSid,
|
|
|
552
550
|
const index = inspected;
|
|
553
551
|
inspected += 1;
|
|
554
552
|
await options.resolveDescriptorAliases?.(descriptor);
|
|
555
|
-
if (index < ancestors) {
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
553
|
+
if (index < ancestors.length) {
|
|
554
|
+
const ancestorPath = ancestors[index];
|
|
555
|
+
try {
|
|
556
|
+
const ancestor = inspectWindowsCredentialAcl(descriptor, currentUserSid, {
|
|
557
|
+
resolvedAliases: options.resolvedAliases,
|
|
558
|
+
scope: "ancestor",
|
|
559
|
+
});
|
|
560
|
+
if (ancestor.untrustedPrincipals.length !== 0) {
|
|
561
|
+
throw new Error("Windows credential-home ancestor allows another identity to replace the directory");
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
catch (error) {
|
|
565
|
+
const guidance = ancestorPath === dirname(ancestorPath)
|
|
566
|
+
? "This volume root is unsupported. Choose a location on a volume with trusted ancestry; another directory on the same volume will not resolve this."
|
|
567
|
+
: "Choose a location outside this ancestor with trusted ownership and permissions.";
|
|
568
|
+
throw new Error(`Windows private-directory ancestor could not be trusted: ${ancestorPath}. ${errorMessage(error)}. ${guidance}`, { cause: error });
|
|
562
569
|
}
|
|
563
570
|
return;
|
|
564
571
|
}
|
|
565
|
-
if (index === ancestors) {
|
|
572
|
+
if (index === ancestors.length) {
|
|
566
573
|
try {
|
|
567
574
|
home = inspectWindowsCredentialAcl(descriptor, currentUserSid, {
|
|
568
575
|
resolvedAliases: options.resolvedAliases,
|
|
@@ -591,7 +598,7 @@ export async function inspectWindowsCredentialAclSnapshot(path, currentUserSid,
|
|
|
591
598
|
continue;
|
|
592
599
|
throw error;
|
|
593
600
|
}
|
|
594
|
-
if (inspected <= ancestors) {
|
|
601
|
+
if (inspected <= ancestors.length) {
|
|
595
602
|
throw new Error("Windows credential-home ancestry could not be verified");
|
|
596
603
|
}
|
|
597
604
|
if (!completed) {
|
|
@@ -1389,7 +1396,10 @@ export async function planOutputArchive(outputDirectory) {
|
|
|
1389
1396
|
const entries = await readdir(outputDirectory).catch(nullIfMissingFileError);
|
|
1390
1397
|
if (entries === null || entries.length === 0)
|
|
1391
1398
|
return null;
|
|
1392
|
-
return `${outputDirectory}
|
|
1399
|
+
return `${outputDirectory}${outputArchiveSuffix()}`;
|
|
1400
|
+
}
|
|
1401
|
+
function outputArchiveSuffix() {
|
|
1402
|
+
return `.previous-${new Date()
|
|
1393
1403
|
.toISOString()
|
|
1394
1404
|
.replaceAll(/[-:]/g, "")
|
|
1395
1405
|
.replace(/\.\d{3}Z$/, "")}-${randomUUID().slice(0, 8)}`;
|
|
@@ -1442,10 +1452,22 @@ async function prepareOutputDirectory(outputDirectory, repositoryName, temporary
|
|
|
1442
1452
|
const path = await validateOutputDir(outputDirectory, existingOutput !== "reject");
|
|
1443
1453
|
validateLocation?.(path ?? (await realpath(temporaryRoot)));
|
|
1444
1454
|
if (path === null) {
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
|
|
1455
|
+
const prefix = `codex-security-${safePrefix(repositoryName)}`;
|
|
1456
|
+
let created;
|
|
1457
|
+
if (process.platform === "win32") {
|
|
1458
|
+
const suffix = `-${randomUUID()}`;
|
|
1459
|
+
// Reserve room within NTFS's 255-unit component limit for later archival.
|
|
1460
|
+
// The SDK suffix is longer than the workbench's .previous-<tempname> suffix.
|
|
1461
|
+
const prefixLength = 255 - suffix.length - outputArchiveSuffix().length;
|
|
1462
|
+
created = join(temporaryRoot, `${prefix.slice(0, prefixLength)}${suffix}`);
|
|
1463
|
+
await createWindowsOutputDirectory(created, false);
|
|
1464
|
+
}
|
|
1465
|
+
else {
|
|
1466
|
+
created = await mkdtemp(join(temporaryRoot, `${prefix}-`));
|
|
1467
|
+
}
|
|
1448
1468
|
try {
|
|
1469
|
+
if ((process.umask() & 0o700) !== 0)
|
|
1470
|
+
await chmod(created, 0o700);
|
|
1449
1471
|
return await validatePreparedOutputDir(created, validateLocation);
|
|
1450
1472
|
}
|
|
1451
1473
|
catch (error) {
|
|
@@ -1465,7 +1487,10 @@ async function prepareOutputDirectory(outputDirectory, repositoryName, temporary
|
|
|
1465
1487
|
}
|
|
1466
1488
|
}
|
|
1467
1489
|
if (existing === null) {
|
|
1468
|
-
createdRoot =
|
|
1490
|
+
createdRoot =
|
|
1491
|
+
process.platform === "win32"
|
|
1492
|
+
? await createWindowsOutputDirectory(path, true)
|
|
1493
|
+
: await mkdir(path, { recursive: true, mode: 0o700 });
|
|
1469
1494
|
if ((process.umask() & 0o700) !== 0)
|
|
1470
1495
|
await chmod(path, 0o700);
|
|
1471
1496
|
}
|
|
@@ -1482,6 +1507,26 @@ async function prepareOutputDirectory(outputDirectory, repositoryName, temporary
|
|
|
1482
1507
|
});
|
|
1483
1508
|
}
|
|
1484
1509
|
}
|
|
1510
|
+
async function createWindowsOutputDirectory(path, recursive) {
|
|
1511
|
+
const native = createRequire(import.meta.url)(join(await bundledPluginRoot(), "mcp", "native", `win32-${process.arch}`, "windows.node"));
|
|
1512
|
+
const create = async (target) => {
|
|
1513
|
+
const createOne = () => native.createPrivateWindowsDirectory(Buffer.from(win32.toNamespacedPath(target), "utf16le"));
|
|
1514
|
+
let error = createOne();
|
|
1515
|
+
let firstCreated;
|
|
1516
|
+
if (recursive &&
|
|
1517
|
+
(error === 2 || error === 3) &&
|
|
1518
|
+
dirname(target) !== target) {
|
|
1519
|
+
firstCreated = await create(dirname(target));
|
|
1520
|
+
error = createOne();
|
|
1521
|
+
}
|
|
1522
|
+
if (error === 0)
|
|
1523
|
+
return firstCreated ?? target;
|
|
1524
|
+
if (recursive && error === 183 && (await stat(target)).isDirectory())
|
|
1525
|
+
return firstCreated;
|
|
1526
|
+
throw new OutputDirectoryError(`Unable to create private Windows output directory (Windows error ${error}): ${target}`);
|
|
1527
|
+
};
|
|
1528
|
+
return create(path);
|
|
1529
|
+
}
|
|
1485
1530
|
export async function validatePreparedOutputDir(path, validateLocation, allowNonempty = false) {
|
|
1486
1531
|
const metadata = await lstat(path);
|
|
1487
1532
|
if (!metadata.isDirectory()) {
|
|
@@ -2239,12 +2284,13 @@ export async function cleanupSdkDirectory(path) {
|
|
|
2239
2284
|
export async function runCodexCommand(command, args, environment, input, signal, archiveHandshake = false, stdinPrefix) {
|
|
2240
2285
|
const cancellation = archiveHandshake ? new AbortController() : undefined;
|
|
2241
2286
|
const abort = () => cancellation?.abort(signal?.reason);
|
|
2287
|
+
const commandSignal = cancellation?.signal ?? signal;
|
|
2242
2288
|
let awaitingArchive = archiveHandshake;
|
|
2243
2289
|
const child = spawn(executablePathForSpawn(command.command), [...(command.args ?? []), ...args], {
|
|
2244
2290
|
env: environment,
|
|
2245
2291
|
stdio: ["pipe", "pipe", "pipe"],
|
|
2246
2292
|
windowsHide: true,
|
|
2247
|
-
signal:
|
|
2293
|
+
signal: commandSignal,
|
|
2248
2294
|
});
|
|
2249
2295
|
let stdout = "";
|
|
2250
2296
|
let stderr = "";
|
|
@@ -2280,6 +2326,19 @@ export async function runCodexCommand(command, args, environment, input, signal,
|
|
|
2280
2326
|
? resolve({ success: exitCode === 0, exitCode, stdout, stderr })
|
|
2281
2327
|
: reject(processError));
|
|
2282
2328
|
});
|
|
2329
|
+
const releaseCanceledPipes = () => {
|
|
2330
|
+
if (!commandSignal?.aborted)
|
|
2331
|
+
return;
|
|
2332
|
+
if (child.exitCode === null && child.signalCode === null)
|
|
2333
|
+
return;
|
|
2334
|
+
child.stdin.destroy();
|
|
2335
|
+
child.stdout.destroy();
|
|
2336
|
+
child.stderr.destroy();
|
|
2337
|
+
};
|
|
2338
|
+
commandSignal?.addEventListener("abort", releaseCanceledPipes, {
|
|
2339
|
+
once: true,
|
|
2340
|
+
});
|
|
2341
|
+
child.once("exit", releaseCanceledPipes);
|
|
2283
2342
|
if (archiveHandshake) {
|
|
2284
2343
|
signal?.addEventListener("abort", abort, { once: true });
|
|
2285
2344
|
if (signal?.aborted)
|
|
@@ -2297,6 +2356,8 @@ export async function runCodexCommand(command, args, environment, input, signal,
|
|
|
2297
2356
|
finally {
|
|
2298
2357
|
if (archiveHandshake)
|
|
2299
2358
|
signal?.removeEventListener("abort", abort);
|
|
2359
|
+
commandSignal?.removeEventListener("abort", releaseCanceledPipes);
|
|
2360
|
+
child.removeListener("exit", releaseCanceledPipes);
|
|
2300
2361
|
}
|
|
2301
2362
|
}
|
|
2302
2363
|
export async function probeCodexSandbox(command, environment, signal) {
|