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(cli): return pull request details for supplied-issue patches (#1645)

wjcfb2f912570e
diff --git a/sdk/typescript/src/cli.ts b/sdk/typescript/src/cli.ts
index 4b33620f6..07d1c4010 100644
--- a/sdk/typescript/src/cli.ts
+++ b/sdk/typescript/src/cli.ts
@@ -5418,9 +5418,10 @@ export async function main(
dependencies,
)
: undefined;
+ let pullRequest: { branch: string; url: string } | undefined;
if (options.createPr) {
const identifier = directPatchIdentifier(positionals, imports);
- await createPatchPullRequest(
+ pullRequest = await createPatchPullRequest(
repository,
identifier ?? directPatchDigest(positionals, imports),
files,
@@ -5436,6 +5437,7 @@ export async function main(
return {
...patchResult,
...(jsonOutput ? { report: report.text() } : {}),
+ ...(pullRequest === undefined ? {} : { pullRequest }),
};
} catch (error) {
if (exitCode === 0) exitCode = 2;
diff --git a/sdk/typescript/tests-ts/cli-patch.test.ts b/sdk/typescript/tests-ts/cli-patch.test.ts
index 693c5c804..8159999c6 100644
--- a/sdk/typescript/tests-ts/cli-patch.test.ts
+++ b/sdk/typescript/tests-ts/cli-patch.test.ts
@@ -893,6 +893,7 @@ describe("scan and patch workflow", () => {
"lin_api_SYNTHETIC",
"--assess-patch-risk",
"--create-pr",
+ "--json",
],
{
currentDirectory: repository,
@@ -980,6 +981,9 @@ describe("scan and patch workflow", () => {
]);
expect(outcome.stderr).toContain("Patch risk assessment:");
expect(outcome.stderr).toContain(`Pull request: ${url}`);
+ expect(JSON.parse(outcome.stdout)).toMatchObject({
+ pullRequest: { branch: "codex-security/patch-SEC-123", url },
+ });
expect(pullRequestArguments.at(-1)).not.toContain("schemaVersion");
expect(pullRequestArguments.at(-1)).not.toContain(
"codex-security:patch-risk-summary",