@openai/codex-security 0.1.21 → 0.1.23
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 +529 -0
- 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/references/config-preflight.md +2 -30
- package/_bundled_plugin/references/core-scan.md +1 -1
- package/_bundled_plugin/references/final-report.md +1 -1
- package/_bundled_plugin/references/finding-detail-fields.md +5 -10
- package/_bundled_plugin/references/sarif-adapter.md +1 -1
- package/_bundled_plugin/scripts/config_preflight.py +2 -8
- package/_bundled_plugin/scripts/finalize_scan_contract.py +114 -24
- package/_bundled_plugin/scripts/finding_preview.py +22 -4
- package/_bundled_plugin/scripts/generate_in_scope_files.py +27 -1
- package/_bundled_plugin/scripts/windows_scan_local_files.py +101 -7
- package/_bundled_plugin/scripts/workbench_cli.py +21 -1
- package/_bundled_plugin/scripts/workbench_dashboard.py +115 -0
- package/_bundled_plugin/scripts/workbench_db.py +29 -2
- package/_bundled_plugin/scripts/workbench_finding_index.py +42 -24
- package/_bundled_plugin/scripts/workbench_finding_workflows.py +190 -0
- package/_bundled_plugin/scripts/workbench_findings.py +216 -0
- package/_bundled_plugin/scripts/workbench_saved_results.py +30 -5
- package/_bundled_plugin/scripts/workbench_schema.py +263 -58
- package/_bundled_plugin/scripts/workbench_target.py +22 -3
- package/_bundled_plugin/skills/track-findings/SKILL.md +2 -0
- package/dist/api.d.ts +2 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +115 -27
- package/dist/api.js.map +1 -1
- package/dist/cli.d.ts +4 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +124 -58
- package/dist/cli.js.map +1 -1
- package/dist/cloud-publish.js +5 -1
- package/dist/cloud-publish.js.map +1 -1
- package/dist/contract.d.ts +1 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +9 -0
- package/dist/contract.js.map +1 -1
- package/dist/custom-publish.d.ts +22 -0
- package/dist/custom-publish.d.ts.map +1 -0
- package/dist/custom-publish.js +47 -0
- package/dist/custom-publish.js.map +1 -0
- package/dist/custom-validation-prompt.js +1 -1
- package/dist/custom-validation-prompt.js.map +1 -1
- package/dist/deduplication/checkpointed-review.d.ts +16 -0
- package/dist/deduplication/checkpointed-review.d.ts.map +1 -0
- package/dist/deduplication/checkpointed-review.js +76 -0
- package/dist/deduplication/checkpointed-review.js.map +1 -0
- package/dist/deduplication/codex-review.d.ts +21 -0
- package/dist/deduplication/codex-review.d.ts.map +1 -0
- package/dist/deduplication/codex-review.js +252 -0
- package/dist/deduplication/codex-review.js.map +1 -0
- package/dist/deduplication/deduplication-prompts.d.ts +8 -0
- package/dist/deduplication/deduplication-prompts.d.ts.map +1 -0
- package/dist/deduplication/deduplication-prompts.js +35 -0
- package/dist/deduplication/deduplication-prompts.js.map +1 -0
- package/dist/deduplication/deduplication-reviewer.d.ts +46 -0
- package/dist/deduplication/deduplication-reviewer.d.ts.map +1 -0
- package/dist/deduplication/deduplication-reviewer.js +105 -0
- package/dist/deduplication/deduplication-reviewer.js.map +1 -0
- package/dist/deduplication/deduplication.d.ts +6 -0
- package/dist/deduplication/deduplication.d.ts.map +1 -0
- package/dist/deduplication/deduplication.js +85 -0
- package/dist/deduplication/deduplication.js.map +1 -0
- package/dist/deduplication/scan.d.ts +16 -0
- package/dist/deduplication/scan.d.ts.map +1 -0
- package/dist/deduplication/scan.js +101 -0
- package/dist/deduplication/scan.js.map +1 -0
- package/dist/finding-dedupe-groups.d.ts +7 -0
- package/dist/finding-dedupe-groups.d.ts.map +1 -0
- package/dist/finding-dedupe-groups.js +2 -0
- package/dist/finding-dedupe-groups.js.map +1 -0
- package/dist/finding-retrieval.d.ts +13 -0
- package/dist/finding-retrieval.d.ts.map +1 -0
- package/dist/finding-retrieval.js +2 -0
- package/dist/finding-retrieval.js.map +1 -0
- package/dist/finding-workflow.d.ts +53 -0
- package/dist/finding-workflow.d.ts.map +1 -0
- package/dist/finding-workflow.js +117 -0
- package/dist/finding-workflow.js.map +1 -0
- package/dist/findings-client.d.ts +15 -0
- package/dist/findings-client.d.ts.map +1 -0
- package/dist/findings-client.js +60 -0
- package/dist/findings-client.js.map +1 -0
- 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/publication.js +28 -40
- package/dist/publication.js.map +1 -1
- package/dist/runtime.d.ts +5 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +113 -12
- package/dist/runtime.js.map +1 -1
- package/dist/saved-scan.d.ts +15 -0
- package/dist/saved-scan.d.ts.map +1 -0
- package/dist/saved-scan.js +68 -0
- package/dist/saved-scan.js.map +1 -0
- package/dist/scan-comparison.d.ts +3 -2
- package/dist/scan-comparison.d.ts.map +1 -1
- package/dist/scan-comparison.js +1 -1
- package/dist/scan-comparison.js.map +1 -1
- package/dist/server/dashboard/THIRD_PARTY_NOTICES.txt +276 -0
- package/dist/server/dashboard/app.css +2 -0
- package/dist/server/dashboard/app.js +66 -0
- package/dist/server/dashboard/index.html +18 -0
- package/dist/server/dashboard-types.d.ts +45 -0
- package/dist/server/dashboard-types.d.ts.map +1 -0
- package/dist/server/dashboard-types.js +2 -0
- package/dist/server/dashboard-types.js.map +1 -0
- package/dist/server/dashboard.d.ts +6 -0
- package/dist/server/dashboard.d.ts.map +1 -0
- package/dist/server/dashboard.js +45 -0
- package/dist/server/dashboard.js.map +1 -0
- package/dist/server/embeddings.d.ts +16 -0
- package/dist/server/embeddings.d.ts.map +1 -0
- package/dist/server/embeddings.js +114 -0
- package/dist/server/embeddings.js.map +1 -0
- package/dist/server/errors.d.ts +5 -0
- package/dist/server/errors.d.ts.map +1 -0
- package/dist/server/errors.js +8 -0
- package/dist/server/errors.js.map +1 -0
- package/dist/server/findings-service.d.ts +20 -0
- package/dist/server/findings-service.d.ts.map +1 -0
- package/dist/server/findings-service.js +31 -0
- package/dist/server/findings-service.js.map +1 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +32 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/routes.d.ts +6 -0
- package/dist/server/routes.d.ts.map +1 -0
- package/dist/server/routes.js +86 -0
- package/dist/server/routes.js.map +1 -0
- package/dist/server/server.d.ts +10 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/server.js +17 -0
- package/dist/server/server.js.map +1 -0
- package/dist/server/sqlite-store.d.ts +22 -0
- package/dist/server/sqlite-store.d.ts.map +1 -0
- package/dist/server/sqlite-store.js +82 -0
- package/dist/server/sqlite-store.js.map +1 -0
- package/dist/server/storage.d.ts +32 -0
- package/dist/server/storage.d.ts.map +1 -0
- package/dist/server/storage.js +2 -0
- package/dist/server/storage.js.map +1 -0
- package/dist/server/validation.d.ts +17 -0
- package/dist/server/validation.d.ts.map +1 -0
- package/dist/server/validation.js +53 -0
- package/dist/server/validation.js.map +1 -0
- package/dist/trusted-executable.d.ts.map +1 -1
- package/dist/trusted-executable.js +2 -1
- package/dist/trusted-executable.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 +17 -5
package/dist/runtime.js
CHANGED
|
@@ -31,6 +31,42 @@ const CREDENTIAL_LOCK_POLL_MILLISECONDS = 25;
|
|
|
31
31
|
const INCOMPLETE_CREDENTIAL_LOCK_MILLISECONDS = 30_000;
|
|
32
32
|
const MAX_PROCESS_ID = 2_147_483_647;
|
|
33
33
|
const MAX_WINDOWS_CREDENTIAL_ACL_STDERR = 64 * 1024;
|
|
34
|
+
const PLUGIN_HELPER_SECRET_ENVIRONMENT_VARIABLES = new Set([
|
|
35
|
+
"OPENAI_API_KEY",
|
|
36
|
+
"CODEX_API_KEY",
|
|
37
|
+
"OPENROUTER_API_KEY",
|
|
38
|
+
"FIREWORKS_API_KEY",
|
|
39
|
+
]);
|
|
40
|
+
const PREPARE_SCAN_ARTIFACT_RESTORER_PROGRAM = `
|
|
41
|
+
from pathlib import Path
|
|
42
|
+
from runpy import run_path
|
|
43
|
+
import json
|
|
44
|
+
import sys
|
|
45
|
+
|
|
46
|
+
module = run_path(sys.argv[1])
|
|
47
|
+
canonical_path, root_identity = module["scan_root_identity"](Path(sys.argv[2]))
|
|
48
|
+
print(json.dumps({
|
|
49
|
+
"canonicalPath": str(canonical_path),
|
|
50
|
+
"dev": str(root_identity[0]),
|
|
51
|
+
"ino": str(root_identity[1]),
|
|
52
|
+
}, ensure_ascii=False))
|
|
53
|
+
`.trim();
|
|
54
|
+
const RESTORE_SCAN_ARTIFACT_PROGRAM = `
|
|
55
|
+
from pathlib import Path
|
|
56
|
+
from runpy import run_path
|
|
57
|
+
import sys
|
|
58
|
+
|
|
59
|
+
module = run_path(sys.argv[1])
|
|
60
|
+
try:
|
|
61
|
+
module["write_scan_local_bytes"](
|
|
62
|
+
Path(sys.argv[2]),
|
|
63
|
+
sys.argv[3],
|
|
64
|
+
sys.stdin.buffer.read(),
|
|
65
|
+
expected_root_identity=(int(sys.argv[4]), int(sys.argv[5])),
|
|
66
|
+
)
|
|
67
|
+
except (module["ContractError"], OSError) as error:
|
|
68
|
+
raise SystemExit(str(error))
|
|
69
|
+
`.trim();
|
|
34
70
|
const WINDOWS_CREDENTIAL_ACL_COMPLETE_PREFIX = "CODEX_SECURITY_ACL_COMPLETE:";
|
|
35
71
|
const WINDOWS_CREDENTIAL_DESCENDANTS_CHANGED_EXIT_CODE = 2;
|
|
36
72
|
function environmentValue(environment, requested) {
|
|
@@ -1074,10 +1110,6 @@ export async function preparePersistentOutputRoot(stateDirectory, category, repo
|
|
|
1074
1110
|
export async function runWorkbench(options, args, input) {
|
|
1075
1111
|
let stdout;
|
|
1076
1112
|
try {
|
|
1077
|
-
const environment = Object.fromEntries(Object.entries(options.environment).filter(([name]) => name.toUpperCase() !== "OPENAI_API_KEY" &&
|
|
1078
|
-
name.toUpperCase() !== "CODEX_API_KEY" &&
|
|
1079
|
-
name.toUpperCase() !== "OPENROUTER_API_KEY" &&
|
|
1080
|
-
name.toUpperCase() !== "FIREWORKS_API_KEY"));
|
|
1081
1113
|
const result = await runCodexCommand({ command: options.python }, [
|
|
1082
1114
|
"-I",
|
|
1083
1115
|
"-X",
|
|
@@ -1085,7 +1117,7 @@ export async function runWorkbench(options, args, input) {
|
|
|
1085
1117
|
"-B",
|
|
1086
1118
|
join(options.pluginRoot, "scripts", "workbench_db.py"),
|
|
1087
1119
|
...args,
|
|
1088
|
-
],
|
|
1120
|
+
], pluginHelperEnvironment(options.environment), input, options.signal);
|
|
1089
1121
|
if (!result.success) {
|
|
1090
1122
|
throw new Error(result.stderr.trim() ||
|
|
1091
1123
|
result.stdout.trim() ||
|
|
@@ -1116,16 +1148,10 @@ export async function runWorkbench(options, args, input) {
|
|
|
1116
1148
|
return result;
|
|
1117
1149
|
}
|
|
1118
1150
|
export function bundledPluginCandidates(moduleDirectory) {
|
|
1119
|
-
|
|
1151
|
+
return [
|
|
1120
1152
|
resolve(moduleDirectory, "_bundled_plugin"),
|
|
1121
1153
|
resolve(moduleDirectory, "../_bundled_plugin"),
|
|
1122
1154
|
];
|
|
1123
|
-
return basename(moduleDirectory) === "src"
|
|
1124
|
-
? [
|
|
1125
|
-
resolve(moduleDirectory, "../../../plugins/codex-security"),
|
|
1126
|
-
...packageCandidates,
|
|
1127
|
-
]
|
|
1128
|
-
: packageCandidates;
|
|
1129
1155
|
}
|
|
1130
1156
|
export async function bundledPluginRoot() {
|
|
1131
1157
|
const moduleDirectory = dirname(fileURLToPath(import.meta.url));
|
|
@@ -1189,6 +1215,78 @@ export async function validateOutputDir(outputDirectory, archiveExisting = false
|
|
|
1189
1215
|
throw new OutputDirectoryError(`Unable to inspect scan output directory: ${outputDirectory}`, { cause: error });
|
|
1190
1216
|
}
|
|
1191
1217
|
}
|
|
1218
|
+
export async function prepareScanArtifactRestorer(options, scanDirectory) {
|
|
1219
|
+
let helperPath;
|
|
1220
|
+
let canonicalPath;
|
|
1221
|
+
let dev;
|
|
1222
|
+
let ino;
|
|
1223
|
+
try {
|
|
1224
|
+
// Recovery uses the SDK-owned writer, even if the scan selected a custom plugin.
|
|
1225
|
+
helperPath = join(await bundledPluginRoot(), "scripts", "finalize_scan_contract.py");
|
|
1226
|
+
const result = await runCodexCommand({ command: options.python }, [
|
|
1227
|
+
"-I",
|
|
1228
|
+
"-X",
|
|
1229
|
+
"utf8",
|
|
1230
|
+
"-B",
|
|
1231
|
+
"-c",
|
|
1232
|
+
PREPARE_SCAN_ARTIFACT_RESTORER_PROGRAM,
|
|
1233
|
+
helperPath,
|
|
1234
|
+
scanDirectory,
|
|
1235
|
+
], pluginHelperEnvironment(options.environment), undefined, options.signal);
|
|
1236
|
+
if (!result.success) {
|
|
1237
|
+
throw new Error(result.stderr.trim() ||
|
|
1238
|
+
result.stdout.trim() ||
|
|
1239
|
+
`Artifact restoration setup exited with status ${result.exitCode}.`);
|
|
1240
|
+
}
|
|
1241
|
+
const prepared = JSON.parse(result.stdout);
|
|
1242
|
+
if (!isRecord(prepared) ||
|
|
1243
|
+
typeof prepared["canonicalPath"] !== "string" ||
|
|
1244
|
+
prepared["canonicalPath"].length === 0 ||
|
|
1245
|
+
typeof prepared["dev"] !== "string" ||
|
|
1246
|
+
!/^(?:0|[1-9]\d*)$/u.test(prepared["dev"]) ||
|
|
1247
|
+
typeof prepared["ino"] !== "string" ||
|
|
1248
|
+
!/^(?:0|[1-9]\d*)$/u.test(prepared["ino"])) {
|
|
1249
|
+
throw new Error("Artifact restoration setup returned invalid output.");
|
|
1250
|
+
}
|
|
1251
|
+
canonicalPath = prepared["canonicalPath"];
|
|
1252
|
+
dev = prepared["dev"];
|
|
1253
|
+
ino = prepared["ino"];
|
|
1254
|
+
}
|
|
1255
|
+
catch (error) {
|
|
1256
|
+
if (options.signal?.aborted)
|
|
1257
|
+
throw error;
|
|
1258
|
+
throw new OutputDirectoryError("Could not securely prepare completed scan artifact restoration.", { cause: error });
|
|
1259
|
+
}
|
|
1260
|
+
return {
|
|
1261
|
+
async restore(relativePath, contents) {
|
|
1262
|
+
try {
|
|
1263
|
+
const result = await runCodexCommand({ command: options.python }, [
|
|
1264
|
+
"-I",
|
|
1265
|
+
"-X",
|
|
1266
|
+
"utf8",
|
|
1267
|
+
"-B",
|
|
1268
|
+
"-c",
|
|
1269
|
+
RESTORE_SCAN_ARTIFACT_PROGRAM,
|
|
1270
|
+
helperPath,
|
|
1271
|
+
canonicalPath,
|
|
1272
|
+
relativePath,
|
|
1273
|
+
dev,
|
|
1274
|
+
ino,
|
|
1275
|
+
], pluginHelperEnvironment(options.environment), contents, options.signal);
|
|
1276
|
+
if (!result.success) {
|
|
1277
|
+
throw new Error(result.stderr.trim() ||
|
|
1278
|
+
result.stdout.trim() ||
|
|
1279
|
+
`Artifact restoration exited with status ${result.exitCode}.`);
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
catch (error) {
|
|
1283
|
+
if (options.signal?.aborted)
|
|
1284
|
+
throw error;
|
|
1285
|
+
throw new OutputDirectoryError("Could not safely restore a completed scan artifact.", { cause: error });
|
|
1286
|
+
}
|
|
1287
|
+
},
|
|
1288
|
+
};
|
|
1289
|
+
}
|
|
1192
1290
|
export async function planOutputArchive(outputDirectory) {
|
|
1193
1291
|
if (outputDirectory === null)
|
|
1194
1292
|
return null;
|
|
@@ -1793,6 +1891,9 @@ export function pythonUtf8Environment(environment) {
|
|
|
1793
1891
|
normalized["PYTHONUTF8"] = "1";
|
|
1794
1892
|
return normalized;
|
|
1795
1893
|
}
|
|
1894
|
+
function pluginHelperEnvironment(environment) {
|
|
1895
|
+
return pythonUtf8Environment(Object.fromEntries(Object.entries(environment).filter(([name]) => !PLUGIN_HELPER_SECRET_ENVIRONMENT_VARIABLES.has(name.toUpperCase()))));
|
|
1896
|
+
}
|
|
1796
1897
|
export async function cleanupSdkDirectory(path) {
|
|
1797
1898
|
await rm(path, { recursive: true, force: true });
|
|
1798
1899
|
}
|