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

chore: simplify plugin tests and validation example (#1621)

Michael D'Angelo51d3a4d416cc
diff --git a/examples/custom-validation/validate.mts b/examples/custom-validation/validate.mts
index 68bfc378d..a72c907f1 100644
--- a/examples/custom-validation/validate.mts
+++ b/examples/custom-validation/validate.mts
@@ -3,7 +3,7 @@ import assert from "node:assert/strict";
import { mkdir, writeFile } from "node:fs/promises";
import type { AddressInfo } from "node:net";
import { dirname } from "node:path";
-import { parseArgs } from "node:util";
+import { parseArgs, promisify } from "node:util";
import { createServer } from "./app.mjs";
type HttpResult = {
@@ -64,9 +64,7 @@ async function main(): Promise<number> {
other_invoice.status === 200 && other_invoice.body.owner === "bob",
};
} finally {
- await new Promise<void>((resolve, reject) => {
- server.close((error) => (error ? reject(error) : resolve()));
- });
+ await promisify(server.close).call(server);
}
const proof = { ...evidence, server_stopped: true };
diff --git a/plugins/codex-security/tests/test_plugin_contract.py b/plugins/codex-security/tests/test_plugin_contract.py
index 838873c87..da6f5c977 100644
--- a/plugins/codex-security/tests/test_plugin_contract.py
+++ b/plugins/codex-security/tests/test_plugin_contract.py
@@ -18,21 +18,6 @@ def read_json(path: Path) -> dict[str, Any]:
return payload
-def read_yaml(path: Path) -> dict[str, Any]:
- payload = yaml.safe_load(path.read_text(encoding="utf-8"))
- assert isinstance(payload, dict), path
- return payload
-
-
-def read_skill_frontmatter(path: Path) -> dict[str, Any]:
- text = path.read_text(encoding="utf-8")
- match = re.match(r"\A---\n(.*?)\n---\n", text, re.DOTALL)
- assert match is not None, f"{path}: missing YAML frontmatter"
- payload = yaml.safe_load(match.group(1))
- assert isinstance(payload, dict), path
- return payload
-
-
def test_plugin_manifest_references_existing_assets_and_skills() -> None:
manifest = read_json(PLUGIN_ROOT / ".codex-plugin" / "plugin.json")
@@ -130,12 +115,17 @@ def test_every_skill_has_valid_frontmatter_and_agent_interface() -> None:
assert skill_path.is_file(), skill_path
assert agent_path.is_file(), agent_path
- frontmatter = read_skill_frontmatter(skill_path)
+ text = skill_path.read_text(encoding="utf-8")
+ match = re.match(r"\A---\n(.*?)\n---\n", text, re.DOTALL)
+ assert match is not None, f"{skill_path}: missing YAML frontmatter"
+ frontmatter = yaml.safe_load(match.group(1))
+ assert isinstance(frontmatter, dict), skill_path
assert set(frontmatter) == {"name", "description"}
assert frontmatter["name"] == skill_dir.name
assert isinstance(frontmatter["description"], str) and frontmatter["description"].strip()
- agent = read_yaml(agent_path)
+ agent = yaml.safe_load(agent_path.read_text(encoding="utf-8"))
+ assert isinstance(agent, dict), agent_path
interface = agent["interface"]
assert isinstance(interface, dict)
for field in ("display_name", "short_description", "default_prompt"):