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(targets): ignore log.showSignature when reading commit subjects (#1805)

1233c161cccbeb
diff --git a/plugins/codex-security/scripts/workbench_target.py b/plugins/codex-security/scripts/workbench_target.py
index 6a0793579..f7cb6e936 100644
--- a/plugins/codex-security/scripts/workbench_target.py
+++ b/plugins/codex-security/scripts/workbench_target.py
@@ -1072,7 +1072,7 @@ def git_target_metadata(target: Path) -> dict[str, Any]:
branch = git_output(target, "symbolic-ref", "--quiet", "--short", "HEAD")
metadata.update({"branch": branch, "detachedHead": revision is not None and branch is None})
if revision is not None:
- subject = git_bytes(target, "show", "-s", "--format=%s", "HEAD")
+ subject = git_bytes(target, "show", "-s", "--no-show-signature", "--format=%s", "HEAD")
metadata.update(
{
"commitSubject": (subject or b"").decode("utf-8", errors="replace").strip() or None,
diff --git a/plugins/codex-security/tests/test_workbench_target.py b/plugins/codex-security/tests/test_workbench_target.py
index bd54c73a1..26982e5b7 100644
--- a/plugins/codex-security/tests/test_workbench_target.py
+++ b/plugins/codex-security/tests/test_workbench_target.py
@@ -1021,6 +1021,31 @@ def test_git_metadata_preserves_unicode_commit_subject(
) == f"{subject}\n".encode("utf-8")
+def test_git_metadata_ignores_signature_output_in_commit_subject(tmp_path: Path) -> None:
+ target = tmp_path / "target"
+ initialize_git_repository(target)
+ headers = subprocess.check_output(["git", "cat-file", "commit", "HEAD"], cwd=target).split(
+ b"\n\n", 1
+ )[0]
+ # A synthetic signature reproduces Git's extra output without a signing tool.
+ commit = headers + (
+ b"\ngpgsig -----BEGIN SSH SIGNATURE-----\n synthetic\n -----END SSH SIGNATURE-----"
+ b"\n\nSigned subject\n"
+ )
+ revision = (
+ subprocess.check_output(
+ ["git", "hash-object", "-t", "commit", "-w", "--stdin"], cwd=target, input=commit
+ )
+ .decode()
+ .strip()
+ )
+ subprocess.run(["git", "update-ref", "HEAD", revision], cwd=target, check=True)
+ subprocess.run(["git", "config", "log.showSignature", "true"], cwd=target, check=True)
+
+ assert WORKBENCH_TARGET["git_target_metadata"](target)["commitSubject"] == "Signed subject"
+
+
@pytest.mark.parametrize("encoding", ["cp932", "cp949"])
def test_git_output_decodes_repository_paths_as_utf8(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, encoding: str