Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/codex-security/scripts/generate_in_scope_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,8 @@ def write_inventory(output: Path, rows: list[bytes]) -> int:
with tempfile.NamedTemporaryFile(
mode="wb",
dir=output.parent,
prefix=f".{output.name}.",
# Including the output name can exceed the filesystem's 255-byte name limit.
prefix=".",
suffix=".tmp",
delete=False,
) as handle:
Expand Down
17 changes: 15 additions & 2 deletions plugins/codex-security/tests/test_generate_in_scope_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_inventory_matches_the_existing_standard_command(tmp_path: Path, scope:

assert result.returncode == 0, result.stderr
assert output.read_bytes() == standard_inventory(repository, scope)
assert list(output.parent.glob(f".{output.name}.*.tmp")) == []
assert list(output.parent.glob(".*.tmp")) == []
if scope == ".":
rows = set(output.read_text(encoding="utf-8").splitlines())
assert {
Expand All @@ -131,6 +131,19 @@ def test_inventory_matches_the_existing_standard_command(tmp_path: Path, scope:
assert {"./ignored/secret.py", "./app/ignored.skip"}.isdisjoint(rows)


@pytest.mark.parametrize("name", [f"{'a' * 251}.txt", f"{'文' * 83}.txt"])
def test_inventory_replaces_outputs_with_long_filenames(tmp_path: Path, name: str) -> None:
repository = make_repository(tmp_path)
output = tmp_path / name
output.write_text("previous.py\n", encoding="utf-8")

result = run_inventory(repository, ".", output)

assert result.returncode == 0, result.stderr
assert output.read_bytes() == standard_inventory(repository, ".")
assert list(output.parent.glob(".*.tmp")) == []


def test_absolute_scope_still_produces_repository_relative_paths(tmp_path: Path) -> None:
repository = make_repository(tmp_path)
output = tmp_path / "in_scope_files.txt"
Expand Down Expand Up @@ -278,7 +291,7 @@ def test_inventory_rejects_line_breaks_before_serializing_paths(
assert "path that cannot fit in the file inventory" in result.stderr
assert result.stdout == ""
assert output.read_bytes() == previous
assert list(output.parent.glob(f".{output.name}.*.tmp")) == []
assert list(output.parent.glob(".*.tmp")) == []


def test_diff_inventory_includes_power_shell_files(
Expand Down
Loading