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(sdk): isolate rejected publication progress callbacks (#2203)

Michael D'Angelo51b6fd886345
diff --git a/sdk/typescript/src/external-findings-publish.ts b/sdk/typescript/src/external-findings-publish.ts
index bf428e081..7018606f3 100644
--- a/sdk/typescript/src/external-findings-publish.ts
+++ b/sdk/typescript/src/external-findings-publish.ts
@@ -31,6 +31,7 @@ import {
type ExternalFindingsReaderOptions,
} from "./external-findings-read.js";
import { canonicalJson } from "./record.js";
+import { notify } from "./value.js";
import { wizCsvRepositoryUrl } from "./wiz-csv.js";
import { wizFindingRepository } from "./wiz-findings.js";
import { dependabotRepository } from "./github-dependabot-findings.js";
@@ -446,13 +447,8 @@ async function preparePublicationInput(
dependencies: ExternalPublicationDependencies,
): Promise<PreparedExternalPublication> {
const { inspectorProjectMap } = options;
- const progress = (event: ExternalPublicationProgress): void => {
- try {
- dependencies.onProgress?.(event);
- } catch {
- // Optional progress must not interrupt preparation or publication.
- }
- };
+ const progress = (event: ExternalPublicationProgress): void =>
+ notify(() => dependencies.onProgress?.(event));
if (
!options.sourceKey.trim() ||
options.sourceKey.includes("\0") ||
diff --git a/sdk/typescript/tests-ts/external-findings-publish.test.ts b/sdk/typescript/tests-ts/external-findings-publish.test.ts
index 210dedb16..5375ffc8b 100644
--- a/sdk/typescript/tests-ts/external-findings-publish.test.ts
+++ b/sdk/typescript/tests-ts/external-findings-publish.test.ts
@@ -3731,13 +3731,25 @@ test("read lookups and verification run concurrently with bounded requests and o
test("progress is optional and stderr progress never corrupts JSON results", async () => {
const f = await fixture();
+ const phases = new Set<ExternalPublicationProgress["phase"]>();
const prepared = await prepareExternalPublication(f.file, options, {
...f.deps,
- onProgress: () => {
+ onProgress: ({ phase }) => {
+ phases.add(phase);
+ if (phase === "reading")
+ return Promise.reject(new Error("Optional async observer failed"));
throw new Error("Optional observer failed");
},
});
expect((await prepared.publish()).status).toBe("complete");
+ expect([...phases]).toEqual([
+ "reading",
+ "discovering",
+ "preparing",
+ "waiting",
+ "uploading",
+ "verifying",
+ ]);
const cli = createCliTest(main, { stderr: true });
expect(await cli.runCli([...f.command, "--yes"], f.cliDeps)).toBe(0);
expect(JSON.parse(cli.stdout.text())).toMatchObject({