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: cover publication cancellation fallback and diagnose subprocess failures (#1929)
Michael D'Angelocb5195f9aa15
diff --git a/sdk/typescript/src/publish.ts b/sdk/typescript/src/publish.tsindex 2a5d75b43..7dcb2f5b8 100644--- a/sdk/typescript/src/publish.ts+++ b/sdk/typescript/src/publish.ts@@ -1612,7 +1612,7 @@ function forceTerminatePublicationProcess(terminatePublicationProcessGroup(child, "SIGKILL");}-function terminatePublicationProcessGroup(+export function terminatePublicationProcessGroup(child: ChildProcessWithoutNullStreams,signal: NodeJS.Signals,): void {diff --git a/sdk/typescript/tests-ts/auth.test.ts b/sdk/typescript/tests-ts/auth.test.tsindex 7151c7868..f99144769 100644--- a/sdk/typescript/tests-ts/auth.test.ts+++ b/sdk/typescript/tests-ts/auth.test.ts@@ -132,14 +132,13 @@ describe("Codex authentication process boundary", () => {const root = await temporaryDirectory("codex-security-auth-epipe-");const script = join(root, "exit.mjs");await writeFile(script, "process.exit(1);\n");- await expect(- runCodexCommand(- { command: process.execPath },- [script],- process.env,- "x".repeat(16 * 1024 * 1024),- ),- ).resolves.toMatchObject({ success: false, exitCode: 1 });+ const result = await runCodexCommand(+ { command: process.execPath },+ [script],+ process.env,+ "x".repeat(16 * 1024 * 1024),+ );+ expect(result).toMatchObject({ success: false, exitCode: 1 });});test("retains large noninteractive authentication output", async () => {diff --git a/sdk/typescript/tests-ts/package-tar-listing.test.ts b/sdk/typescript/tests-ts/package-tar-listing.test.tsindex ac8e73768..eb23566a3 100644--- a/sdk/typescript/tests-ts/package-tar-listing.test.ts+++ b/sdk/typescript/tests-ts/package-tar-listing.test.ts@@ -229,6 +229,7 @@ async function installPackage([...npm.args,"install",+ "--timing","--global=false","--prefix",consumer,diff --git a/sdk/typescript/tests-ts/publish.test.ts b/sdk/typescript/tests-ts/publish.test.tsindex 622e14ffc..3603a6aab 100644--- a/sdk/typescript/tests-ts/publish.test.ts+++ b/sdk/typescript/tests-ts/publish.test.ts@@ -5,6 +5,8 @@ import { resolving } from "./support/promises.js";import { runTestInSubprocess } from "./support/test-subprocess.js";import { nodeCommand } from "./support/shell.js";import { randomUUID } from "node:crypto";+import { spawn } from "node:child_process";+import { once } from "node:events";import * as filesystem from "node:fs/promises";import { CodexSecurityError } from "../src/errors.js";import {@@ -29,6 +31,7 @@ import { VERSION } from "../src/version.js";import {forceTerminatePublicationProcesses,publishScanInternal,+ terminatePublicationProcessGroup,type PublicationCodexResult,type PublishScanDependencies,type PublishScanOptions,@@ -3209,6 +3212,21 @@ describe("connected Linear publication", () => {expect(savedIssueIdentifiers).toEqual(["SEC-1"]);});+ test.skipIf(process.platform === "win32")(+ "signals the direct publication child when it has no process group of its own",+ async () => {+ const child = spawn(process.execPath, ["-e", "process.stdin.resume()"]);+ const closed = once(child, "close");+ try {+ terminatePublicationProcessGroup(child, "SIGTERM");+ } finally {+ child.stdin.end();+ }+ const [, signal] = await closed;+ expect(signal).toBe("SIGTERM");+ },+ );+test.each([["a promptly exiting parent", false, "SIGTERM", true],["a parent that ignores termination", true, "SIGTERM", false],