Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #154.
Who it helps
Anyone whose staged changes include a file git renders as a binary diff: content that is not valid UTF-8, or a path matched by a
-diffgitattributes attribute. Until now the patch uploaded with that file's bytes and preflight said nothing, so a key or token inside it reached the server without being named. The product's promise is that local secrets are named before anything leaves the machine; this case was the hole in it.What changes
check()insrc/preflight.rsnow treats binary-diff records the way it treats credentials in hunks: when a line outside any hunk starts a binary record (Binary files … differorGIT binary patch), the file path is resolved from the surrounding raw record (new.or(old), since binary renames carry two paths) and refused with a newPreflightError::Binary { path }variant, in the same wording style as the existingSecretandEnvironmentPathrefusals. The message names the two remedies: remove the file before upload, or pass--allow-pathfor that exact path. Text output renders through the existing error path; no new finding kind, since preflight refusals happen before any review and never become findings.Decisions
Binary files a/x and b/x differdoes not refuse; the check only fires outside hunks. A malformed patch that starts withBinary filesand no header still returnsInvalidPatch, unchanged.GIT binary patchmatched too. Plaingit diff --patchnormally emits only theBinary files … differline, but the relayed formats vary; matching both is cheap and safe.Binary filesline. That line C-quotes paths with spaces; the--raw -zrecord the loop already tracks gives the path unquoted.NotUtf8gate (src/git.rs) runs before preflight, so a non-UTF-8 sibling file can still mask a binary file's content. That is the encoding case in One file that is not UTF-8 hides the credentials the local preflight would name #131 and is out of scope here.Verification
cargo test --test local_patch --test hookscovers: a staged PEM rendered binary (exit 1, no HTTP request made, upload fixture absent), the*.pem -diffgitattributes case, exact-path--allow-pathpass-through, and a pre-push hook report naming the file. A text hunk quoting the binary-diff line does not refuse.cargo clippy --all-targetsclean.