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(plugin): include Objective-C sources in scan inventories (#989)

abhijeet sharmacce82310321a
diff --git a/plugins/codex-security/scripts/rank_preview.py b/plugins/codex-security/scripts/rank_preview.py
index 2963a037e..cf335fd58 100644
--- a/plugins/codex-security/scripts/rank_preview.py
+++ b/plugins/codex-security/scripts/rank_preview.py
@@ -42,6 +42,7 @@ TEXT_CODE_EXTENSIONS = {
".kt",
".kts",
".lua",
+ ".m",
".mjs",
".mm",
".mts",
diff --git a/plugins/codex-security/tests/test_generate_in_scope_files.py b/plugins/codex-security/tests/test_generate_in_scope_files.py
index c27d03d5d..4e05cdf95 100644
--- a/plugins/codex-security/tests/test_generate_in_scope_files.py
+++ b/plugins/codex-security/tests/test_generate_in_scope_files.py
@@ -431,6 +431,35 @@ def test_diff_inventory_includes_changed_terraform(tmp_path: Path, mode: str) ->
assert output.read_text(encoding="utf-8") == "infra/main.tf\n"
[email protected]("mode", ["revisions", "local-patch"])
+def test_diff_inventory_includes_changed_objective_c(tmp_path: Path, mode: str) -> None:
+ repository = make_repository(tmp_path)
+ sources = {
+ "ios/Bridge.mm": b"@implementation Bridge\n@end\n",
+ "ios/ViewController.h": b"@interface ViewController : NSObject\n@end\n",
+ "ios/ViewController.m": b"@implementation ViewController\n@end\n",
+ }
+ for name, source in sources.items():
+ write_file(repository, name, source)
+ git(repository, "add", ".")
+ git(repository, "commit", "-qm", "base")
+ base = git(repository, "rev-parse", "HEAD")
+ for name, source in sources.items():
+ write_file(repository, name, source + b"// Changed.\n")
+ arguments = ["--diff-base", base, "--diff-mode", mode]
+ if mode == "revisions":
+ git(repository, "add", ".")
+ git(repository, "commit", "-qm", "change")
+ arguments.extend(["--diff-head", git(repository, "rev-parse", "HEAD")])
+ git(repository, "checkout", "-q", base)
+ output = tmp_path / "in_scope_files.txt"
+
+ result = run_inventory(repository, ".", output, arguments=arguments)
+
+ assert result.returncode == 0, result.stderr
+ assert output.read_text(encoding="utf-8").splitlines() == sorted(sources)
+
+
def test_diff_inventory_keeps_every_javascript_module_extension(tmp_path: Path) -> None:
repository = make_repository(tmp_path)
git(repository, "add", ".")
diff --git a/plugins/codex-security/tests/test_generate_rank_input.py b/plugins/codex-security/tests/test_generate_rank_input.py
index 3f1abc340..23acdb855 100644
--- a/plugins/codex-security/tests/test_generate_rank_input.py
+++ b/plugins/codex-security/tests/test_generate_rank_input.py
@@ -259,6 +259,42 @@ def test_rank_input_includes_terraform(tmp_path: Path, mode: str) -> None:
]
[email protected]("mode", ["repo", "revisions", "local-patch"])
+def test_rank_input_includes_objective_c(tmp_path: Path, mode: str) -> None:
+ repo = tmp_path / "repo"
+ ios = repo / "ios"
+ ios.mkdir(parents=True)
+ initialize_repo(repo)
+ source = ios / "ViewController.m"
+ source.write_text('NSString *greeting = @"hello";\n', encoding="utf-8")
+ git(repo, "add", ".")
+ git(repo, "commit", "-qm", "base")
+ base = git(repo, "rev-parse", "HEAD")
+ changed = 'NSString *greeting = @"goodbye";'
+ source.write_text(changed + "\n", encoding="utf-8")
+ output = tmp_path / "rank_input.jsonl"
+
+ if mode == "repo":
+ arguments = ["make-repo-rank-input", "--repo", str(repo), "--scope", "ios"]
+ else:
+ arguments = ["make-diff-rank-input", "--repo", str(repo), "--base", base, "--mode", mode]
+ if mode == "revisions":
+ git(repo, "add", ".")
+ git(repo, "commit", "-qm", "change")
+ arguments.extend(["--head", git(repo, "rev-parse", "HEAD")])
+ git(repo, "checkout", "-q", base)
+
+ run_cli(*arguments, "--out", str(output))
+
+ assert read_jsonl(output) == [
+ {
+ "path": "ios/ViewController.m",
+ "area": "ios" if mode == "repo" else "diff",
+ "preview": changed,
+ }
+ ]
+
+
def test_make_repo_rank_input_rejects_scope_outside_repo(tmp_path: Path) -> None:
repo = tmp_path / "repo"
repo.mkdir()
diff --git a/plugins/codex-security/tests/test_rank_preview.py b/plugins/codex-security/tests/test_rank_preview.py
index f1b44582e..5ed6c16f1 100644
--- a/plugins/codex-security/tests/test_rank_preview.py
+++ b/plugins/codex-security/tests/test_rank_preview.py
@@ -583,7 +583,7 @@ def test_fallback_preview_omits_marker_when_no_lines_are_skipped(tmp_path: Path)
assert "..." not in preview
[email protected]("filename", ["styles.css", "main.tf"])
[email protected]("filename", ["styles.css", "main.tf", "ViewController.m"])
def test_preview_byte_budget_preserves_sampled_tail_and_valid_unicode(
tmp_path: Path, filename: str
) -> None: