OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
fix(owners): match scan owner hints across email case variants
wj59a9fdb5ef83
diff --git a/sdk/typescript/src/suggest-owners.ts b/sdk/typescript/src/suggest-owners.tsindex 424865a18..31ffcd8db 100644--- a/sdk/typescript/src/suggest-owners.ts+++ b/sdk/typescript/src/suggest-owners.ts@@ -230,15 +230,20 @@ export async function suggestOwnersFromScan(const hint = z.object({ email: text, commit: text, reason: text }).parse(value);+ const supports = (item: OwnerEvidence) =>+ item.kind === "blame"+ ? item.blameCommit === hint.commit+ : item.commit === hint.commit;+ // Git keeps emails that differ only in case as separate identities.const identityIndex = context.identities.findIndex(- (identity) => identity.email.toLowerCase() === hint.email.toLowerCase(),+ (identity, index) =>+ identity.email.toLowerCase() === hint.email.toLowerCase() &&+ context.evidence.some(+ (item) => item.identityIndex === index && supports(item),+ ),);const cited = context.evidence.filter(- (item) =>- item.identityIndex === identityIndex &&- (item.kind === "blame"- ? item.blameCommit === hint.commit- : item.commit === hint.commit),+ (item) => item.identityIndex === identityIndex && supports(item),);if (identityIndex < 0 || cited.length === 0)throw new CodexSecurityError(diff --git a/sdk/typescript/tests-ts/suggest-owners.test.ts b/sdk/typescript/tests-ts/suggest-owners.test.tsindex eca38a07e..601efb0d1 100644--- a/sdk/typescript/tests-ts/suggest-owners.test.ts+++ b/sdk/typescript/tests-ts/suggest-owners.test.ts@@ -582,6 +582,45 @@ test.each(["author", "checkout"] as const)(},);+test("scan hints match the cited commit when Git emails differ in case", async () => {+ const repo = await repository();+ await writeFile(+ join(repo.path, "handler.ts"),+ "// Record access\nexport function readRecord(id) {\n return records.get(id);\n}\n",+ );+ await repo.git(+ "-c",+ "[email protected]",+ "commit",+ "-qam",+ "Use a record map",+ );+ const revision = await repo.git("rev-parse", "HEAD");+ const { codex, calls } = fakeCodex();+ const report = await suggestOwnersFromScan(+ repo.path,+ [+ {+ ...finding,+ sourceRevision: revision,+ extensions: {+ ownerSuggestion: {+ email: "[email protected]",+ commit: revision,+ reason: "Alex changed the affected record lookup.",+ },+ },+ },+ ],+ { codex },+ );+ expect(calls).toHaveLength(0);+ expect(report.results[0]).toMatchObject({+ status: "identified",+ owner: { name: "Alex Example", email: "[email protected]" },+ });+});+test("rejects invented identities and citations and preserves later results", async () => {const repo = await repository();const invalid: ((context: OwnerContext) => unknown)[] = [