Skip to content

git-nonutf8-paths: fix SEC-10 - #40

Merged
kridaydave merged 2 commits into
mainfrom
fix/pr-23-git-nonutf8-paths
Nov 8, 2026
Merged

kridaydave merged 2 commits into
mainfrom
fix/pr-23-git-nonutf8-paths

Conversation

@kridaydave

Copy link
Copy Markdown
Contributor

Bugs

  • SEC-10: extract_snapshot decodes ls-tree paths with String::from_utf8_lossy, so distinct non-UTF-8 paths can collide into one snapshot key and files get silently merged.

What was wrong

src/adapter/git.rs:extract_snapshot decoded each NUL-framed git ls-tree -r -z entry with String::from_utf8_lossy and split the lossy string on \t. The lossy path became the validate_tree_path input and the Snapshot.files key. Git stores paths as raw bytes; distinct non-UTF-8 paths can decode to the same lossy string, so a later entry overwrote an earlier one and the overwritten file was never diffed, visibility-checked, or exported.

Fix

Parse ls-tree records on raw bytes: split on the tab byte, keep metadata as lossy text (ASCII), and decode the path with std::str::from_utf8. If the path is not valid UTF-8, return an error that names the lossy path and states it was rejected to avoid path collisions. Snapshot.files remains HashMap<String, Vec<u8>>, so rejecting is the smallest change that makes the collision impossible.

Added test_git_adapter_rejects_non_utf8_path in tests/git_adapter_test.rs (unix). It commits a file whose name contains an invalid UTF-8 byte and asserts extract_snapshot returns an error mentioning "non-UTF-8 path".

Verification

CI green (fmt, clippy, tests, release build, adjudication) + the regression test you added

@kridaydave kridaydave added the purging Batch purge: bug-fix swarm PRs label Nov 8, 2026
@kridaydave
kridaydave force-pushed the fix/pr-23-git-nonutf8-paths branch from 3da8508 to 00688ee Compare November 8, 2026 18:10
@kridaydave
kridaydave force-pushed the fix/pr-23-git-nonutf8-paths branch from 00688ee to 2c33a4f Compare November 8, 2026 18:53
@kridaydave
kridaydave merged commit 986bb03 into main Nov 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

purging Batch purge: bug-fix swarm PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant