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

ci: fix image pull failures and Windows diagnostic test (#1641)

Michael D'Angelo9b0379b22922
diff --git a/.github/workflows/native-musl.yml b/.github/workflows/native-musl.yml
index 0ef5e1e1c..e8978fb36 100644
--- a/.github/workflows/native-musl.yml
+++ b/.github/workflows/native-musl.yml
@@ -46,6 +46,16 @@ jobs:
run: |
rustup toolchain install 1.97.1 --profile minimal
cargo +1.97.1 fetch --locked
+ - name: Pull pinned musl images
+ run: |
+ for image_variable in RUST_IMAGE NODE22_IMAGE NODE20_IMAGE; do
+ native_image="${!image_variable}"
+ if ! docker pull "$native_image"; then
+ native_image="docker.io/library/${native_image#public.ecr.aws/docker/library/}"
+ docker pull "$native_image"
+ fi
+ printf '%s=%s\n' "$image_variable" "$native_image" >> "$GITHUB_ENV"
+ done
- name: Assemble pinned musl compiler image
run: |
docker build --network none \
diff --git a/sdk/typescript/tests-ts/cli-project-config.test.ts b/sdk/typescript/tests-ts/cli-project-config.test.ts
index 591a735e0..36e46ae6a 100644
--- a/sdk/typescript/tests-ts/cli-project-config.test.ts
+++ b/sdk/typescript/tests-ts/cli-project-config.test.ts
@@ -1260,7 +1260,7 @@ test.each(["yaml", "toon", "json"])(
const missing = join(
root,
"a-directory-name-long-enough-to-make-yaml-fold-the-line",
- "scan.yaml",
+ "nested\\scan.yaml",
);
const { stderr, runCli } = createCliTest(main);
expect(
@@ -1269,6 +1269,10 @@ test.each(["yaml", "toon", "json"])(
dependencies({ currentDirectory: root }),
),
).toBe(2);
- expect(stderr.text()).toContain(missing);
+ const message =
+ format === "json"
+ ? JSON.parse(stderr.text().replace(/^codex-security: /u, "")).message
+ : stderr.text();
+ expect(message).toContain(missing);
},
);
diff --git a/sdk/typescript/tests-ts/workflow-quality.test.ts b/sdk/typescript/tests-ts/workflow-quality.test.ts
index e58921b3b..6b81be85e 100644
--- a/sdk/typescript/tests-ts/workflow-quality.test.ts
+++ b/sdk/typescript/tests-ts/workflow-quality.test.ts
@@ -19,6 +19,29 @@ const ci = Bun.YAML.parse(
>;
};
+const musl = Bun.YAML.parse(
+ await readFile(
+ new URL("../../../.github/workflows/native-musl.yml", import.meta.url),
+ "utf8",
+ ),
+) as {
+ jobs: {
+ primitives: {
+ strategy: {
+ matrix: {
+ include: {
+ arch: string;
+ "rust-image": string;
+ "node22-image": string;
+ "node20-image": string;
+ }[];
+ };
+ };
+ steps: { name: string; run: string }[];
+ };
+ };
+};
+
// These scripts run in Ubuntu Bash in CI, independent of the CLI platform.
const bashTest = test.skipIf(process.platform === "win32");
@@ -82,6 +105,104 @@ bashTest(
},
);
+for (const target of musl.jobs.primitives.strategy.matrix.include) {
+ for (const scenario of ["ecr-success", "ecr-failure", "both-fail"] as const) {
+ bashTest(`musl ${target.arch} image pulls: ${scenario}`, async () => {
+ const directory = await mkdtemp(join(tmpdir(), "musl-image-pulls-"));
+ const environment = join(directory, "environment");
+ const dockerLog = join(directory, "docker-log");
+ const images = {
+ RUST_IMAGE: target["rust-image"],
+ NODE22_IMAGE: target["node22-image"],
+ NODE20_IMAGE: target["node20-image"],
+ };
+ const run = (name: string) =>
+ musl.jobs.primitives.steps.find((step) => step.name === name)!.run;
+ try {
+ const result = spawnSync(
+ "bash",
+ [
+ "-e",
+ "-c",
+ `
+ : > "$GITHUB_ENV"
+ : > "$DOCKER_LOG"
+ docker() {
+ printf '%s\\n' "$*" >> "$DOCKER_LOG"
+ case "$1:$2" in
+ pull:public.ecr.aws/*) [[ "$PULL_SCENARIO" == ecr-success ]] ;;
+ pull:docker.io/*) [[ "$PULL_SCENARIO" != both-fail ]] ;;
+ *) return 0 ;;
+ esac
+ }
+ ${run("Pull pinned musl images")}
+ source "$GITHUB_ENV"
+ ${run("Assemble pinned musl compiler image")}
+ ${run("Verify the same artifact with Node.js 22 and 20")}
+ `,
+ ],
+ {
+ encoding: "utf8",
+ env: {
+ ...process.env,
+ ...images,
+ GITHUB_ENV: environment,
+ DOCKER_LOG: dockerLog,
+ PULL_SCENARIO: scenario,
+ },
+ },
+ );
+ const calls = (await readFile(dockerLog, "utf8")).trim().split("\n");
+ const selectedEnvironment = await readFile(environment, "utf8");
+ const fallback = (image: string) =>
+ image.replace("public.ecr.aws/docker/library/", "docker.io/library/");
+ if (scenario === "both-fail") {
+ expect(result.status, result.stderr).toBe(1);
+ expect(calls).toEqual([
+ `pull ${images.RUST_IMAGE}`,
+ `pull ${fallback(images.RUST_IMAGE)}`,
+ ]);
+ expect(selectedEnvironment).toBe("");
+ return;
+ }
+
+ expect(result.status, result.stderr).toBe(0);
+ const selected = Object.fromEntries(
+ Object.entries(images).map(([name, image]) => [
+ name,
+ scenario === "ecr-failure" ? fallback(image) : image,
+ ]),
+ );
+ expect(selectedEnvironment).toBe(
+ Object.entries(selected)
+ .map(([name, image]) => `${name}=${image}\n`)
+ .join(""),
+ );
+ expect(calls.filter((call) => call.startsWith("pull "))).toEqual(
+ Object.values(images).flatMap((image) =>
+ scenario === "ecr-failure"
+ ? [`pull ${image}`, `pull ${fallback(image)}`]
+ : [`pull ${image}`],
+ ),
+ );
+ const build = calls.find((call) => call.startsWith("build "))!;
+ expect(build).toContain(
+ `--build-arg RUST_IMAGE=${selected["RUST_IMAGE"]}`,
+ );
+ expect(build).toContain(
+ `--build-arg NODE_IMAGE=${selected["NODE22_IMAGE"]}`,
+ );
+ const runs = calls.filter((call) => call.startsWith("run "));
+ expect(runs).toHaveLength(2);
+ expect(runs[0]).toContain(`${selected["NODE22_IMAGE"]} /bin/sh`);
+ expect(runs[1]).toContain(`${selected["NODE20_IMAGE"]} /bin/sh`);
+ } finally {
+ await rm(directory, { recursive: true, force: true });
+ }
+ });
+ }
+}
+
bashTest(
"required Unix checks fail when selected workflow checks do not pass",
() => {