mirror of
https://github.com/openai/codex-security.git
synced 2026-12-04 02:07:21 +08:00
* 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 * test: restore dependency investigation quality controls * fix(cli): restore dependency investigation and report compatibility * test: grade malformed dependency baseline answers * fix(cli): scope headless tool access to the investigator * test(cli): lock down reviewer and external evidence tool access * fix(cli): keep linked evidence tied to its originating call * Reconcile application mappings and expose original evidence hashes * test: verify selected catalog rows against original replies * fix(cli): recover incomplete reviews and preserve selected evidence rows * fix(cli): preserve wire evidence and verify finding citations * Finalize from approved submissions and explain remaining uses * fix(cli): restore coordinator recovery, independent review and report contracts * Review withdrawals under the original dependency assessment ID * test(cli): compare trace progress with completed search scopes * Recheck dependency coverage after concurrent investigation changes * Preserve exploratory scope explanations during dependency review * feat(cli): track shared source work in dependency investigations * Include shared source work in final coverage checks * Require deciding evidence on the caller it establishes * Preserve generic MCP search outcomes and scopes in dependency reports * Share pinned source notes between dependency investigators * Ship the source worklist and search audit modules * refactor(cli): name the dependency coordinator for its ability to resume * refactor(cli): simplify the tools for dependency investigations * fix(cli): keep investigation tool arguments visible to Codex and reuse the evidence store * fix(cli): send missing verdict citations back to the reviewer * fix(cli): verify caller bindings and input flow across investigation steps * fix(cli): require direct citations for asserted runtime facts on every use * test(cli): verify failed catalog lookups without a timed source scan --------- Co-authored-by: utsav-oai <348536218+utsav-oai@users.noreply.github.com>
89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
import { cp, mkdir, readFile, realpath } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { Codex } from "../../sdk/typescript/node_modules/@openai/codex-sdk/dist/index.js";
|
|
import * as auth from "../../sdk/typescript/dist/auth.js";
|
|
import {
|
|
createIsolatedHome,
|
|
resolveCodexCommand,
|
|
} from "../../sdk/typescript/dist/runtime.js";
|
|
import {
|
|
preflightEval,
|
|
runStructuredTurn,
|
|
} from "../secret-discovery/harness.mts";
|
|
import { withEvalState } from "../secret-discovery/runtime.mts";
|
|
import { routingSettings } from "../workflow-routing/harness.mts";
|
|
|
|
const plugin = join(import.meta.dirname, "../../plugins/codex-security");
|
|
const skill = "skills/attack-path-analysis";
|
|
|
|
export async function stageSkill(root: string) {
|
|
const runtime = join(root, "runtime");
|
|
await mkdir(runtime);
|
|
for (const directory of [skill, "references"]) {
|
|
await cp(join(plugin, directory), join(runtime, directory), {
|
|
recursive: true,
|
|
});
|
|
}
|
|
const path = join(runtime, skill, "SKILL.md");
|
|
return { runtime, path, instructions: await readFile(path, "utf8") };
|
|
}
|
|
|
|
interface ModelState {
|
|
root: string;
|
|
signal: AbortSignal;
|
|
run(
|
|
repo: string,
|
|
question: string,
|
|
schema: unknown,
|
|
): Promise<{
|
|
answer: unknown;
|
|
usage: unknown;
|
|
}>;
|
|
}
|
|
|
|
export async function withModel(
|
|
model: string | undefined,
|
|
execute: (state: ModelState) => Promise<void>,
|
|
) {
|
|
const ambientHome = (
|
|
auth as unknown as typeof import("../../sdk/typescript/src/auth.js")
|
|
).configuredCodexHome(process.env);
|
|
await withEvalState(
|
|
createIsolatedHome,
|
|
ambientHome,
|
|
async ({ root, home, signal }) => {
|
|
const codexPath = await realpath(resolveCodexCommand({}).command);
|
|
const settings = routingSettings(home, codexPath);
|
|
const { runtime, path, instructions } = await stageSkill(root);
|
|
await execute({
|
|
root,
|
|
signal,
|
|
async run(repo, question, schema) {
|
|
signal.throwIfAborted();
|
|
const prepared = { repo, runtime };
|
|
const codex = new Codex(
|
|
await preflightEval(prepared, settings, signal),
|
|
);
|
|
const prompt = [
|
|
"Apply the production attack-path-analysis skill below to the supplied finding. Inspect the current source snapshot offline and read-only. Return the requested JSON.",
|
|
`Resolve skill references relative to ${path}.`,
|
|
instructions,
|
|
question,
|
|
].join("\n\n");
|
|
const { finalResponse, usage } = await runStructuredTurn(
|
|
prepared,
|
|
codex,
|
|
prompt,
|
|
schema,
|
|
{ model, signal },
|
|
);
|
|
return {
|
|
answer: JSON.parse(finalResponse) as unknown,
|
|
usage: usage ?? null,
|
|
};
|
|
},
|
|
});
|
|
},
|
|
);
|
|
}
|