OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
fix(threat-model): show non-string legacy origins as not recorded (#1802)
wj9bb3673e5b8f
diff --git a/plugins/codex-security/scripts/threat_model_projection.py b/plugins/codex-security/scripts/threat_model_projection.pyindex 7b428aee2..8f21780b9 100644--- a/plugins/codex-security/scripts/threat_model_projection.py+++ b/plugins/codex-security/scripts/threat_model_projection.py@@ -129,9 +129,7 @@ def render_threat_model(model: dict[str, Any], provenance: dict[str, Any] | None):if provenance.get(key):footer.append(f"- {label}: {text(str(provenance[key]), 'not recorded')}")- footer.append(- f"- Model origin: {text(str(model.get('origin', 'not recorded')), 'not recorded')}"- )+ footer.append(f"- Model origin: {text(model.get('origin'), 'not recorded')}")footer.extend(_scope_lines(model.get("scope"), "Model scope", text))scan_scope = provenance.get("scanScope")if isinstance(scan_scope, dict):diff --git a/plugins/codex-security/tests/test_threat_model_projection.py b/plugins/codex-security/tests/test_threat_model_projection.pyindex 3482cb26c..ecbf721e9 100644--- a/plugins/codex-security/tests/test_threat_model_projection.py+++ b/plugins/codex-security/tests/test_threat_model_projection.py@@ -81,12 +81,16 @@ class ThreatModelProjectionTest(ScanFixtureTestCase):self.assertIn(b"Service boundaries.", document)def test_exports_legacy_structured_model_extensions(self) -> None:- for extensions in (- {"format": "markdown"},- {"format": "markdown", "content": " \n"},- {"scope": "Repository-wide", "origin": "legacy-import"},- {"scope": {"includePaths": 42}, "origin": {"tool": "legacy"}},- {"scope": {"includePaths": ["src"], "excludePaths": 42, "summary": []}},+ for extensions, expected_origin in (+ ({"format": "markdown"}, "not recorded"),+ ({"format": "markdown", "content": " \n"}, "not recorded"),+ ({"scope": "Repository-wide", "origin": "legacy-import"}, "legacy-import"),+ ({"scope": {"includePaths": 42}, "origin": {"tool": "legacy"}}, "not recorded"),+ (+ {"scope": {"includePaths": ["src"], "excludePaths": 42, "summary": []}},+ "not recorded",+ ),+ ({"origin": ["generated"]}, "not recorded"),):with self.subTest(extensions=extensions):model = {"summary": "Existing structured model.", **extensions}@@ -94,10 +98,10 @@ class ThreatModelProjectionTest(ScanFixtureTestCase):self.write_scan()FINALIZER.finalize_scan(self.scan_dir)self.assertEqual(self.read_json("scan-manifest.json")["scan"]["threatModel"], model)- self.assertIn(- b"Existing structured model.",- FINALIZER.build_threat_model_export(self.scan_dir),- )+ document = FINALIZER.build_threat_model_export(self.scan_dir)+ self.assertIn(b"Existing structured model.", document)+ self.assertIn(f"- Model origin: {expected_origin}".encode(), document.splitlines())+ self.assertEqual((self.scan_dir / "threatmodel.md").read_bytes(), document)self.assertEqual(FINALIZER.build_findings_export(self.scan_dir, "json"),(self.scan_dir / "findings.json").read_bytes(),@@ -117,11 +121,14 @@ class ThreatModelProjectionTest(ScanFixtureTestCase):def test_exports_legacy_metadata_with_markdown_content(self) -> None:body = "# Saved model\n\nKeep **authored** detail.\n"- for metadata in (- {"origin": "legacy-import", "scope": "Repository-wide"},- {"origin": {"tool": "legacy"}, "scope": {"includePaths": 42}},- {"origin": None, "scope": None},- {"scope": {"includePaths": ["src"], "excludePaths": 42, "summary": []}},+ for metadata, expected_origin in (+ ({"origin": "legacy-import", "scope": "Repository-wide"}, "legacy-import"),+ ({"origin": {"tool": "legacy"}, "scope": {"includePaths": 42}}, "not recorded"),+ ({"origin": None, "scope": None}, "not recorded"),+ (+ {"scope": {"includePaths": ["src"], "excludePaths": 42, "summary": []}},+ "not recorded",+ ),):with self.subTest(metadata=metadata):model = {@@ -139,6 +146,8 @@ class ThreatModelProjectionTest(ScanFixtureTestCase):document = FINALIZER.build_threat_model_export(self.scan_dir)self.assertTrue(document.startswith(body.encode()))self.assertNotIn(b"Existing structured model.", document)+ self.assertIn(f"- Model origin: {expected_origin}".encode(), document.splitlines())+ self.assertEqual((self.scan_dir / "threatmodel.md").read_bytes(), document)self.assertEqual(FINALIZER.describe_threat_model(self.scan_dir)["threatModel"], model)