Files
codex-security/evals/dependency-reachability/cli.mjs
utsav-oaiandutsav-oai 5353212b03 test(cli): evaluate dependency investigations across public fixtures (#2716)
* feat(cli): add independently reviewed dependency checks

* Compare frozen Python advisory versions as releases

* fix(cli): bind unnamed root manifests to observed services

* test(cli): evaluate dependency investigations across public fixtures

* test(sdk): bound the budget wait after the mock scan starts

* test(cli): exercise MCP evidence and missing caller access

* Bind graded citations to the approved use evidence

---------

Co-authored-by: utsav-oai <348536218+utsav-oai@users.noreply.github.com>
2026-11-19 07:28:56 -08:00

40 lines
1.2 KiB
JavaScript

import { spawn } from "node:child_process";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
export async function invokeCli(cli, repo, args, { input, signal } = {}) {
const child = spawn(process.execPath, [cli, "exploitability", ...args], {
cwd: repo,
env: {
...process.env,
CODEX_SECURITY_ENABLE_DEPENDENCY_EXPLOITABILITY: "1",
},
signal,
stdio: ["pipe", "pipe", "pipe"],
});
const stdout = [];
let stderr = "";
child.stdout.on("data", (chunk) => stdout.push(chunk));
child.stderr.setEncoding("utf8").on("data", (s) => {
stderr += s;
});
const done = new Promise((accept, reject) => {
child.on("error", reject);
child.stdin.on("error", (error) => {
if (error.code !== "EPIPE") reject(error);
});
child.on("close", (code, signal) =>
accept({ code, signal, stdout: Buffer.concat(stdout), stderr }),
);
});
child.stdin.end(input === undefined ? undefined : JSON.stringify(input));
return done;
}
export async function writeCliLogs(dir, { code, stdout, stderr }) {
await writeFile(join(dir, "stderr.log"), stderr, { mode: 0o600 });
if (code !== 0) {
await writeFile(join(dir, "stdout.log"), stdout, { mode: 0o600 });
}
}