Repository navigation
fix(release): the reference verifier refuses a commit or a digest that ends in a newline - #31
Merged
Merged
Conversation
…t ends in a newline In Python the end anchor $ also matches in front of a final newline, so DIGEST_RE.match and COMMIT_RE.match accepted "<40 hex>\n" as a source_commit and "sha256:<64 hex>\n" as an artifact digest, and gave artifact_manifest_mismatch instead of artifact_manifest_digest_form for a manifest digest with a final newline. Both patterns now end with \Z. Proof first: three new vectors fail against the verifier of d2d8ec7 (two of them were PASS on a re-authenticated record), the test reads that verifier from git so the defect is reproduced in CI and not remembered; four controls are refused before and after. A planted-defect test puts the anchor back at each place and the vectors turn red. The frozen yardstick is amended explicitly, not edited: FROZEN.sha256 is untouched and still checked against the blobs of d2d8ec7; tests/fixtures/envelope3/AMENDMENTS.yaml lists the two changed files with the digest they had, the digest they have and the reason, and test_conformance_frozen.py checks all three. The second file is e3_mutants.py, where nine mutants carry the text of the changed lines (mechanical, none added, removed or retargeted). The released v0.2.1 record still passes record, blobs and crypto with the fixed verifier. The compiler is not changed: its SOURCE_COMMIT_RE reads the stripped output of git rev-parse, where a final newline cannot occur. --- [signing-metadata] key = cic-my-sign-key signature = vault:v1:MEUCIQCLwIZ84N3bk20eWruUv8KTOH+KVNUBpjPb7SO0SGSBtgIgVcIKENjgFT2iutuCZ8IBLpvkWWgD79T7OZSG/I3+RTw= hash-algorithm = sha256 digest = scaAfk0EzqHJCTcwf7/RcJQhlswbsqckmMpMQwyk8GU= [certificate] -----BEGIN CERTIFICATE----- MIICBjCCAaygAwIBAgIUSnRMR6RPnEbg296XWPOqq/u5PCwwCgYIKoZIzj0EAwIw QzELMAkGA1UEBhMCSFUxGTAXBgNVBAoMEENlbnRyYWxJbmZyYUNvcmUxGTAXBgNV BAMMEENJQyBEZXZlbG9wZXIgQ0EwHhcNMjYwMzIwMTMyMjU5WhcNMjYxMjMxMTMy MjU5WjBFMQswCQYDVQQGEwJIVTEZMBcGA1UECgwQQ2VudHJhbEluZnJhQ29yZTEb MBkGA1UEAwwSR2Fib3IgWm9sdGFuIFNpbmtvMFkwEwYHKoZIzj0CAQYIKoZIzj0D AQcDQgAEIG2CVmTfmLB9pLLclj7YmP2eedAjklpy4LGrU2ijoiy6Xqpuybv7OgJe i+ez31s65NEV8+X/ByeX1cstR988z6N8MHowCQYDVR0TBAIwADAdBgNVHQ4EFgQU yZN6AIX/TNnIJ9GwAa/NRN3ujHAwHwYDVR0jBBgwFoAUXn6CHYzPUqU4JVP8g+OS WeDYjhcwDgYDVR0PAQH/BAQDAgeAMB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEF BQcDBDAKBggqhkjOPQQDAgNIADBFAiEA+bFzXRoJ4PCQbhAAtpkcMjt0vNj5rEW0 lOMBGDNyaWkCIB1vmM7PcZzv/c9bIrxF5kqv6QXomouhByUfeNUTbpKW -----END CERTIFICATE-----
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.
The defect
In Python the end anchor `$` also matches in front of a final newline. `DIGEST_RE.match` and `COMMIT_RE.match` in `tools/release_record_conformance.py` therefore accepted `<40 hex>\n` as a `source_commit` and `sha256:<64 hex>\n` as an artifact digest. The contract says 40 / 64 lowercase hex digits. Found by a test of the pre-check (#29), reproduced here.
Proof first (against the verifier of devel, before the fix; record re-authenticated so the refusal has to come from the contract check)
The old verifier is read from git inside the test (`test_the_verifier_of_d2d8ec7_did_not_refuse_it_for_that_reason`), so the proof runs in CI; where the history is required its absence is a failure, not a skip.
The fix
Both patterns end with `\Z`. Two lines of the verifier.
The frozen yardstick: amended explicitly, not edited
Not changed, and why
Checks
Merge is for the owner.