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

test: verify the installed SDK TypeScript contract (#507)

mldangelo-oai22a72a7c8d06
diff --git a/sdk/typescript/scripts/fixtures/package-consumer.ts b/sdk/typescript/scripts/fixtures/package-consumer.ts
new file mode 100644
index 000000000..293518017
--- /dev/null
+++ b/sdk/typescript/scripts/fixtures/package-consumer.ts
@@ -0,0 +1,33 @@
+import {
+ CodexSecurity,
+ DiffTarget,
+ estimateScanCost,
+ type ScanCost,
+ type ScanOptions,
+ type ScanProgress,
+ type ScanResult,
+} from "@openai/codex-security";
+
+const options: ScanOptions = {
+ target: DiffTarget.refs({ base: "HEAD~1" }),
+ onProgress(progress: ScanProgress) {
+ progress.filesCompleted satisfies number;
+ },
+};
+
+export async function scan(repository: string): Promise<ScanResult> {
+ const client = new CodexSecurity();
+ try {
+ return await client.run(repository, options);
+ } finally {
+ await client.close();
+ }
+}
+
+export const cost: ScanCost | null = estimateScanCost("gpt-5.6-sol", {
+ input_tokens: 10,
+ output_tokens: 2,
+});
+
+// @ts-expect-error The dependency-injection constructor is internal.
+new CodexSecurity({}, undefined as never, undefined as never);
diff --git a/sdk/typescript/scripts/smoke-package.mjs b/sdk/typescript/scripts/smoke-package.mjs
index 9c7307b6b..bafd80ff8 100644
--- a/sdk/typescript/scripts/smoke-package.mjs
+++ b/sdk/typescript/scripts/smoke-package.mjs
@@ -320,6 +320,8 @@ try {
"--no-audit",
"--no-fund",
archive,
+ `typescript@${packageManifest.devDependencies.typescript}`,
+ `@types/node@${packageManifest.devDependencies["@types/node"]}`,
],
{ cwd: consumer },
);
@@ -351,6 +353,29 @@ try {
{ cwd: consumer },
);
+ await cp(
+ join(packageRoot, "scripts", "fixtures", "package-consumer.ts"),
+ join(consumer, "consumer.ts"),
+ );
+ run(
+ process.execPath,
+ [
+ join(consumer, "node_modules", "typescript", "bin", "tsc"),
+ "--strict",
+ "--noEmit",
+ "--target",
+ "ES2022",
+ "--lib",
+ "ESNext",
+ "--module",
+ "NodeNext",
+ "--types",
+ "node",
+ "consumer.ts",
+ ],
+ { cwd: consumer },
+ );
+
assert.equal(
typeof installedManifest.bin?.["codex-security"],
"string",
@@ -496,7 +521,7 @@ try {
await smokeNestedDeepScanWorker(installedRoot, consumer);
console.log(
- `Validated installed ${packageManifest.name}@${packageManifest.version}: public import, CLI, ${expectedPluginFiles.length} bundled plugin files, bundled Codex version, and a nested worker without global codex.`,
+ `Validated installed ${packageManifest.name}@${packageManifest.version}: public import, NodeNext types, CLI, ${expectedPluginFiles.length} bundled plugin files, bundled Codex version, and a nested worker without global codex.`,
);
} finally {
await rm(consumer, {