Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

test(scans): cover private endpoint profile cleanup and replay (#125)

Haokun Tang6b63b00486fe
diff --git a/sdk/typescript/tests-ts/api-file-profile-replay.test.ts b/sdk/typescript/tests-ts/api-file-profile-replay.test.ts
index 83303a265..b7d224d04 100644
--- a/sdk/typescript/tests-ts/api-file-profile-replay.test.ts
+++ b/sdk/typescript/tests-ts/api-file-profile-replay.test.ts
@@ -61,6 +61,7 @@ test.serial.each([
"early",
"precommit",
"rejected",
+ "rejected-endpoint",
"postcommit",
"unavailable-receipt",
"success",
@@ -170,7 +171,13 @@ test.serial.each([
: undefined;
let submitted: JsonObject | undefined;
client = new TestClient(
- { pluginPath: pluginRoot, codexOverrides: explicit },
+ {
+ pluginPath: pluginRoot,
+ codexOverrides:
+ boundary === "rejected-endpoint"
+ ? { openai_base_url: "https://explicit.example.test/v1" }
+ : explicit,
+ },
{
environment,
resolvePluginPython: async () => python,
@@ -183,7 +190,7 @@ test.serial.each([
runWorkbench: async (options, args, input) => {
if (args[0] === "register-cli-scan") {
submitted = JSON.parse(input!).recipe;
- if (boundary === "rejected")
+ if (boundary === "rejected" || boundary === "rejected-endpoint")
args = [
...args,
"--parent-scan-id",
@@ -235,6 +242,10 @@ test.serial.each([
].includes(boundary);
expect(scans).toHaveLength(committed ? 1 : 0);
if (!committed) {
+ if (boundary === "rejected-endpoint")
+ expect(submitted?.["providerProfile"]).toMatchObject({
+ home: "managed",
+ });
const names = await readdir(
codexSecurityCredentialHome(environment),
).catch((error: NodeJS.ErrnoException) => {
@@ -337,6 +348,7 @@ test.each(
await mkdir(path, { mode: 0o700 });
const profilePath = join(home, "review.config.toml");
const fileProfile = (version: string) => ({
+ openai_base_url: `https://${version}.example.test/v1`,
model: version === "first" ? "initial-model" : "updated-model",
model_reasoning_effort: version === "first" ? "low" : "high",
analytics: { enabled: true },
@@ -371,6 +383,9 @@ test.each(
model_catalog_json: "../caller-catalog.json",
features: { view_image: false, shell_tool: false },
};
+ const explicitEndpoint =
+ skills === "explicit" ? "https://caller.example.test/v1" : undefined;
+ if (explicitEndpoint) explicit["openai_base_url"] = explicitEndpoint;
if (skills !== "inherited")
explicit["skills"] =
skills === "null"
@@ -434,6 +449,7 @@ test.each(
await mergedCodexConfig({ codexOverrides: replay }, home),
);
expect(restored).toMatchObject({
+ openai_base_url: explicitEndpoint ?? "https://reloaded.example.test/v1",
model: "updated-model",
model_reasoning_effort: "high",
analytics: { enabled: false },
@@ -484,6 +500,7 @@ test.each(
`${profile["name"]}.config.json`,
);
const saved = JSON.parse(await readFile(privatePath, "utf8"));
+ expect(saved["openai_base_url"]).toBe(explicitEndpoint);
expect(saved).not.toHaveProperty("model_catalog_json");
expect(saved).not.toHaveProperty("features.shell_tool");
expect(saved).toHaveProperty("model_instructions_file", null);
diff --git a/sdk/typescript/tests-ts/support/replay-worker-boundary.ts b/sdk/typescript/tests-ts/support/replay-worker-boundary.ts
index 2783bab5e..3b23ffa92 100644
--- a/sdk/typescript/tests-ts/support/replay-worker-boundary.ts
+++ b/sdk/typescript/tests-ts/support/replay-worker-boundary.ts
@@ -107,6 +107,7 @@ async function assertWorkerReplay(
selected = deepMerge(selected, parse(argv[++index]!) as JsonObject);
for (const key of [
"analytics",
+ "openai_base_url",
"shell_environment_policy",
"otel",
"skills",