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): display scan paths with trailing separators (#185)

Dipesh Babu97d2c83b6e47
diff --git a/sdk/typescript/src/cli.ts b/sdk/typescript/src/cli.ts
index 19a79398c..ab30d913a 100644
--- a/sdk/typescript/src/cli.ts
+++ b/sdk/typescript/src/cli.ts
@@ -5742,7 +5742,7 @@ function scanScope(arguments_: ScanArguments): string | null {
isAbsolute(path) ||
/^[A-Za-z]:\//u.test(portable) ||
portable.startsWith("//")
- ? portable.split("/").at(-1) ?? portable
+ ? basename(portable) || portable
: portable;
return errorMessage(scoped.replaceAll(/[\u0000-\u001F\u007F]/gu, " "));
});
diff --git a/sdk/typescript/tests-ts/cli.test.ts b/sdk/typescript/tests-ts/cli.test.ts
index 7a8517e1c..3960008f6 100644
--- a/sdk/typescript/tests-ts/cli.test.ts
+++ b/sdk/typescript/tests-ts/cli.test.ts
@@ -4575,6 +4575,29 @@ describe("CLI", () => {
expect(stderr.text()).not.toContain("% complete");
});
+ test("preserves directory names for absolute scan paths with trailing separators", async () => {
+ const stdout = capture();
+ const stderr = capture();
+
+ expect(
+ await main(
+ [
+ "scan",
+ ".",
+ "--path",
+ "/synthetic-parent/trailing-directory/",
+ "--json",
+ ],
+ stdout.stream,
+ stderr.stream,
+ dependencies(),
+ ),
+ ).toBe(0);
+ expect(JSON.parse(stdout.text())).toEqual(fakeResult().toJSON());
+ expect(stderr.text()).toContain("Running scan: trailing-directory");
+ expect(stderr.text()).not.toContain("synthetic-parent");
+ });
+
test("shows live stage, files, workers, tokens, and cost without a budget", async () => {
const stdout = capture();
const stderr = capture();