Repository navigation
Name a credential in a local patch before refusing it as a whole - #132
Open
ammartahamohamedy wants to merge 1 commit into
Open
ammartahamohamedy wants to merge 1 commit into
ammartahamohamedy wants to merge 1 commit into
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 #131
Problem
git::diffrefuses a whole patch that has text that isn't UTF-8, is over 5 MiB or has over 3,000 files, beforepreflight::checkruns. The refusal then names only its reason, never a credential in the same patch. In the pre-push hook, one Latin-1 file in the range is enough: underwarnthe push proceeds and the token goes out unmentioned; underblockthe reason reads like an encoding problem and the hook offers--no-verify.Fix
NotUtf8,TooLargeandTooManyFilesnow carry it as aRefused, read lossily (String::from_utf8_lossy): each invalid byte becomes U+FFFD, so lines and paths keep their places. Paths that aren't UTF-8 are read the same way and refused asNotUtf8, as before.Refusedhas no public accessor for the text, and itsDebugomits it.preflight::check_refusedruns the usual check on a refused patch.hooks::readyandreview_localreport a credential or.envpath if there is one, and the original refusal otherwise.--allow-pathworks as before: allowing the exact path leaves the refusal.InvalidDiffis now checked before the size limits, since a refused patch only helps the preflight if its paths can be read.The pre-push hook, with a token and a Latin-1 file in the range:
#121 maps the same three variants to a
--pathhint inreview_local. The variants now carry data, so itsTooLarge(_) | TooManyFiles(_) | NotUtf8pattern becomesTooLarge(..) | TooManyFiles(..) | NotUtf8(_). That's a compile error rather than a silent change, and both edits touch the samelocal_changes(...).awaitinreview_local. I'm happy to rebase on whichever lands first.Tests (written first; the three integration tests failed with the refusal messages before the fix)
a_refused_push_still_names_the_credential_it_carries(new,tests/hooks.rs)warn, no uploadsa_patch_that_is_not_utf8_names_its_credential_before_http(new,tests/local_patch.rs)reviewnames the token at line 2. With--allow-path settings.py, it refuses as "not UTF-8". No requests, index untouchedlocal_selection_uploads_only_selected_bytes_and_refuses_before_http(extended)a_refused_patch_keeps_lossy_text_and_paths_for_the_preflight(new,git.rsunit)range_changesreturnsNotUtf8holding U+FFFD text and path with the same lines, and the error'sDebugdoesn't contain the tokensize_refusals_keep_the_credential_for_the_preflight(new,git.rsunit)--raw -z --patchoutput, with a token at line 2 of the second file. It's read with small limits standing in for 5 MiB and 3,000 files. BothTooLargeandTooManyFilesrefuse,check_refusednames the token at"settings.py":2, and neither error'sDebugcontains it. No Git or disk involved:diffnow hands its output toread_diff, which takes the limitsMutation checks: each of these makes a new test fail:
TooLargekeeping no patch (hooks.rstest, large branch);TooLargeandTooManyFileskeeping no patch (size_refusals_…unit test);review_localskippingcheck_refused(bothlocal_patch.rstests).End to end, with the built binary: the reproduction in #131 names
"settings.py":1instead of the encoding, underwarnand underblock.Checks
cargo fmt --check: ✅cargo clippy --locked -- -D warnings: clean on the lib, the bins and every integration test.--all-targetsstops at the 2 errorsmainalready has on Windows (src/agent/tests.rs).cargo test --locked: the changed and new tests pass. On Windows, the same 9 tests fail as onmain, outside this change (mcp, agent install, update,added_context_deleted_and_quoted_content_refuses_before_httpon a file name Windows forbids, anda_push_reviews_the_branches_it_updates_and_skips_tags_and_deletionson a Windows push URL).cargo deny check: no dependency changes.checkandwindowspassed on ammar-taha-dev/proofline-cli#2.Proofline review log
Fork review PR: ammar-taha-dev/proofline-cli#2. Rounds capped at 2.
The prompts below are the ones that drove this implementation; the investigation, reproduction and fix scope were done before them and aren't included.