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
test(findings): share model response and finding identity setup (#1406)
mldangelo-oaic82116c27865
diff --git a/sdk/typescript/tests-ts/classify-severity.test.ts b/sdk/typescript/tests-ts/classify-severity.test.tsindex 3111de2cd..b972a4aa1 100644--- a/sdk/typescript/tests-ts/classify-severity.test.ts+++ b/sdk/typescript/tests-ts/classify-severity.test.ts@@ -1,3 +1,4 @@+import { modelResponseText } from "./support/model-response-text.js";import { writeFile } from "node:fs/promises";import { join } from "node:path";import type { ThreadOptions, TurnOptions } from "@openai/codex-sdk";@@ -52,12 +53,7 @@ function fakeCodex(response: unknown) {return {async run(prompt, turn) {calls.push({ prompt, thread, turn });- return {- finalResponse:- typeof response === "string"- ? response- : JSON.stringify(response),- };+ return { finalResponse: modelResponseText(response) };},};},diff --git a/sdk/typescript/tests-ts/finding-workflow-integration.test.ts b/sdk/typescript/tests-ts/finding-workflow-integration.test.tsindex d8c2f57b4..34a9649cd 100644--- a/sdk/typescript/tests-ts/finding-workflow-integration.test.ts+++ b/sdk/typescript/tests-ts/finding-workflow-integration.test.ts@@ -1,4 +1,4 @@-import { findingFingerprint, sha256 } from "./support/finding-identity.js";+import { setFindingIdentity, sha256 } from "./support/finding-identity.js";import { resolving } from "./support/promises.js";import { execFileSync, spawn } from "node:child_process";import { once } from "node:events";@@ -85,17 +85,9 @@ async function fixtureWithFindings(count: number) {document.findings = Array.from({ length: count }, (_value, index) => {const finding = structuredClone(document.findings[0]!);finding.identity.instance = `concurrent-${index}`;- const fingerprint = findingFingerprint(- manifest.scan.target.targetId,- finding,- );- return {- ...finding,- findingId: `csf_${sha256(fingerprint).slice(0, 24)}`,- occurrenceId: `occ_${sha256([document.scanId, fingerprint].join("\0")).slice(0, 24)}`,- fingerprints: { ...finding.fingerprints, primary: fingerprint },- title: `Synthetic concurrent finding ${index}`,- };+ setFindingIdentity({ ...manifest.scan, id: document.scanId }, finding);+ finding.title = `Synthetic concurrent finding ${index}`;+ return finding;});const content = JSON.stringify(document);await writeFile(join(scanDir, "findings.json"), content);diff --git a/sdk/typescript/tests-ts/scan-comparison.test.ts b/sdk/typescript/tests-ts/scan-comparison.test.tsindex 8b34c998f..60f6fbbee 100644--- a/sdk/typescript/tests-ts/scan-comparison.test.ts+++ b/sdk/typescript/tests-ts/scan-comparison.test.ts@@ -1,3 +1,4 @@+import { modelResponseText } from "./support/model-response-text.js";import { once } from "node:events";import {copyFile,@@ -78,12 +79,7 @@ function fakeCodex(response: unknown) {async run(prompt, turnOptions) {calls.prompt = prompt;calls.turnOptions = turnOptions;- return {- finalResponse:- typeof response === "string"- ? response- : JSON.stringify(response),- };+ return { finalResponse: modelResponseText(response) };},};},diff --git a/sdk/typescript/tests-ts/suggest-owners.test.ts b/sdk/typescript/tests-ts/suggest-owners.test.tsindex 700772a2f..5c2e5d6aa 100644--- a/sdk/typescript/tests-ts/suggest-owners.test.ts+++ b/sdk/typescript/tests-ts/suggest-owners.test.ts@@ -1,3 +1,4 @@+import { modelResponseText } from "./support/model-response-text.js";import { execFile as execFileCallback } from "node:child_process";import { cp, mkdir, readFile, rm, symlink, writeFile } from "node:fs/promises";import { join, relative } from "node:path";@@ -71,10 +72,7 @@ function fakeCodex(decide: (context: OwnerContext) => unknown = chooseAlex) {) as OwnerContext;calls.push({ context, thread, turn });const result = decide(context);- return {- finalResponse:- typeof result === "string" ? result : JSON.stringify(result),- };+ return { finalResponse: modelResponseText(result) };},};},diff --git a/sdk/typescript/tests-ts/support/model-response-text.ts b/sdk/typescript/tests-ts/support/model-response-text.tsnew file mode 100644index 000000000..84f814284--- /dev/null+++ b/sdk/typescript/tests-ts/support/model-response-text.ts@@ -0,0 +1,3 @@+export function modelResponseText(response: unknown) {+ return typeof response === "string" ? response : JSON.stringify(response);+}