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(windows): preserve long Git metadata in reviewed patch replay (#2543)
Michael D'Angelo943ea05777f9
diff --git a/plugins/codex-security/scripts/windows_scan_local_files.py b/plugins/codex-security/scripts/windows_scan_local_files.pyindex aed3acf64..5a9cbb571 100644--- a/plugins/codex-security/scripts/windows_scan_local_files.py+++ b/plugins/codex-security/scripts/windows_scan_local_files.py@@ -1088,6 +1088,55 @@ def pinned_root_git_marker(yield marker+def pin_replay_metadata(+ pins: contextlib.ExitStack, metadata: Path | None, scratch: Path+) -> Path | None:+ """Bind the selected metadata and fresh private Windows scratch before copying into it."""+ if os.name != "nt" or metadata is None:+ return None+ try:+ with contextlib.ExitStack() as checked:+ checked.enter_context(_locked_parent(metadata, "HEAD", create=False))+ checked.enter_context(_locked_parent(scratch.parent, scratch.name, create=False))+ directory = _create_file(+ scratch,+ access=_FILE_TRAVERSE | _FILE_READ_ATTRIBUTES | _READ_CONTROL,+ share=_FILE_SHARE_READ | _FILE_SHARE_WRITE,+ disposition=_OPEN_EXISTING,+ flags=_FILE_FLAG_BACKUP_SEMANTICS | _FILE_FLAG_OPEN_REPARSE_POINT,+ )+ assert directory is not None and directory.value is not None+ checked.enter_context(directory)+ _verify_directory(directory.value, scratch)+ if _output_directory_grants(directory.value, scratch):+ return None+ pins.enter_context(checked.pop_all())+ except (OSError, ValueError):+ return None+ return metadata+++def pinned_replay_gitfile(checkout: Path, metadata: Path) -> Iterator[Path]:+ """Keep Git's short metadata pointer outside the replay and immutable while Git uses it."""+ with _locked_parent(checkout, ".git", create=False):+ # Git reads this path relative to its unchanged worktree cwd. Both volumes'+ # literal ancestors are pinned, including the temporary directory above checkout.+ marker = checkout.parent / "reviewed.git"+ handle = _create_file(+ marker,+ access=_GENERIC_WRITE | _FILE_READ_ATTRIBUTES,+ share=_FILE_SHARE_READ,+ disposition=_CREATE_NEW,+ flags=_FILE_ATTRIBUTE_NORMAL | _FILE_FLAG_OPEN_REPARSE_POINT,+ )+ assert handle is not None and handle.value is not None+ with handle:+ _verify_regular_file(handle.value, marker)+ _write_all(handle.value, f"gitdir: {metadata.as_posix()}\n".encode("utf-8"))+ yield Path("..") / marker.name++def open_read_fd(scan_dir: Path, relative_path: str, context: str) -> int:"""Open a verified regular file and return an owned binary read descriptor."""diff --git a/plugins/codex-security/scripts/workbench_db.py b/plugins/codex-security/scripts/workbench_db.pyindex d97437868..716b2589d 100644--- a/plugins/codex-security/scripts/workbench_db.py+++ b/plugins/codex-security/scripts/workbench_db.py@@ -54,6 +54,7 @@ from finalize_scan_contract import (open_scan_local_file_descriptor,)from finding_preview import bounded_finding_details+from windows_scan_local_files import pin_replay_metadatafrom workbench import handofffrom workbench.storage import (create_private_directory,@@ -2371,12 +2372,17 @@ def require_reviewed_patch_applied(excluded = (Path(scan["scan_dir"]),)# Unborn repositories still need their config while metadata junctions are deferred.git_dir = git_output(target, "rev-parse", "--absolute-git-dir")+ metadata = Path(git_dir) if git_dir is not None else Noneif not unversioned:repository, pathspec = git_worktree_context(target)if git_dir is None:raise SystemExit("Could not inspect the selected Git working tree.")excluded += tuple(path for path, _ in git_submodule_entries(target))- with tempfile.TemporaryDirectory(prefix="codex-security-remediation-") as temporary:+ with (+ tempfile.TemporaryDirectory(prefix="codex-security-remediation-") as temporary,+ ExitStack() as pins,+ ):+ pinned_metadata = pin_replay_metadata(pins, metadata, Path(temporary))reviewed_patch = Path(temporary) / "reviewed.patch"digest = hashlib.sha256()with open_scan_local_file(Path(scan["scan_dir"]), patch_path) as source:@@ -2392,35 +2398,28 @@ def require_reviewed_patch_applied(junctions = copy_directory_excluding(target, checkout, excluded)else:_, junctions = copy_git_worktree_files(target, checkout_root, excluded)- arguments = ["apply", "--reverse", "--whitespace=nowarn"]- if unversioned:- arguments.append("--no-index")- elif pathspec != ".":- arguments.append(f"--directory={pathspec}")- arguments.append(str(reviewed_patch))- applied = git_command(- checkout if unversioned else checkout_root,- *arguments,- text=False,- git_dir=Path(git_dir) if git_dir is not None else None,- work_tree=checkout_root if git_dir is not None else None,+ short, replay_root = remediation_state.reverse_reviewed_patch(+ target,+ checkout_root,+ metadata,+ pinned_metadata,+ remediation["patch_digest"],+ pins,+ reviewed_patch,+ None if unversioned else pathspec,)- if applied.returncode != 0:- raise SystemExit(- "The selected checkout does not contain the reviewed remediation patch. Apply exactly that patch before recording it as applied."- )restore_directory_junctions(target if unversioned else repository,checkout if unversioned else checkout_root,junctions,)reverted_digest = (- directory_content_digest(checkout)+ directory_content_digest(checkout, replay_git_dir=replay_root)if unversionedelse worktree_content_digest_for_context(checkout_root,pathspec or ".",- git_dir=Path(git_dir),+ git_dir=short or metadata,work_tree=checkout_root,))@@ -2431,12 +2430,16 @@ def require_reviewed_patch_applied(checkout,"-c","core.autocrlf=input",- *arguments,+ "apply",+ "--reverse",+ "--whitespace=nowarn",+ "--no-index",+ str(reviewed_patch),text=True,)if applied_without_conversion.returncode == 0:restore_directory_junctions(target, checkout, junctions)- reverted_digest = directory_content_digest(checkout)+ reverted_digest = directory_content_digest(checkout, replay_git_dir=replay_root)if reverted_digest != remediation["base_content_digest"]:raise SystemExit("The selected checkout contains changes outside the reviewed patch. Remove them before recording the patch as applied."diff --git a/plugins/codex-security/scripts/workbench_remediation.py b/plugins/codex-security/scripts/workbench_remediation.pyindex a0848f8e2..1e197517a 100644--- a/plugins/codex-security/scripts/workbench_remediation.py+++ b/plugins/codex-security/scripts/workbench_remediation.py@@ -46,6 +46,92 @@ COMMANDS = {SCAN_STATUS_ERROR = "Remediation is available only for successfully completed scans."+def reverse_reviewed_patch(+ target: Path,+ checkout: Path,+ metadata: Path | None,+ pinned_metadata: Path | None,+ patch_digest: str,+ pins: ExitStack,+ patch: Path,+ pathspec: str | None,+) -> tuple[Path | None, Path | None]:+ """Reverse reviewed bytes and select the Git references for subsequent content snapshots."""++ arguments = ["--reverse", "--whitespace=nowarn"]+ if pathspec is None:+ arguments.append("--no-index")+ elif pathspec != ".":+ arguments.append(f"--directory={pathspec}")+ arguments.append(str(patch))++ def reverse(*, git_dir: Path | None, check: bool = False):+ return git_command(+ checkout,+ "apply",+ *(["--check"] if check else []),+ *arguments,+ text=False,+ git_dir=git_dir,+ work_tree=checkout if git_dir else None,+ environment_overrides={"LC_ALL": "C", "LANGUAGE": "C"} if check else None,+ )++ applied = reverse(git_dir=metadata)+ short = None+ diagnostic = b"fatal: '$GIT_DIR' too big"+ if (+ os.name == "nt"+ and metadata is not None+ and applied.returncode == 128+ and not applied.stdout+ and b"GIT_DIR" in applied.stderr+ ):+ # Confirm translated messages without applying the reverse patch twice.+ failure = (+ applied+ if diagnostic in applied.stderr.splitlines()+ else reverse(git_dir=metadata, check=True)+ )+ if (+ failure.returncode == 128+ and not failure.stdout+ and diagnostic in failure.stderr.splitlines()+ ):+ short = prepare_replay_gitfile(checkout, pinned_metadata, patch_digest, pins)+ applied = reverse(git_dir=short)+ if applied.returncode != 0:+ raise SystemExit(+ "The selected checkout does not contain the reviewed remediation patch. Apply exactly that patch before recording it as applied."+ )+ replay_root = None+ if pathspec is None and short is not None:+ selected_root = git_output(target, "rev-parse", "--show-toplevel")+ if selected_root and Path(selected_root).samefile(target):+ replay_root = short+ return short, replay_root+++def prepare_replay_gitfile(+ checkout: Path, pinned_metadata: Path | None, patch_digest: str, pins: ExitStack+) -> Path:+ """Retain the verified patch and short metadata reference through the final snapshot."""+ if pinned_metadata is None:+ raise SystemExit(+ "Could not bind the selected Windows Git directory and private patch replay directory."+ )+ from windows_scan_local_files import open_read_fd, pinned_replay_gitfile++ try:+ short = pins.enter_context(pinned_replay_gitfile(checkout, pinned_metadata))+ fd = open_read_fd(checkout.parent, "reviewed.patch", "reviewed remediation patch")+ patch = pins.enter_context(os.fdopen(fd, "rb"))+ matching_patch_metadata(patch, patch_digest)+ except (OSError, ValueError) as exc:+ raise SystemExit(f"Could not verify the reviewed patch replay: {exc}") from exc+ return short++def require_available(connection: sqlite3.Connection, args: Any, require_scan: Any) -> None:"""Require a successfully completed scan for commands that act on a remediation request."""if args.command not in COMMANDS:diff --git a/plugins/codex-security/scripts/workbench_target.py b/plugins/codex-security/scripts/workbench_target.pyindex 5f62cf3a0..612ec0107 100644--- a/plugins/codex-security/scripts/workbench_target.py+++ b/plugins/codex-security/scripts/workbench_target.py@@ -956,11 +956,16 @@ def _windows_inventory_query(return result-def git_directory_snapshot_paths(target: Path) -> list[Path] | None:- repository_root = git_output(target, "rev-parse", "--show-toplevel")- if repository_root is None:- return None- repository, pathspec = git_worktree_context(target)+def git_directory_snapshot_paths(+ target: Path, *, replay_git_dir: Path | None = None+) -> list[Path] | None:+ if replay_git_dir is None:+ if git_output(target, "rev-parse", "--show-toplevel") is None:+ return None+ repository, pathspec = git_worktree_context(target)+ else:+ # The temporary copy of an unborn repository uses the selected Git config and index.+ repository, pathspec = target, "."scope = repository / pathspecscope_depth = len(Path(pathspec).parts)matching_prefixes: dict[str, bool] = {}@@ -988,6 +993,8 @@ def git_directory_snapshot_paths(target: Path) -> list[Path] | None:"-z","--",inventory_pathspec,+ git_dir=replay_git_dir,+ work_tree=repository if replay_git_dir else None,)if listed is None:raise SystemExit("Could not inspect files in the selected Git working tree.")@@ -1046,7 +1053,7 @@ def git_directory_snapshot_paths(target: Path) -> list[Path] | None:if _WINDOWS:# Git omits empty untracked directories from its file listing. Inventory# junction identities independently of whether their targets contain files.- git_directory = git_output(target, "rev-parse", "--absolute-git-dir")+ git_directory = replay_git_dir or git_output(target, "rev-parse", "--absolute-git-dir")if git_directory is None:raise SystemExit("Could not inspect the selected Git working tree.")directories = _windows_inventory_query(@@ -1163,6 +1170,7 @@ def directory_content_digest(excluded: tuple[Path, ...] = (),include_ignored: bool = False,include_git_metadata: bool = False,+ replay_git_dir: Path | None = None,) -> str:def raise_walk_error(error: OSError) -> None:raise error@@ -1175,7 +1183,7 @@ def directory_content_digest(target, excluded, include_git_metadata=include_git_metadata, onerror=raise_walk_error)if include_ignored- else git_directory_snapshot_paths(target)+ else git_directory_snapshot_paths(target, replay_git_dir=replay_git_dir))if paths is None:paths = source_directory_snapshot_paths(target, excluded)diff --git a/plugins/codex-security/tests/test_workbench_target.py b/plugins/codex-security/tests/test_workbench_target.pyindex 3900c0a60..5f2b0494e 100644--- a/plugins/codex-security/tests/test_workbench_target.py+++ b/plugins/codex-security/tests/test_workbench_target.py@@ -155,12 +155,14 @@ def test_recorded_checkout_distinguishes_a_replaced_parent_from_a_missing_path(def write_reviewed_patch(tmp_path: Path, source: Path, patch: bytes, revision: str = "unversioned") -> dict[str, object]:+ from filesystem_identity import serialize_filesystem_identity+scan_dir = tmp_path / "scan"scan_dir.mkdir(mode=0o700)(scan_dir / "reviewed.patch").write_bytes(patch)return {"target_path": str(source),- "target_inode": source.stat().st_ino,+ "target_inode": serialize_filesystem_identity(source.stat().st_ino),"target_revision": revision,"scan_dir": str(scan_dir),}@@ -174,6 +176,218 @@ def reviewed_remediation(patch: bytes, revision: str, digest: str) -> dict[str,}[email protected]_platform[email protected]("layout", ["separate", "linked", "unborn", "unborn-root"])+def test_reviewed_patch_uses_long_source_metadata_in_its_private_replay(+ tmp_path: Path, layout: str, monkeypatch: pytest.MonkeyPatch+) -> None:+ import workbench_db++ # The metadata argument is long in UTF-8 even on hosts with short temporary paths.+ padding = max(1, (230 - len((tmp_path / "metadata-").as_posix().encode("utf-8")) + 2) // 3)+ metadata = tmp_path / ("metadata-" + "界" * padding)+ source = tmp_path / "source"+ if layout == "unborn-root":+ source, metadata = metadata, metadata / ".git"+ subprocess.run(["git", "init", "-q", str(source)], check=True)+ else:+ subprocess.run(+ ["git", "init", "-q", "--separate-git-dir", str(metadata), str(source)], check=True+ )+ subprocess.run(["git", "-C", str(source), "config", "core.autocrlf", "false"], check=True)+ (source / "file.txt").write_bytes(b"before\n")+ revision = "unversioned"+ if layout in {"separate", "linked"}:+ subprocess.run(["git", "-C", str(source), "add", "file.txt"], check=True)+ subprocess.run(+ [+ "git",+ "-C",+ str(source),+ "-c",+ "user.name=Fixture",+ "-c",+ "[email protected]",+ "commit",+ "-qm",+ "base",+ ],+ check=True,+ )+ if layout == "linked":+ linked = tmp_path / "linked"+ subprocess.run(+ ["git", "-C", str(source), "worktree", "add", "--detach", str(linked)], check=True+ )+ source = linked+ revision = subprocess.check_output(+ ["git", "-C", str(source), "rev-parse", "HEAD"], text=True+ ).strip()+ marker = source / ".git/HEAD" if layout == "unborn-root" else source / ".git"+ original_marker = marker.read_bytes()+ (metadata / "info/exclude").write_bytes(b"ignored.fixture\n")+ (source / "ignored.fixture").write_bytes(b"outside the recorded content\n")+ if os.name == "nt" and revision == "unversioned":+ # The private copy keeps the original gitdir-conditional visibility when using the retry.+ global_config, included, excludes = (+ tmp_path / name for name in ("global", "include", "excludes")+ )+ excludes.write_bytes(b"conditional.fixture\n")+ subprocess.run(+ ["git", "config", "--file", included, "core.excludesFile", excludes.as_posix()],+ check=True,+ )+ subprocess.run(+ [+ "git",+ "config",+ "--file",+ global_config,+ f"includeIf.gitdir:{metadata.as_posix()}.path",+ included.as_posix(),+ ],+ check=True,+ )+ monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(global_config))+ (source / "conditional.fixture").write_bytes(b"excluded by the selected Git directory\n")+ ignored = subprocess.check_output(+ ["git", "-C", source, "check-ignore", "conditional.fixture"]+ )+ assert ignored.strip()+ patch = b"diff --git a/file.txt b/file.txt\n--- a/file.txt\n+++ b/file.txt\n@@ -1 +1 @@\n-before\n+after\n"+ scan = write_reviewed_patch(tmp_path, source, patch, revision)+ _, digest = workbench_db.remediation_checkout_snapshot(scan)+ remediation = reviewed_remediation(patch, revision, digest)+ selected_file = source / "file.txt"+ selected_file.write_bytes(b"after\n")+ _, applied_digest = workbench_db.remediation_checkout_snapshot(scan)+ verify = workbench_db.require_reviewed_patch_applied+ assert verify(scan, remediation, "reviewed.patch") == applied_digest+ assert selected_file.read_bytes() == b"after\n"+ selected_file.write_bytes(b"other\n")+ with pytest.raises(SystemExit, match="does not contain the reviewed remediation patch"):+ verify(scan, remediation, "reviewed.patch")+ assert selected_file.read_bytes() == b"other\n"+ selected_file.write_bytes(b"after\n")+ (source / "unrelated.txt").write_bytes(b"keep me\n")+ with pytest.raises(SystemExit, match="changes outside the reviewed patch"):+ verify(scan, remediation, "reviewed.patch")+ assert (source / "unrelated.txt").read_bytes() == b"keep me\n"+ (source / "unrelated.txt").unlink()+ malformed = b"not a patch\n"+ (tmp_path / "scan/reviewed.patch").write_bytes(malformed)+ with pytest.raises(SystemExit, match="does not contain the reviewed remediation patch"):+ verify(scan, reviewed_remediation(malformed, revision, digest), "reviewed.patch")+ assert marker.read_bytes() == original_marker+ assert selected_file.read_bytes() == b"after\n"++[email protected]_windows[email protected](os.name != "nt", reason="requires Windows directory and file sharing")+def test_replay_gitfile_remains_bound_until_the_private_replay_is_removed(tmp_path: Path) -> None:+ import tempfile+ from contextlib import ExitStack++ import windows_scan_local_files as windows+ import workbench_target++ source = tmp_path / "source"+ foreign = tmp_path / "foreign"+ initialize_git_repository(source)+ initialize_git_repository(foreign)+ metadata = source / ".git"+ stages = tmp_path / "replays"+ stages.mkdir()++ def interrupt_replay():+ with tempfile.TemporaryDirectory(dir=stages) as temporary, ExitStack() as pins:+ scratch = Path(temporary)+ checkout = scratch / "checkout"+ checkout.mkdir()+ (checkout / ".git").write_bytes(f"gitdir: {(foreign / '.git').as_posix()}\n".encode())+ assert windows.pin_replay_metadata(pins, metadata, scratch) == metadata+ with pytest.raises(PermissionError):+ scratch.rename(stages / "elsewhere")+ short = pins.enter_context(windows.pinned_replay_gitfile(checkout, metadata))+ assert (+ Path(+ workbench_target.git_output(+ checkout,+ "rev-parse",+ "--absolute-git-dir",+ git_dir=short,+ work_tree=checkout,+ )+ )+ == metadata+ )+ with pytest.raises(PermissionError):+ (checkout / short).write_bytes(b"other")+ for path in (metadata, checkout, scratch, checkout / short):+ with pytest.raises(PermissionError):+ path.rename(path.with_name("replaced"))+ raise KeyboardInterrupt++ with pytest.raises(KeyboardInterrupt):+ interrupt_replay()+ assert not list(stages.iterdir())+ assert metadata.is_dir() and (foreign / ".git").is_dir()++[email protected]_windows[email protected](os.name != "nt", reason="requires Windows regular-file and junction checks")+ "change", ["foreign-pointer", "changed-patch", "replaced-parent", "writable-scratch"]+)+def test_short_git_reference_refuses_changed_replay_inputs(+ tmp_path: Path, change: str, monkeypatch: pytest.MonkeyPatch+) -> None:+ from contextlib import ExitStack++ import windows_scan_local_files as windows+ import workbench_remediation++ metadata, scratch = tmp_path / "metadata", tmp_path / "scratch"+ metadata.mkdir()+ scratch.mkdir()+ worktree = scratch / "checkout"+ worktree.mkdir()+ patch = scratch / "reviewed.patch"+ patch.write_bytes(b"expected")+ expected = "sha256:" + hashlib.sha256(patch.read_bytes()).hexdigest()+ marker = scratch / "reviewed.git"+ if change == "foreign-pointer":+ marker.write_bytes(b"gitdir: foreign\n")+ elif change == "changed-patch":+ patch.write_bytes(b"changed")+ elif change == "replaced-parent":+ alias = tmp_path / "alias"+ subprocess.run(["cmd", "/c", "mklink", "/J", str(alias), str(scratch)], check=True)+ worktree = alias / "checkout"+ else:+ subprocess.run(["icacls.exe", str(scratch), "/grant", "*S-1-1-0:(WD)"], check=True)+ failed = subprocess.CompletedProcess([], 128, b"", b"fatal: '$GIT_DIR' too big\n")+ monkeypatch.setattr(workbench_remediation, "git_command", lambda *args, **kwargs: failed)+ with ExitStack() as pins:+ selected = windows.pin_replay_metadata(pins, metadata, scratch)+ if change == "writable-scratch":+ assert selected is None+ with pytest.raises(SystemExit, match="Could not bind"):+ workbench_remediation.reverse_reviewed_patch(+ tmp_path, worktree, metadata, selected, expected, pins, patch, "."+ )+ assert not marker.exists()+ return+ with pytest.raises(SystemExit, match="Could not verify|Patch digest does not match"):+ workbench_remediation.reverse_reviewed_patch(+ tmp_path, worktree, metadata, selected, expected, pins, patch, "."+ )+ if change == "foreign-pointer":+ assert marker.read_bytes() == b"gitdir: foreign\n"+ if change == "replaced-parent":+ assert not marker.exists()++@pytest.mark.parametrize(("git_repository", "git_exclusion"),[@@ -310,6 +524,7 @@ def test_versioned_reviewed_patch_preserves_nested_junctions(populated: bool,) -> None:import workbench_db+ import workbench_remediationrepository = tmp_path / "repository"initialize_git_repository(repository)@@ -327,7 +542,7 @@ def test_versioned_reviewed_patch_preserves_nested_junctions(junction = nested / "linked"junction_factory(junction, outside)relative_junction = junction.relative_to(repository)- original_command = workbench_db.git_command+ original_command = workbench_remediation.git_commandoriginal_restore = workbench_db.restore_directory_junctionsreversed_roots: list[Path] = []restored: list[Path] = []@@ -351,7 +566,7 @@ def test_versioned_reviewed_patch_preserves_nested_junctions(original_restore(source, destination, junctions)restored.append(destination)- monkeypatch.setattr(workbench_db, "git_command", command)+ monkeypatch.setattr(workbench_remediation, "git_command", command)monkeypatch.setattr(workbench_db, "restore_directory_junctions", restore)assert_reviewed_change(target,@@ -511,10 +726,43 @@ def test_reviewed_patch_restores_junction_git_context(assert (source / patched).read_bytes() == after.replace("\n", newline).encode()[email protected]_platform-def test_reviewed_patch_preserves_scoped_unborn_lf_bytes(tmp_path: Path) -> None:+ "short_reference",+ [+ pytest.param(False, marks=pytest.mark.cross_platform),+ pytest.param(+ True,+ marks=[+ pytest.mark.native_windows,+ pytest.mark.skipif(os.name != "nt", reason="requires Windows replay binding"),+ ],+ ),+ ],+ ids=["ordinary", "short-reference"],+)+def test_reviewed_patch_preserves_scoped_unborn_lf_bytes(+ tmp_path: Path, short_reference: bool, monkeypatch: pytest.MonkeyPatch+) -> None:+ import workbench_remediation+repository = tmp_path / "repository"initialize_unborn_git_repository(repository)+ references = []+ reverse = workbench_remediation.reverse_reviewed_patch+ git = workbench_remediation.git_command++ def record_references(*args, **kwargs):+ selected = reverse(*args, **kwargs)+ references.append(selected)+ return selected++ def require_short_reference(target, *args, **kwargs):+ if short_reference and kwargs.get("git_dir") == repository / ".git":+ return subprocess.CompletedProcess([], 128, b"", b"fatal: '$GIT_DIR' too big\n")+ return git(target, *args, **kwargs)++ monkeypatch.setattr(workbench_remediation, "reverse_reviewed_patch", record_references)+ monkeypatch.setattr(workbench_remediation, "git_command", require_short_reference)attributes = tmp_path / "attributes"attributes.write_text("*.txt text eol=crlf\n")subprocess.run(@@ -526,6 +774,8 @@ def test_reviewed_patch_preserves_scoped_unborn_lf_bytes(tmp_path: Path) -> Noneassert_reviewed_change(source, tmp_path, "app.txt", "before\n", "after\n", newline="\n")assert (source / "app.txt").read_bytes() == b"after\n"+ if short_reference:+ assert references[0][0] is not Nonedef assert_reviewed_change(