Repository navigation
Preflight more credential families - #97
Open
antonyth18 wants to merge 6 commits into
Open
antonyth18 wants to merge 6 commits into
antonyth18 wants to merge 6 commits into
Conversation
…larify minimum-length comments
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.
Closes #86
Problem
Before
proofline reviewuploads local changes,preflight::checkrefuses patches containing known credential shapes. It didn't recognise Azure Storage account keys, GitLab PATs, npm tokens, Hugging Face tokens or PyPI tokens, so a patch adding one was uploaded without warning, both byreviewand by the git hooks. Azure is the notable gap, since Proofline supports Azure.Approach
GitLab, npm, Hugging Face, PyPI are new
TOKEN_SHAPESrows, following the existing prefix plus minimum-length design (no right-hand boundary, like every other row). Two new body functions match the real encodings:base64for Azure andbase64urlfor GitLab and PyPI.Azure is a dedicated check in
secret_shaperather than a table row, for two reasons:has_token's exact prefix matching can't express without touching every row.It finds
accountkey=in any casing, then requires 86 base64 characters. A real key is 88 characters including==padding; the padding isn't checked. Field names ending inAccountKey, such asStorageAccountKey, are matched deliberately, since they commonly hold real keys.Azurite. The emulator's well-known key is published by Microsoft and isn't a secret. The Azure check skips that exact key and nothing else; other families are still checked against the original text. I chose to exempt it because hooks call
preflight::checkwithout--allow-path, so flagging it would leave any repo with Azurite fixtures permanently "unreviewed" by the hook whenever those lines appear in a diff. The cost is a special case in a deliberately simple file, which is why it has the most tests.The Azure check runs after the token rows, so the original rows keep their label priority.
Sources
accountkey=(any casing) + ≥86 base64glpat-+ ≥20 base64urlnpm_+ ≥36 alphanumerichf_+ ≥34 alphanumericpypi-+ ≥85 base64urlpypi-prefix instead of the longer one in the issue: with an 85-character minimum, false positives are negligible, and the rule doesn't depend on the encoded bytes that follow the prefix.Verification
Tests first. The tests were committed before the implementation (git log --oneline -7) and failed for the right reason:
credential_families_refuse_minimum_bodies_…left: None,right: Some("an Azure Storage account key")an_azure_storage_connection_string_refuses_before_httpidentifiers_and_placeholders_near_credential_prefixes_…Tests added
-/_for Azure,+//for GitLab and PyPI), sobase64andbase64urlcan't be confused.npm_config_registry,self.hf_model,AccountKey=<your-key>,AccountKey=${STORAGE_KEY}, and the Azurite connection string.StorageAccountKey=is flagged, and a GitHub token's label wins over an Azure key on the same line.tests/local_patch.rs: a trackedappsettings.jsongains an Azure connection string.proofline reviewexits 1, names the location and the label, doesn't echo the key, and the fake server receives zero requests. The file is tracked and isn't named.env, so the test exercises the new detection rather than the untracked-file or path rules.Mutation testing. I disabled or altered each check in turn to confirm a test catches it:
=check on the right off=byte after the padding=counted on the leftAccountKey=checkedAccountKey=ACCOUNTKEY=StorageAccountKey=testbase64urlaccepts+or/+and/base64accepts-or_-and_Mutation testing also changed the code: a left-boundary check turned out to be unreachable, since a candidate always follows the keyword's
=, so I removed it and documented the invariant.CI checks.
fmt,clippy,testanddenyall pass, rebased onto currentmain. One test,unattended_registration_preserves_settings_and_uses_the_installed_binary, also fails onmainon macOS (/varversus/private/var). It's unrelated, and CI doesn't run on macOS.Reproduce
Proofline review
I installed Proofline on my account and reviewed this branch as a PR in my fork (review). It took four runs:
base64andbase64urlapart; I added rows for that. I dismissed a warning about cloning the line as negligible.AccountKey=, because it would missStorageAccountKey; the new test fails under that change.One finding came up in every run:
npm_followed by a 64-character hex digest is flagged. I dismissed it each time. No row in this file has a right-hand boundary, including fixed-lengthghp_, so exact-length matching would be a design change for the whole table. Happy to open a separate issue if that's wanted.