@openai/codex-security 0.1.7 → 0.1.9
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 +23 -11
- package/_bundled_plugin/.codex-plugin/plugin.json +1 -1
- package/_bundled_plugin/mcp/server.mjs +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 +2 -2
- package/_bundled_plugin/references/config-preflight.md +6 -6
- package/_bundled_plugin/references/desktop-config-preflight.md +11 -0
- package/_bundled_plugin/references/final-report.md +10 -14
- package/_bundled_plugin/references/scan-artifacts.md +17 -17
- package/_bundled_plugin/references/shared-hard-rules.md +2 -2
- package/_bundled_plugin/scripts/deep_scan_workbench.py +422 -48
- package/_bundled_plugin/scripts/generate_rank_input.py +118 -1
- package/_bundled_plugin/scripts/workbench_cli.py +1 -50
- package/_bundled_plugin/scripts/workbench_constants.py +0 -3
- package/_bundled_plugin/scripts/workbench_db.py +7 -297
- package/_bundled_plugin/scripts/workbench_progress.py +11 -0
- package/_bundled_plugin/scripts/workbench_scan_history.py +8 -64
- package/_bundled_plugin/scripts/workbench_target.py +2 -6
- package/_bundled_plugin/scripts/workbench_validation.py +0 -211
- package/_bundled_plugin/skills/attack-path-analysis/SKILL.md +10 -10
- package/_bundled_plugin/skills/deep-security-scan/SKILL.md +25 -43
- package/_bundled_plugin/skills/finding-discovery/SKILL.md +2 -4
- package/_bundled_plugin/skills/security-diff-scan/SKILL.md +11 -23
- package/_bundled_plugin/skills/security-scan/SKILL.md +89 -26
- package/_bundled_plugin/skills/security-scan/references/desktop-scan.md +25 -0
- package/_bundled_plugin/skills/security-scan/references/repository-wide-scan.md +11 -38
- package/_bundled_plugin/skills/security-scan/references/scan-artifacts-and-ledger.md +5 -6
- package/_bundled_plugin/skills/triage-finding/SKILL.md +6 -14
- package/_bundled_plugin/skills/validation/SKILL.md +9 -9
- package/dist/api.d.ts +3 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +113 -82
- 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 +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +57 -136
- 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.map +1 -1
- package/dist/cost.js +0 -4
- package/dist/cost.js.map +1 -1
- package/dist/knowledge-base.js +4 -4
- package/dist/knowledge-base.js.map +1 -1
- package/dist/multiscan.d.ts +5 -1
- package/dist/multiscan.d.ts.map +1 -1
- package/dist/multiscan.js +232 -26
- package/dist/multiscan.js.map +1 -1
- package/dist/runtime.d.ts +13 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +136 -242
- package/dist/runtime.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/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/_bundled_plugin/mcp/mcp-app.html.br +0 -0
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,8 @@ import { accessSync, constants, existsSync, lstatSync, realpathSync, writeSync,
|
|
|
4
4
|
import { mkdir, readFile, realpath, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { basename, dirname, isAbsolute, join, parse, relative, resolve, sep, win32, } from "node:path";
|
|
6
6
|
import { cwd } from "node:process";
|
|
7
|
-
import {
|
|
7
|
+
import { createInterface } from "node:readline";
|
|
8
|
+
import { Readable, Writable as NodeWritable } from "node:stream";
|
|
8
9
|
import { pipeline } from "node:stream/promises";
|
|
9
10
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
11
|
import { Cli, z } from "incur";
|
|
@@ -23,14 +24,6 @@ import { ScanDashboard } from "./scan-dashboard.js";
|
|
|
23
24
|
import { DiffTarget } from "./targets.js";
|
|
24
25
|
import { BUNDLED_PLUGIN_VERSION, checkForUpdate, CODEX_EXECUTABLE_VERSION, CODEX_SDK_VERSION, formatUpdateNotice, updateNoticeEnabled, VERSION, } from "./version.js";
|
|
25
26
|
const PROGRESS_REFRESH_MILLISECONDS = 1_000;
|
|
26
|
-
const MAX_CODEX_OVERRIDE_KEY_LENGTH = 1_024;
|
|
27
|
-
const MAX_CODEX_OVERRIDE_VALUE_LENGTH = 64 * 1_024;
|
|
28
|
-
const MAX_CODEX_OVERRIDE_DEPTH = 64;
|
|
29
|
-
const MAX_SKILL_INPUT_BYTES = 1_024 * 1_024;
|
|
30
|
-
const MAX_SKILL_INPUT_COUNT = 64;
|
|
31
|
-
const MAX_SKILL_EVENT_BYTES = 1_024 * 1_024;
|
|
32
|
-
const MAX_SKILL_RESPONSE_BYTES = 256 * 1_024;
|
|
33
|
-
const SKILL_OUTPUT_LIMIT_MESSAGE = "Codex skill output exceeded the 1 MiB event or 256 KiB response safety limit.";
|
|
34
27
|
const WINDOWS_NETWORK_PATH = /^[\\/]{2}/u;
|
|
35
28
|
const WINDOWS_LOCAL_DEVICE_ROOT = /^[\\/]{2}[?.][\\/](?:[A-Za-z]:|Volume\{[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}\}|GLOBALROOT[\\/]Device[\\/]HarddiskVolume[0-9]+)(?=[\\/]|$)/iu;
|
|
36
29
|
const SCAN_HISTORY_OUTPUT_OPTION = /^--(?:format|filter-output|full-output|token-count|token-limit|token-offset)(?:=|$)/u;
|
|
@@ -67,6 +60,8 @@ const VALUE_OPTIONS = new Set([
|
|
|
67
60
|
"--auth",
|
|
68
61
|
"--path",
|
|
69
62
|
"--knowledge-base",
|
|
63
|
+
"--scan-prompt-file",
|
|
64
|
+
"--post-scan-prompt-file",
|
|
70
65
|
"--diff",
|
|
71
66
|
"--head",
|
|
72
67
|
"--base",
|
|
@@ -136,6 +131,20 @@ const DEEP_SCAN_OPTION_SCHEMAS = {
|
|
|
136
131
|
.optional()
|
|
137
132
|
.describe("Maximum deep-scan discovery runs."),
|
|
138
133
|
};
|
|
134
|
+
async function readPromptFiles(directory, scanPromptFile, postScanPromptFile) {
|
|
135
|
+
const [scanPrompt, postScanPrompt] = await Promise.all([
|
|
136
|
+
scanPromptFile === undefined
|
|
137
|
+
? undefined
|
|
138
|
+
: readFile(resolve(directory, scanPromptFile), "utf8"),
|
|
139
|
+
postScanPromptFile === undefined
|
|
140
|
+
? undefined
|
|
141
|
+
: readFile(resolve(directory, postScanPromptFile), "utf8"),
|
|
142
|
+
]);
|
|
143
|
+
return {
|
|
144
|
+
...(scanPrompt?.trim() ? { scanPrompt } : {}),
|
|
145
|
+
...(postScanPrompt?.trim() ? { postScanPrompt } : {}),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
139
148
|
const DEFAULT_DEPENDENCIES = {
|
|
140
149
|
createSecurity: (config) => new CodexSecurity(config),
|
|
141
150
|
environment: process.env,
|
|
@@ -258,7 +267,6 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
|
|
|
258
267
|
windowsHide: true,
|
|
259
268
|
});
|
|
260
269
|
let requestedSignal = null;
|
|
261
|
-
let skillOutputLimitExceeded = false;
|
|
262
270
|
let forcedTermination;
|
|
263
271
|
let forceStatusCompletion = null;
|
|
264
272
|
let forceCaptureCompletion = null;
|
|
@@ -295,10 +303,7 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
|
|
|
295
303
|
const captured = output === undefined || invocation.stdout === null
|
|
296
304
|
? Promise.resolve(undefined)
|
|
297
305
|
: Promise.race([
|
|
298
|
-
readSkillCommandOutput(invocation.stdout,
|
|
299
|
-
skillOutputLimitExceeded = true;
|
|
300
|
-
requestTermination("SIGTERM");
|
|
301
|
-
}),
|
|
306
|
+
readSkillCommandOutput(invocation.stdout),
|
|
302
307
|
new Promise((resolve) => {
|
|
303
308
|
forceCaptureCompletion = () => resolve(undefined);
|
|
304
309
|
}),
|
|
@@ -327,9 +332,6 @@ export async function runCodexSkillCommand(args, output, command = resolveCodexC
|
|
|
327
332
|
invocation.once(output === undefined ? "exit" : "close", complete);
|
|
328
333
|
});
|
|
329
334
|
const [status, events] = await Promise.all([invocationStatus, captured]);
|
|
330
|
-
if (skillOutputLimitExceeded) {
|
|
331
|
-
throw new CodexSecurityError(SKILL_OUTPUT_LIMIT_MESSAGE);
|
|
332
|
-
}
|
|
333
335
|
if (output === undefined || status === 130 || status === 143)
|
|
334
336
|
return status;
|
|
335
337
|
if (status !== 0) {
|
|
@@ -727,6 +729,12 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
727
729
|
.array(optionValue("--knowledge-base"))
|
|
728
730
|
.default([])
|
|
729
731
|
.describe("Add security-context files or directories; repeat for multiple paths."),
|
|
732
|
+
scanPromptFile: optionValue("--scan-prompt-file")
|
|
733
|
+
.optional()
|
|
734
|
+
.describe("Append scan instructions from FILE."),
|
|
735
|
+
postScanPromptFile: optionValue("--post-scan-prompt-file")
|
|
736
|
+
.optional()
|
|
737
|
+
.describe("Run FILE after each scan, including failures."),
|
|
730
738
|
diff: optionValue("--diff")
|
|
731
739
|
.optional()
|
|
732
740
|
.describe("Scan committed Git changes from BASE to --head."),
|
|
@@ -832,6 +840,8 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
832
840
|
repository: args.repository,
|
|
833
841
|
paths: options.path,
|
|
834
842
|
knowledgeBasePaths: options.knowledgeBase,
|
|
843
|
+
scanPromptFile: options.scanPromptFile,
|
|
844
|
+
postScanPromptFile: options.postScanPromptFile,
|
|
835
845
|
diff: options.diff,
|
|
836
846
|
workingTree: options.workingTree,
|
|
837
847
|
head: options.head,
|
|
@@ -968,6 +978,12 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
968
978
|
.enum(["standard", "deep"])
|
|
969
979
|
.default("standard")
|
|
970
980
|
.describe("Default scan mode for repositories without a CSV mode."),
|
|
981
|
+
scanPromptFile: optionValue("--scan-prompt-file")
|
|
982
|
+
.optional()
|
|
983
|
+
.describe("Append instructions from FILE to every scan."),
|
|
984
|
+
postScanPromptFile: optionValue("--post-scan-prompt-file")
|
|
985
|
+
.optional()
|
|
986
|
+
.describe("Run FILE after each scan, including failures."),
|
|
971
987
|
model: optionValue("--model")
|
|
972
988
|
.optional()
|
|
973
989
|
.describe(`OpenAI model for each repository (default: ${DEFAULT_SCAN_MODEL_CONFIGURATION.model}).`),
|
|
@@ -1014,33 +1030,13 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
1014
1030
|
dependencies.addSignalListener("SIGTERM", onTerminate);
|
|
1015
1031
|
try {
|
|
1016
1032
|
const currentDirectory = dependencies.currentDirectory();
|
|
1033
|
+
const prompts = await readPromptFiles(currentDirectory, options.scanPromptFile, options.postScanPromptFile);
|
|
1017
1034
|
let inputPath;
|
|
1018
1035
|
let outputDir;
|
|
1019
1036
|
let githubHost;
|
|
1020
1037
|
if (args.input === undefined) {
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
const argument = argv[optionIndex];
|
|
1024
|
-
if (argument === "--model" ||
|
|
1025
|
-
argument === "--effort" ||
|
|
1026
|
-
argument === "--provider" ||
|
|
1027
|
-
argument === "--codex" ||
|
|
1028
|
-
argument === "--knowledge-base") {
|
|
1029
|
-
optionIndex += 2;
|
|
1030
|
-
}
|
|
1031
|
-
else if (argument.startsWith("--model=") ||
|
|
1032
|
-
argument.startsWith("--effort=") ||
|
|
1033
|
-
argument.startsWith("--provider=") ||
|
|
1034
|
-
argument.startsWith("--codex=") ||
|
|
1035
|
-
argument.startsWith("--knowledge-base=")) {
|
|
1036
|
-
optionIndex += 1;
|
|
1037
|
-
}
|
|
1038
|
-
else {
|
|
1039
|
-
break;
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
if (argv[0] !== "bulk-scan" || optionIndex !== argv.length) {
|
|
1043
|
-
throw new Error("Run 'codex-security bulk-scan [--provider PROVIDER] [--model MODEL] [--effort EFFORT] [--codex KEY=VALUE] [--knowledge-base PATH]' to discover repositories, or provide a CSV and --output-dir.");
|
|
1038
|
+
if (options.outputDir !== undefined) {
|
|
1039
|
+
throw new Error("--output-dir can only be used with a repository CSV; omit it to choose an output directory interactively.");
|
|
1044
1040
|
}
|
|
1045
1041
|
const wizard = await runBulkScanWizard(dependencies.bulkScan ??
|
|
1046
1042
|
createBulkScanDiscoveryDependencies({
|
|
@@ -1069,6 +1065,7 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
1069
1065
|
mode: options.mode,
|
|
1070
1066
|
maxAttempts: options.maxAttempts,
|
|
1071
1067
|
knowledgeBasePaths: options.knowledgeBase,
|
|
1068
|
+
...prompts,
|
|
1072
1069
|
config: {
|
|
1073
1070
|
pluginPath: options.pluginPath,
|
|
1074
1071
|
pythonPath: options.python,
|
|
@@ -1076,11 +1073,14 @@ export async function main(argv = process.argv.slice(2), output = process.stdout
|
|
|
1076
1073
|
},
|
|
1077
1074
|
createSecurity: dependencies.createSecurity,
|
|
1078
1075
|
signal: controller.signal,
|
|
1079
|
-
onProgress: ({ repository, status, attempt, error }) => {
|
|
1080
|
-
|
|
1076
|
+
onProgress: ({ repository, status, attempt, error, warning }) => {
|
|
1077
|
+
const detail = error ?? warning;
|
|
1078
|
+
errorOutput.write(`codex-security: ${repository} ${status} (attempt ${attempt})${detail === undefined ? "" : `: ${redactedErrorMessage(detail)}`}\n`);
|
|
1081
1079
|
},
|
|
1082
1080
|
});
|
|
1083
|
-
exitCode =
|
|
1081
|
+
exitCode =
|
|
1082
|
+
interruptedExitCode() ??
|
|
1083
|
+
(result.failed > 0 || result.incomplete > 0 ? 2 : 0);
|
|
1084
1084
|
return { ...result };
|
|
1085
1085
|
}
|
|
1086
1086
|
catch (error) {
|
|
@@ -1653,24 +1653,17 @@ function staysWithinWindowsDeviceRoot(input, root) {
|
|
|
1653
1653
|
return true;
|
|
1654
1654
|
}
|
|
1655
1655
|
async function runSkill(skill, inputs, codexOverrides, effort, stdout, stderr, dependencies) {
|
|
1656
|
-
if (inputs.length > MAX_SKILL_INPUT_COUNT) {
|
|
1657
|
-
throw new CodexSecurityError("Skill inputs exceed the 64-item limit.");
|
|
1658
|
-
}
|
|
1659
1656
|
const overrides = parseCodexOverrides(codexOverrides, undefined, effort);
|
|
1660
1657
|
if (Object.keys(overrides).some((key) => key !== "model" && key !== "model_reasoning_effort")) {
|
|
1661
1658
|
throw new CodexSecurityError("Validation and patching only support model and model_reasoning_effort overrides.");
|
|
1662
1659
|
}
|
|
1663
1660
|
const { model, reasoningEffort } = scanModelConfiguration(await mergedCodexConfig({ codexOverrides: overrides }));
|
|
1664
1661
|
const directory = dependencies.currentDirectory();
|
|
1665
|
-
let totalBytes = 0;
|
|
1666
1662
|
const contents = [];
|
|
1667
1663
|
for (const input of inputs) {
|
|
1668
1664
|
if (input.trim().length === 0) {
|
|
1669
1665
|
throw new CodexSecurityError("Finding or issue inputs must not be empty.");
|
|
1670
1666
|
}
|
|
1671
|
-
if (Buffer.byteLength(input, "utf8") > MAX_SKILL_INPUT_BYTES) {
|
|
1672
|
-
throw new CodexSecurityError("Skill input exceeds the 1 MiB limit.");
|
|
1673
|
-
}
|
|
1674
1667
|
let contentsOrLiteral = input;
|
|
1675
1668
|
const windowsNamespace = process.platform === "win32" || input.startsWith("\\");
|
|
1676
1669
|
const rawDeviceRoot = WINDOWS_LOCAL_DEVICE_ROOT.exec(input)?.[0];
|
|
@@ -1703,9 +1696,6 @@ async function runSkill(skill, inputs, codexOverrides, effort, stdout, stderr, d
|
|
|
1703
1696
|
if (!metadata.isFile()) {
|
|
1704
1697
|
throw new CodexSecurityError("Finding and issue inputs must be files or literal text.");
|
|
1705
1698
|
}
|
|
1706
|
-
if (metadata.size > MAX_SKILL_INPUT_BYTES) {
|
|
1707
|
-
throw new CodexSecurityError("Skill input exceeds the 1 MiB limit.");
|
|
1708
|
-
}
|
|
1709
1699
|
try {
|
|
1710
1700
|
contentsOrLiteral = await readFile(path, "utf8");
|
|
1711
1701
|
}
|
|
@@ -1717,10 +1707,6 @@ async function runSkill(skill, inputs, codexOverrides, effort, stdout, stderr, d
|
|
|
1717
1707
|
}
|
|
1718
1708
|
}
|
|
1719
1709
|
}
|
|
1720
|
-
totalBytes += Buffer.byteLength(contentsOrLiteral, "utf8");
|
|
1721
|
-
if (totalBytes > MAX_SKILL_INPUT_BYTES) {
|
|
1722
|
-
throw new CodexSecurityError("Skill input exceeds the 1 MiB limit.");
|
|
1723
|
-
}
|
|
1724
1710
|
contents.push(contentsOrLiteral);
|
|
1725
1711
|
}
|
|
1726
1712
|
const plugin = await bundledPluginRoot();
|
|
@@ -1756,33 +1742,24 @@ async function runSkill(skill, inputs, codexOverrides, effort, stdout, stderr, d
|
|
|
1756
1742
|
stderr,
|
|
1757
1743
|
});
|
|
1758
1744
|
}
|
|
1759
|
-
export async function readSkillCommandOutput(stream
|
|
1745
|
+
export async function readSkillCommandOutput(stream) {
|
|
1760
1746
|
let message;
|
|
1761
1747
|
let error;
|
|
1762
1748
|
let malformed = false;
|
|
1763
|
-
|
|
1764
|
-
const markExceeded = () => {
|
|
1765
|
-
if (exceeded)
|
|
1766
|
-
return;
|
|
1767
|
-
exceeded = true;
|
|
1768
|
-
onLimitExceeded?.();
|
|
1769
|
-
};
|
|
1770
|
-
const readLine = (bytes) => {
|
|
1771
|
-
const content = bytes.at(-1) === 0x0d ? bytes.subarray(0, bytes.length - 1) : bytes;
|
|
1772
|
-
const line = content.toString("utf8");
|
|
1749
|
+
for await (const line of createInterface({ input: Readable.from(stream) })) {
|
|
1773
1750
|
if (line.trim().length === 0)
|
|
1774
|
-
|
|
1751
|
+
continue;
|
|
1775
1752
|
let event;
|
|
1776
1753
|
try {
|
|
1777
1754
|
event = JSON.parse(line);
|
|
1778
1755
|
}
|
|
1779
1756
|
catch {
|
|
1780
1757
|
malformed = true;
|
|
1781
|
-
|
|
1758
|
+
continue;
|
|
1782
1759
|
}
|
|
1783
1760
|
if (typeof event !== "object" || event === null) {
|
|
1784
1761
|
malformed = true;
|
|
1785
|
-
|
|
1762
|
+
continue;
|
|
1786
1763
|
}
|
|
1787
1764
|
const value = event;
|
|
1788
1765
|
if (value["type"] === "item.completed") {
|
|
@@ -1793,12 +1770,7 @@ export async function readSkillCommandOutput(stream, onLimitExceeded) {
|
|
|
1793
1770
|
item.type === "agent_message" &&
|
|
1794
1771
|
"text" in item &&
|
|
1795
1772
|
typeof item.text === "string") {
|
|
1796
|
-
|
|
1797
|
-
markExceeded();
|
|
1798
|
-
}
|
|
1799
|
-
else {
|
|
1800
|
-
message = item.text;
|
|
1801
|
-
}
|
|
1773
|
+
message = item.text;
|
|
1802
1774
|
}
|
|
1803
1775
|
}
|
|
1804
1776
|
else if (value["type"] === "turn.failed") {
|
|
@@ -1807,62 +1779,14 @@ export async function readSkillCommandOutput(stream, onLimitExceeded) {
|
|
|
1807
1779
|
detail !== null &&
|
|
1808
1780
|
"message" in detail &&
|
|
1809
1781
|
typeof detail.message === "string") {
|
|
1810
|
-
|
|
1811
|
-
markExceeded();
|
|
1812
|
-
}
|
|
1813
|
-
else {
|
|
1814
|
-
error = detail.message;
|
|
1815
|
-
}
|
|
1782
|
+
error = detail.message;
|
|
1816
1783
|
}
|
|
1817
1784
|
}
|
|
1818
1785
|
else if (value["type"] === "error" &&
|
|
1819
1786
|
typeof value["message"] === "string") {
|
|
1820
|
-
|
|
1821
|
-
markExceeded();
|
|
1822
|
-
}
|
|
1823
|
-
else {
|
|
1824
|
-
error = value["message"];
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
};
|
|
1828
|
-
const pending = Buffer.alloc(MAX_SKILL_EVENT_BYTES);
|
|
1829
|
-
let pendingBytes = 0;
|
|
1830
|
-
let discardingOversizedLine = false;
|
|
1831
|
-
for await (const rawChunk of stream) {
|
|
1832
|
-
const chunk = Buffer.isBuffer(rawChunk)
|
|
1833
|
-
? rawChunk
|
|
1834
|
-
: Buffer.from(rawChunk, "utf8");
|
|
1835
|
-
let start = 0;
|
|
1836
|
-
while (start < chunk.length) {
|
|
1837
|
-
const newline = chunk.indexOf(0x0a, start);
|
|
1838
|
-
const end = newline === -1 ? chunk.length : newline;
|
|
1839
|
-
const segment = chunk.subarray(start, end);
|
|
1840
|
-
if (!discardingOversizedLine) {
|
|
1841
|
-
if (pendingBytes + segment.length > MAX_SKILL_EVENT_BYTES) {
|
|
1842
|
-
markExceeded();
|
|
1843
|
-
discardingOversizedLine = true;
|
|
1844
|
-
pendingBytes = 0;
|
|
1845
|
-
}
|
|
1846
|
-
else if (segment.length > 0) {
|
|
1847
|
-
segment.copy(pending, pendingBytes);
|
|
1848
|
-
pendingBytes += segment.length;
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
if (newline === -1)
|
|
1852
|
-
break;
|
|
1853
|
-
if (!discardingOversizedLine) {
|
|
1854
|
-
readLine(pending.subarray(0, pendingBytes));
|
|
1855
|
-
}
|
|
1856
|
-
pendingBytes = 0;
|
|
1857
|
-
discardingOversizedLine = false;
|
|
1858
|
-
start = newline + 1;
|
|
1787
|
+
error = value["message"];
|
|
1859
1788
|
}
|
|
1860
1789
|
}
|
|
1861
|
-
if (!discardingOversizedLine && pendingBytes > 0) {
|
|
1862
|
-
readLine(pending.subarray(0, pendingBytes));
|
|
1863
|
-
}
|
|
1864
|
-
if (exceeded)
|
|
1865
|
-
throw new CodexSecurityError(SKILL_OUTPUT_LIMIT_MESSAGE);
|
|
1866
1790
|
return {
|
|
1867
1791
|
...(message === undefined ? {} : { message }),
|
|
1868
1792
|
...(error === undefined ? {} : { error }),
|
|
@@ -2040,6 +1964,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
|
|
|
2040
1964
|
try {
|
|
2041
1965
|
const repository = arguments_.repository ?? dependencies.currentDirectory();
|
|
2042
1966
|
const target = targetFromArguments(arguments_);
|
|
1967
|
+
const prompts = await readPromptFiles(dependencies.currentDirectory(), arguments_.scanPromptFile, arguments_.postScanPromptFile);
|
|
2043
1968
|
const config = {
|
|
2044
1969
|
pluginPath: arguments_.pluginPath,
|
|
2045
1970
|
pythonPath: arguments_.pythonPath,
|
|
@@ -2156,6 +2081,7 @@ async function runScan(arguments_, errorOutput, dependencies, interactive = true
|
|
|
2156
2081
|
auth,
|
|
2157
2082
|
target,
|
|
2158
2083
|
knowledgeBasePaths: arguments_.knowledgeBasePaths,
|
|
2084
|
+
...prompts,
|
|
2159
2085
|
mode: arguments_.mode,
|
|
2160
2086
|
workers: arguments_.workers,
|
|
2161
2087
|
subagents: arguments_.subagents,
|
|
@@ -2766,16 +2692,11 @@ export function parseCodexOverrides(values, model, effort, provider) {
|
|
|
2766
2692
|
if (key.length === 0 || literal.length === 0) {
|
|
2767
2693
|
throw new CodexSecurityError("--codex expects KEY=VALUE");
|
|
2768
2694
|
}
|
|
2769
|
-
if (Buffer.byteLength(key, "utf8") > MAX_CODEX_OVERRIDE_KEY_LENGTH ||
|
|
2770
|
-
Buffer.byteLength(literal, "utf8") > MAX_CODEX_OVERRIDE_VALUE_LENGTH) {
|
|
2771
|
-
throw new CodexSecurityError("--codex key or value exceeds the limit");
|
|
2772
|
-
}
|
|
2773
2695
|
const parts = key.split(".");
|
|
2774
|
-
if (parts.length
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
part === "constructor")) {
|
|
2696
|
+
if (parts.some((part) => part.length === 0 ||
|
|
2697
|
+
part === "__proto__" ||
|
|
2698
|
+
part === "prototype" ||
|
|
2699
|
+
part === "constructor")) {
|
|
2779
2700
|
throw new CodexSecurityError("Invalid --codex key");
|
|
2780
2701
|
}
|
|
2781
2702
|
let parsed;
|