@openai/codex-security 0.1.8 → 0.1.10
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 +30 -14
- package/_bundled_plugin/.codex-plugin/plugin.json +1 -1
- 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/preflight/capability-profiles.toml +1 -1
- package/_bundled_plugin/references/scan-contract.md +1 -1
- package/_bundled_plugin/scripts/deep_scan_workbench.py +22 -0
- package/_bundled_plugin/scripts/generate_in_scope_files.py +102 -1
- package/_bundled_plugin/scripts/generate_rank_input.py +28 -2
- package/_bundled_plugin/scripts/normalize_candidates.py +20 -2
- package/_bundled_plugin/scripts/workbench_cli.py +4 -0
- package/_bundled_plugin/scripts/workbench_constants.py +0 -1
- package/_bundled_plugin/scripts/workbench_db.py +12 -8
- package/_bundled_plugin/scripts/workbench_native_indexes.py +100 -43
- package/_bundled_plugin/scripts/workbench_scan_history.py +8 -10
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +8 -4
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +21 -140
- package/dist/api.d.ts +43 -4
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +164 -117
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +18 -71
- package/dist/auth.js.map +1 -1
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +112 -178
- package/dist/cli.js.map +1 -1
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +7 -228
- package/dist/contract.js.map +1 -1
- package/dist/cost.d.ts +1 -0
- package/dist/cost.d.ts.map +1 -1
- package/dist/cost.js +1 -5
- package/dist/cost.js.map +1 -1
- package/dist/errors.d.ts +4 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -46
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base.js +4 -4
- package/dist/knowledge-base.js.map +1 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +33 -7
- package/dist/multiscan.js.map +1 -1
- package/dist/result.d.ts +13 -1
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +3 -0
- package/dist/result.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +17 -153
- package/dist/runtime.js.map +1 -1
- package/dist/scan-comparison.d.ts +14 -0
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +89 -0
- package/dist/scan-comparison.js.map +1 -1
- package/dist/scan-dashboard.d.ts.map +1 -1
- package/dist/scan-dashboard.js +1 -0
- package/dist/scan-dashboard.js.map +1 -1
- package/dist/scan-history-renderer.d.ts +1 -1
- package/dist/scan-history-renderer.d.ts.map +1 -1
- package/dist/scan-history-renderer.js +10 -0
- package/dist/scan-history-renderer.js.map +1 -1
- package/dist/scan-logs.d.ts +17 -0
- package/dist/scan-logs.d.ts.map +1 -0
- package/dist/scan-logs.js +90 -0
- package/dist/scan-logs.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/worker-progress.d.ts.map +1 -1
- package/dist/worker-progress.js +8 -29
- package/dist/worker-progress.js.map +1 -1
- package/package.json +3 -3
package/dist/runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execFile as execFileCallback, spawn } from "node:child_process";
|
|
2
|
-
import {
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { constants, existsSync } from "node:fs";
|
|
4
4
|
import { chmod, copyFile, link, lstat, mkdir, mkdtemp, open, opendir, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile, } from "node:fs/promises";
|
|
5
5
|
import { homedir, tmpdir } from "node:os";
|
|
@@ -12,7 +12,7 @@ import { crc32 } from "node:zlib";
|
|
|
12
12
|
import { setTimeout as delay } from "node:timers/promises";
|
|
13
13
|
import extractZip from "extract-zip";
|
|
14
14
|
import { parse } from "smol-toml";
|
|
15
|
-
import { CodexSecurityError, OutputDirectoryError, PluginBootstrapError, PluginPythonUnavailableError,
|
|
15
|
+
import { CodexSecurityError, OutputDirectoryError, PluginBootstrapError, PluginPythonUnavailableError, errorMessage, } from "./errors.js";
|
|
16
16
|
import { resolveTrustedExecutable } from "./trusted-executable.js";
|
|
17
17
|
const execFile = promisify(execFileCallback);
|
|
18
18
|
export const MARKETPLACE_NAME = "codex-security-sdk";
|
|
@@ -21,10 +21,6 @@ const MAX_ZIP_ENTRIES = 4_096;
|
|
|
21
21
|
const MAX_ZIP_CENTRAL_DIRECTORY = 16 * 1024 * 1024;
|
|
22
22
|
const MAX_ZIP_ENTRY_SIZE = 128 * 1024 * 1024;
|
|
23
23
|
const MAX_ZIP_EXPANDED_SIZE = 512 * 1024 * 1024;
|
|
24
|
-
const MAX_PLUGIN_MANIFEST_SIZE = 1024 * 1024;
|
|
25
|
-
const MAX_PLUGIN_COPY_ENTRIES = 4_096;
|
|
26
|
-
const MAX_PLUGIN_COPY_FILE_SIZE = 128 * 1024 * 1024;
|
|
27
|
-
const MAX_PLUGIN_COPY_SIZE = 512 * 1024 * 1024;
|
|
28
24
|
const MODEL_UNSAFE_PATH = /[\u0000-\u001f\u007f-\u009f\u2028\u2029]/u;
|
|
29
25
|
const CREDENTIAL_LOCK_NAME = ".codex-security-scan.lock";
|
|
30
26
|
const CREDENTIAL_LOGOUT_MARKER = ".codex-security-logged-out";
|
|
@@ -159,11 +155,11 @@ function windowsCredentialAclFailure(error) {
|
|
|
159
155
|
: error instanceof Error
|
|
160
156
|
? error.message
|
|
161
157
|
: String(error);
|
|
162
|
-
const
|
|
158
|
+
const normalized = errorMessage(detail)
|
|
163
159
|
.replace(/\s+/gu, " ")
|
|
164
160
|
.trim()
|
|
165
161
|
.slice(0, 512);
|
|
166
|
-
return
|
|
162
|
+
return normalized === "" ? "" : `. ${normalized}`;
|
|
167
163
|
}
|
|
168
164
|
const WINDOWS_SYSTEM_SID = "S-1-5-18";
|
|
169
165
|
const WINDOWS_ADMINISTRATORS_SID = "S-1-5-32-544";
|
|
@@ -955,7 +951,7 @@ export async function runWorkbench(options, args) {
|
|
|
955
951
|
name.toUpperCase() !== "OPENROUTER_API_KEY" &&
|
|
956
952
|
name.toUpperCase() !== "FIREWORKS_API_KEY")),
|
|
957
953
|
encoding: "utf8",
|
|
958
|
-
maxBuffer:
|
|
954
|
+
maxBuffer: Infinity,
|
|
959
955
|
windowsHide: true,
|
|
960
956
|
signal: options.signal,
|
|
961
957
|
}));
|
|
@@ -1472,101 +1468,6 @@ export async function createMarketplace(codexHome, pluginRoot, signal) {
|
|
|
1472
1468
|
throwIfSignalAborted(signal);
|
|
1473
1469
|
return marketplace;
|
|
1474
1470
|
}
|
|
1475
|
-
async function pluginProjectionFingerprint(root, signal) {
|
|
1476
|
-
throwIfSignalAborted(signal);
|
|
1477
|
-
const canonical = await realpath(root);
|
|
1478
|
-
const contractPath = join(canonical, ".internal", "external-promotion", "external-projection-contract.json");
|
|
1479
|
-
let paths;
|
|
1480
|
-
if (canonical === (await bundledPluginRoot()) &&
|
|
1481
|
-
(await isRegularFile(contractPath))) {
|
|
1482
|
-
let contract;
|
|
1483
|
-
try {
|
|
1484
|
-
contract = JSON.parse(await readFile(contractPath, "utf8"));
|
|
1485
|
-
}
|
|
1486
|
-
catch (error) {
|
|
1487
|
-
throw new PluginBootstrapError(`Invalid plugin projection contract: ${contractPath}`, { cause: error });
|
|
1488
|
-
}
|
|
1489
|
-
const shipped = isRecord(contract) ? contract["shippedExact"] : undefined;
|
|
1490
|
-
if (!Array.isArray(shipped) ||
|
|
1491
|
-
!shipped.every((path) => typeof path === "string")) {
|
|
1492
|
-
throw new PluginBootstrapError("Plugin projection contract must contain shippedExact paths.");
|
|
1493
|
-
}
|
|
1494
|
-
paths = [
|
|
1495
|
-
...new Set([".codex-plugin/plugin.json", ...shipped]
|
|
1496
|
-
.filter((path) => !path.startsWith("sdk/"))
|
|
1497
|
-
.map((path) => safeArchivePath(path))),
|
|
1498
|
-
];
|
|
1499
|
-
}
|
|
1500
|
-
else {
|
|
1501
|
-
paths = [];
|
|
1502
|
-
const pending = [canonical];
|
|
1503
|
-
let entries = 1;
|
|
1504
|
-
while (pending.length > 0) {
|
|
1505
|
-
throwIfSignalAborted(signal);
|
|
1506
|
-
const path = pending.pop();
|
|
1507
|
-
const metadata = await lstat(path);
|
|
1508
|
-
if (metadata.isSymbolicLink()) {
|
|
1509
|
-
throw new PluginBootstrapError(`Plugin contains an unsafe source path: ${path}`);
|
|
1510
|
-
}
|
|
1511
|
-
if (metadata.isDirectory()) {
|
|
1512
|
-
for await (const entry of pluginDirectoryEntries(path, signal)) {
|
|
1513
|
-
const child = join(path, entry);
|
|
1514
|
-
if (++entries > MAX_PLUGIN_COPY_ENTRIES) {
|
|
1515
|
-
throw new PluginBootstrapError(`Plugin source exceeds the copy entry limit: ${child}`);
|
|
1516
|
-
}
|
|
1517
|
-
pending.push(child);
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
else if (metadata.isFile()) {
|
|
1521
|
-
paths.push(relative(canonical, path).split(sep).join("/"));
|
|
1522
|
-
}
|
|
1523
|
-
else {
|
|
1524
|
-
throw new PluginBootstrapError(`Plugin contains a non-regular file: ${path}`);
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
paths.sort();
|
|
1529
|
-
const fingerprint = createHash("sha256");
|
|
1530
|
-
let totalSize = 0;
|
|
1531
|
-
for (const relativePath of paths) {
|
|
1532
|
-
throwIfSignalAborted(signal);
|
|
1533
|
-
const path = join(canonical, ...relativePath.split("/"));
|
|
1534
|
-
const metadata = await lstat(path);
|
|
1535
|
-
if (!metadata.isFile() || metadata.isSymbolicLink()) {
|
|
1536
|
-
throw new PluginBootstrapError(`Plugin projection contains an unsafe source path: ${path}`);
|
|
1537
|
-
}
|
|
1538
|
-
if (metadata.size > MAX_PLUGIN_COPY_FILE_SIZE) {
|
|
1539
|
-
throw new PluginBootstrapError(`Plugin source exceeds the per-file safety limit: ${path}`);
|
|
1540
|
-
}
|
|
1541
|
-
totalSize += metadata.size;
|
|
1542
|
-
if (totalSize > MAX_PLUGIN_COPY_SIZE) {
|
|
1543
|
-
throw new PluginBootstrapError("Plugin source exceeds the copy safety limit.");
|
|
1544
|
-
}
|
|
1545
|
-
const handle = await open(path, constants.O_RDONLY |
|
|
1546
|
-
(process.platform === "win32"
|
|
1547
|
-
? 0
|
|
1548
|
-
: constants.O_NOFOLLOW | constants.O_NONBLOCK));
|
|
1549
|
-
try {
|
|
1550
|
-
if (!samePluginFile(metadata, await handle.stat())) {
|
|
1551
|
-
throw new PluginBootstrapError(`Plugin source changed before its integrity could be verified: ${path}`);
|
|
1552
|
-
}
|
|
1553
|
-
const contents = await readExactly(handle, metadata.size, 0, signal);
|
|
1554
|
-
if (!samePluginFile(metadata, await handle.stat())) {
|
|
1555
|
-
throw new PluginBootstrapError(`Plugin source changed while its integrity was being verified: ${path}`);
|
|
1556
|
-
}
|
|
1557
|
-
fingerprint.update(relativePath);
|
|
1558
|
-
fingerprint.update("\0");
|
|
1559
|
-
fingerprint.update(String(metadata.size));
|
|
1560
|
-
fingerprint.update("\0");
|
|
1561
|
-
fingerprint.update(contents);
|
|
1562
|
-
fingerprint.update("\0");
|
|
1563
|
-
}
|
|
1564
|
-
finally {
|
|
1565
|
-
await handle.close();
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
return fingerprint.digest("hex");
|
|
1569
|
-
}
|
|
1570
1471
|
async function codexSecurityPluginRegistration(codexHome) {
|
|
1571
1472
|
let config;
|
|
1572
1473
|
try {
|
|
@@ -1656,20 +1557,14 @@ export async function bootstrapPlugin(codexHome, pluginRoot, options = {}) {
|
|
|
1656
1557
|
if (installedRoot !== null) {
|
|
1657
1558
|
const installed = await pluginMetadata(installedRoot);
|
|
1658
1559
|
if (installed.name === name && installed.version === version) {
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
installedRoot,
|
|
1668
|
-
marketplaceName: MARKETPLACE_NAME,
|
|
1669
|
-
name,
|
|
1670
|
-
version,
|
|
1671
|
-
};
|
|
1672
|
-
}
|
|
1560
|
+
return {
|
|
1561
|
+
pluginRoot: root,
|
|
1562
|
+
marketplaceRoot: existingMarketplace,
|
|
1563
|
+
installedRoot,
|
|
1564
|
+
marketplaceName: MARKETPLACE_NAME,
|
|
1565
|
+
name,
|
|
1566
|
+
version,
|
|
1567
|
+
};
|
|
1673
1568
|
}
|
|
1674
1569
|
upgradeExistingPlugin = true;
|
|
1675
1570
|
}
|
|
@@ -1716,30 +1611,11 @@ export async function pluginMetadata(root) {
|
|
|
1716
1611
|
const manifestPath = join(root, ".codex-plugin", "plugin.json");
|
|
1717
1612
|
let manifest;
|
|
1718
1613
|
try {
|
|
1719
|
-
const
|
|
1720
|
-
if (!
|
|
1721
|
-
|
|
1722
|
-
expected.size > MAX_PLUGIN_MANIFEST_SIZE) {
|
|
1723
|
-
throw new Error("plugin manifest is not a bounded regular file");
|
|
1724
|
-
}
|
|
1725
|
-
const input = await open(manifestPath, constants.O_RDONLY |
|
|
1726
|
-
(process.platform === "win32"
|
|
1727
|
-
? 0
|
|
1728
|
-
: constants.O_NOFOLLOW | constants.O_NONBLOCK));
|
|
1729
|
-
try {
|
|
1730
|
-
const opened = await input.stat();
|
|
1731
|
-
if (!samePluginFile(expected, opened)) {
|
|
1732
|
-
throw new Error("plugin manifest changed before reading");
|
|
1733
|
-
}
|
|
1734
|
-
const bytes = await readExactly(input, expected.size, 0);
|
|
1735
|
-
if (!samePluginFile(expected, await input.stat())) {
|
|
1736
|
-
throw new Error("plugin manifest changed while reading");
|
|
1737
|
-
}
|
|
1738
|
-
manifest = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
1739
|
-
}
|
|
1740
|
-
finally {
|
|
1741
|
-
await input.close();
|
|
1614
|
+
const metadata = await lstat(manifestPath);
|
|
1615
|
+
if (!metadata.isFile() || metadata.isSymbolicLink()) {
|
|
1616
|
+
throw new Error("plugin manifest is not a regular file");
|
|
1742
1617
|
}
|
|
1618
|
+
manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
1743
1619
|
}
|
|
1744
1620
|
catch (error) {
|
|
1745
1621
|
throw new PluginBootstrapError(`Invalid Codex plugin directory: ${root}`, {
|
|
@@ -1888,8 +1764,6 @@ async function copyPluginTree(source, destination, signal) {
|
|
|
1888
1764
|
{ source, destination },
|
|
1889
1765
|
];
|
|
1890
1766
|
const directories = new Map();
|
|
1891
|
-
let entries = 1;
|
|
1892
|
-
let size = 0;
|
|
1893
1767
|
await mkdir(dirname(destination), { recursive: true, mode: 0o700 });
|
|
1894
1768
|
try {
|
|
1895
1769
|
while (pending.length > 0) {
|
|
@@ -1903,9 +1777,6 @@ async function copyPluginTree(source, destination, signal) {
|
|
|
1903
1777
|
if (metadata.isDirectory()) {
|
|
1904
1778
|
for await (const entry of pluginDirectoryEntries(current.source, signal)) {
|
|
1905
1779
|
const childSource = join(current.source, entry);
|
|
1906
|
-
if (++entries > MAX_PLUGIN_COPY_ENTRIES) {
|
|
1907
|
-
throw new PluginBootstrapError(`Plugin source exceeds the copy entry limit: ${childSource}`);
|
|
1908
|
-
}
|
|
1909
1780
|
pending.push({
|
|
1910
1781
|
source: childSource,
|
|
1911
1782
|
destination: join(current.destination, entry),
|
|
@@ -1922,13 +1793,6 @@ async function copyPluginTree(source, destination, signal) {
|
|
|
1922
1793
|
if (!metadata.isFile()) {
|
|
1923
1794
|
throw new PluginBootstrapError(`Plugin contains a non-regular file: ${current.source}`);
|
|
1924
1795
|
}
|
|
1925
|
-
if (metadata.size > MAX_PLUGIN_COPY_FILE_SIZE) {
|
|
1926
|
-
throw new PluginBootstrapError(`Plugin source exceeds the per-file safety limit: ${current.source}`);
|
|
1927
|
-
}
|
|
1928
|
-
size += metadata.size;
|
|
1929
|
-
if (size > MAX_PLUGIN_COPY_SIZE) {
|
|
1930
|
-
throw new PluginBootstrapError("Plugin source exceeds the copy safety limit.");
|
|
1931
|
-
}
|
|
1932
1796
|
const input = await open(current.source, constants.O_RDONLY |
|
|
1933
1797
|
(process.platform === "win32"
|
|
1934
1798
|
? 0
|