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

fix(plugin): disambiguate duplicate coverage surface identifiers (#438)

Dane Schneidera6f6f7d2120f
diff --git a/sdk/typescript/_bundled_plugin/mcp/server.mjs.br.part-000 b/sdk/typescript/_bundled_plugin/mcp/server.mjs.br.part-000
index b08951c95..4b7c17cca 100644
Binary files a/sdk/typescript/_bundled_plugin/mcp/server.mjs.br.part-000 and b/sdk/typescript/_bundled_plugin/mcp/server.mjs.br.part-000 differ
diff --git a/sdk/typescript/_bundled_plugin/mcp/server.mjs.br.part-001 b/sdk/typescript/_bundled_plugin/mcp/server.mjs.br.part-001
index bb3c974d2..d280d00e6 100644
Binary files a/sdk/typescript/_bundled_plugin/mcp/server.mjs.br.part-001 and b/sdk/typescript/_bundled_plugin/mcp/server.mjs.br.part-001 differ
diff --git a/sdk/typescript/tests-ts/runtime.test.ts b/sdk/typescript/tests-ts/runtime.test.ts
index 69c0f1e5e..23d574948 100644
--- a/sdk/typescript/tests-ts/runtime.test.ts
+++ b/sdk/typescript/tests-ts/runtime.test.ts
@@ -73,7 +73,7 @@ import {
streamWindowsCredentialAclDescriptors,
verifyStableWindowsCredentialDescendants,
} from "../src/runtime.js";
-import { PLUGIN_ROOT } from "./plugin-root.js";
+import { loadBundledRuntime, PLUGIN_ROOT } from "./plugin-root.js";
import { runMockInSubprocess } from "./support/isolated-mock.js";
const temporaryDirectories: string[] = [];
@@ -225,6 +225,101 @@ describe("plugin runtime preparation", () => {
]);
});
+ test("disambiguates duplicate coverage surface identities without losing evidence", async () => {
+ const runtime = await loadBundledRuntime();
+ const source =
+ /function buildCoverage\(context, contract, semanticCoverage, scope, target\) \{[\s\S]*?\n\}/u.exec(
+ runtime,
+ )?.[0];
+ expect(source).toBeDefined();
+
+ type Surface = {
+ id?: string;
+ label: string;
+ disposition: string;
+ receiptRefs?: string[];
+ };
+ type Deferred = { id: string; reason: string; surfaceIds: string[] };
+ const buildCoverage = new Function(
+ "semanticIdentifier",
+ "coverageMode",
+ "inventoryStrategy",
+ `${source}\nreturn buildCoverage;`,
+ )(
+ (label: string) => label.toLowerCase(),
+ () => "deep_repository",
+ () => "repository",
+ ) as (
+ context: Record<string, unknown>,
+ contract: Record<string, unknown>,
+ coverage: { surfaces: Surface[]; deferred: Deferred[] },
+ scope: { includePaths: string[]; excludePaths: string[] },
+ target: Record<string, unknown>,
+ ) => {
+ surfaces: Array<Surface & { id: string; receiptRefs: string[] }>;
+ deferred: Deferred[];
+ };
+
+ const coverage = {
+ surfaces: [
+ {
+ id: "surface-web",
+ label: "Primary",
+ disposition: "reported",
+ receiptRefs: ["artifacts/primary.json"],
+ },
+ { id: "surface-web", label: "Secondary", disposition: "reported" },
+ {
+ id: "surface-web-2",
+ label: "Reserved suffix",
+ disposition: "no_issue_found",
+ },
+ { label: "Uploads", disposition: "reported" },
+ {
+ id: "surface_uploads",
+ label: "Owned uploads",
+ disposition: "reported",
+ },
+ { label: "Archive", disposition: "reported" },
+ { label: "Archive", disposition: "no_issue_found" },
+ ],
+ deferred: [
+ {
+ id: "deferred-review",
+ reason: "Environment unavailable",
+ surfaceIds: ["surface-web", "surface_uploads"],
+ },
+ ],
+ };
+ const original = structuredClone(coverage);
+ const canonical = buildCoverage(
+ { mode: "deep" },
+ {},
+ coverage,
+ { includePaths: ["."], excludePaths: [] },
+ {},
+ );
+
+ expect(canonical.surfaces.map((surface) => surface.id)).toEqual([
+ "surface-web",
+ "surface-web-3",
+ "surface-web-2",
+ "surface_uploads-2",
+ "surface_uploads",
+ "surface_archive",
+ "surface_archive-2",
+ ]);
+ expect(canonical.surfaces.map((surface) => surface.label)).toEqual(
+ coverage.surfaces.map((surface) => surface.label),
+ );
+ expect(canonical.surfaces[0]!.receiptRefs).toEqual([
+ "artifacts/primary.json",
+ ]);
+ expect(canonical.surfaces[1]!.receiptRefs).toEqual([]);
+ expect(canonical.deferred).toEqual(coverage.deferred);
+ expect(coverage).toEqual(original);
+ });
+
test("generates canonical scoped security inventory paths", async () => {
if (Bun.which("rg") === null) {
const generator = await readFile(