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): pass severity record efforts through to the host (#1842)

Lanre Shittu021f6a68ab1f
diff --git a/sdk/typescript/docs/classify-severity-records.md b/sdk/typescript/docs/classify-severity-records.md
index 01426b2bf..c3257bf85 100644
--- a/sdk/typescript/docs/classify-severity-records.md
+++ b/sdk/typescript/docs/classify-severity-records.md
@@ -58,7 +58,8 @@ an integer from 1 through 10 (default: 3), validated before any host work.
For each record the CLI emits that many sequential `method: "review.run"` requests,
each with a unique request ID and params containing `requestId`, `stage: "severity-classification"`, explicit
`model` and `effort`, `trustedInstructions`, untrusted report/rubric `prompt`, and
-an output JSON `schema`. The host must authorize the requested model and effort,
+an output JSON `schema`. The SDK and CLI forward the `effort` string unchanged.
+The host must authorize the requested model and effort,
create a fresh independent review context, preserve the instruction/data boundary,
and disable tools, repository access, browsing, and source inspection.
A managed-agent host can execute this request directly in its existing session
diff --git a/sdk/typescript/src/classify-severity-records.ts b/sdk/typescript/src/classify-severity-records.ts
index f881a01ff..609f0c3c7 100644
--- a/sdk/typescript/src/classify-severity-records.ts
+++ b/sdk/typescript/src/classify-severity-records.ts
@@ -46,15 +46,7 @@ export const classifySeverityRecordsInputSchema = z
version: z.literal(1),
rubric: severityRubricSnapshotSchema.optional(),
model: text,
- effort: z.enum([
- "minimal",
- "low",
- "medium",
- "high",
- "xhigh",
- "max",
- "ultra",
- ]),
+ effort: z.string(),
records: z.array(
z
.object({
diff --git a/sdk/typescript/tests-ts/classify-severity-records.test.ts b/sdk/typescript/tests-ts/classify-severity-records.test.ts
index dc157b5ee..e63d7981a 100644
--- a/sdk/typescript/tests-ts/classify-severity-records.test.ts
+++ b/sdk/typescript/tests-ts/classify-severity-records.test.ts
@@ -12,7 +12,7 @@ import { capture, dependencies } from "./cli-fixtures.js";
const hash = (value: string) =>
createHash("sha256").update(value, "utf8").digest("hex");
-function input(): ClassifySeverityRecordsInput & {
+function input(effort = "high"): ClassifySeverityRecordsInput & {
rubric: NonNullable<ClassifySeverityRecordsInput["rubric"]>;
} {
const markdown =
@@ -23,7 +23,7 @@ function input(): ClassifySeverityRecordsInput & {
version: 1,
rubric: { revision: 4, markdown, sha256: hash(markdown) },
model: "synthetic-model",
- effort: "high",
+ effort,
records: [
{
id: "canonical-one",
@@ -46,8 +46,9 @@ function answer(request: SeverityClassificationReviewRequest) {
};
}
-test("binds assessments to exact UTF-8 snapshots without rewriting the original report", async () => {
- const original = input();
+const efforts = ["", "\t", " synthetic-effort "];
+test.each(efforts)("preserves UTF-8 records and effort %p", async (effort) => {
+ const original = input(effort);
const before = structuredClone(original);
const requests: SeverityClassificationReviewRequest[] = [];
const result = await classifySeverityRecords(original, {
@@ -55,7 +56,7 @@ test("binds assessments to exact UTF-8 snapshots without rewriting the original
async run(request) {
requests.push(request);
expect(request.model).toBe(original.model);
- expect(request.effort).toBe("high");
+ expect(request.effort).toBe(original.effort);
expect(JSON.parse(request.prompt).rubric).toEqual([
original.rubric.markdown,
]);
@@ -89,6 +90,8 @@ test("binds assessments to exact UTF-8 snapshots without rewriting the original
});
test.each([
+ "missing-effort",
+ "numeric-effort",
"rubric-hash",
"finding-hash",
"duplicate",
@@ -99,6 +102,8 @@ test.each([
"unsafe-revision",
])("rejects %s before any host work", async (scenario) => {
const data = input();
+ if (scenario === "missing-effort") Reflect.deleteProperty(data, "effort");
+ if (scenario === "numeric-effort") Reflect.set(data, "effort", 1);
if (scenario === "rubric-hash") data.rubric.markdown += " ";
if (scenario === "finding-hash") data.records[0]!.findingJson += " ";
if (scenario === "duplicate") data.records.push(data.records[0]!);
@@ -296,7 +301,7 @@ test.each([
capture().stream,
deps,
);
- const params: ClassifySeverityRecordsInput = input();
+ const params: ClassifySeverityRecordsInput = input("none");
if (scenario === "default-rubric") delete params.rubric;
const completed = [
"completed",