Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/typescript/tests-ts/cli-launcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ describe("CLI launcher", () => {
);
expect(build.error).toBeUndefined();
expect(build.status).toBe(0);
expect(build.stderr).toBe("");

expect(await readFile(join(dist, "cli.js"), "utf8")).toContain(
'from "./api.js"',
Expand Down
96 changes: 1 addition & 95 deletions sdk/typescript/tests-ts/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { execFileSync, spawnSync } from "node:child_process";
import {
copyFile,
mkdir,
mkdtemp,
readFile,
realpath,
rm,
stat,
symlink,
writeFile,
} from "node:fs/promises";
import { tmpdir } from "node:os";
import { delimiter, join, normalize } from "node:path";
import { Writable } from "node:stream";
import { fileURLToPath, pathToFileURL } from "node:url";
import { fileURLToPath } from "node:url";
import { stripVTControlCharacters } from "node:util";
import { describe, expect, test } from "bun:test";
import { parse as parseToml } from "smol-toml";
Expand Down Expand Up @@ -1853,98 +1851,6 @@ describe("CLI", () => {
expect(stderr.text()).toBe("");
});

test("runs split TypeScript output from an npm-style bin when Node preserves main symlinks", async () => {
const root = await mkdtemp(join(tmpdir(), "codex-security-cli-node-bin-"));
try {
const source = join(import.meta.dir, "..");
const installed = join(root, "node_modules", "@openai", "codex-security");
const dist = join(installed, "dist");
const build = spawnSync(
"node",
[
join(source, "node_modules", "typescript", "bin", "tsc"),
"-p",
join(source, "tsconfig.build.json"),
"--outDir",
dist,
"--pretty",
"false",
],
{ encoding: "utf8", cwd: source },
);
expect(build.status).toBe(0);
expect(build.stderr).toBe("");
expect(await readFile(join(dist, "cli.js"), "utf8")).toContain(
'from "./api.js"',
);
const launcher = join(installed, "bin", "codex-security.mjs");
await mkdir(join(installed, "bin"), { recursive: true });
await copyFile(join(source, "bin", "codex-security.mjs"), launcher);
await copyFile(
join(source, "package.json"),
join(installed, "package.json"),
);
await symlink(
join(source, "node_modules"),
join(installed, "node_modules"),
"dir",
);
const binDirectory = join(root, "node_modules", ".bin");
await mkdir(binDirectory, { recursive: true });
const bin = join(binDirectory, "codex-security");
await symlink(launcher, bin);
const child = spawnSync("node", [bin, "--version"], {
encoding: "utf8",
env: {
...process.env,
NODE_OPTIONS:
"--preserve-symlinks-main --no-experimental-detect-module",
NODE_USE_ENV_PROXY: undefined,
},
});
expect(child.status).toBe(0);
expect(child.stderr).toBe("");
expect(child.stdout).toBe(`${VERSION}\n`);

const preload = join(root, "unavailable-cwd.mjs");
await writeFile(
preload,
[
"const originalCwd = process.cwd;",
'Object.defineProperty(process, "cwd", {',
" value() {",
' if (/[\\\\/]dist[\\\\/]cli\\.js:/u.test(new Error().stack ?? "")) {',
' throw new Error("working directory is unavailable");',
" }",
" return originalCwd.call(process);",
" },",
"});\n",
].join("\n"),
);
const failed = spawnSync(
"node",
["--import", pathToFileURL(preload).href, bin, "scan"],
{
encoding: "utf8",
env: {
...process.env,
NODE_OPTIONS:
"--preserve-symlinks-main --no-experimental-detect-module",
NODE_USE_ENV_PROXY: undefined,
},
timeout: 30_000,
},
);
expect([failed.status, failed.stdout, failed.stderr]).toEqual([
2,
"",
"working directory is unavailable\n",
]);
} finally {
await rm(root, { recursive: true, force: true });
}
}, 30_000);

test("uses Incur version and command help", async () => {
const version = capture();
const stderr = capture();
Expand Down
27 changes: 0 additions & 27 deletions sdk/typescript/tests-ts/runtime.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1890,33 +1890,6 @@ describe("runtime directories and plugin Python boundary", () => {
},
);

testPosix("rejects sticky shared parents controlled by another user", () => {
expect(() =>
requireTrustedOutputAncestor(
{ mode: 0o41777, uid: 1001 },
"/shared",
1000,
),
).toThrow("trusted owner");
expect(() =>
requireTrustedOutputAncestor(
{ mode: 0o40755, uid: 1001 },
"/shared",
1000,
),
).toThrow("trusted owner");
expect(() =>
requireTrustedOutputAncestor(
{ mode: 0o41777, uid: 1000 },
"/shared",
1000,
),
).not.toThrow();
expect(() =>
requireTrustedOutputAncestor({ mode: 0o41777, uid: 0 }, "/tmp", 1000),
).not.toThrow();
});

testPosix(
"rejects a credential home that is no longer private to the current user",
async () => {
Expand Down
Loading