Repository navigation
Verify pinned parser digests before the gnn arm parses, and always ask upstream for the pin tag - #31
Merged
Merged
Conversation
scripts/release_check.py's gnn arm ran python -m gnn.importers check before scripts/validate_gnn_spec.py. The shared reader parses every *.gnn.md with the installed parser (gnn.importers._validate_spec), so a tampered pinned parser was executed, and its verdict trusted, before the pin's digests were checked. The validator now runs first: it verifies the digests before it parses, and the arm aborts there when they do not match. --verify-tag-remote accepted a locally resolved tag without asking upstream, so a tag that moved after a checkout fetched it passed. tag_binding always queries git ls-remote when the flag is given: the upstream answer decides, and an unanswerable upstream ends the run as not run rather than a pass. Reproduced with a tampered src/gnn/parsers/markdown_parser.py (a pinned file): before the reorder gnn.importers check imported it and printed 'verdict: ok' ahead of the digest mismatch; after it the arm stops at the digest check and the parser never runs. A local bare remote whose tag moved off the pinned commit was accepted from a stale checkout; it now fails as tag-commit-mismatch. tests/test_release_gate.py pins the order (digest verification before any parsing) and tests/test_gnn_pin_binding.py covers the stale local tag and the unanswerable upstream with real git and no network. gate-metrics.md is regenerated for the new test count (115).
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.
Both findings reproduce on main at 248f98a.
P1: the gnn arm parsed before it verified parser digests
The arm ran
python -m gnn.importers checkbeforescripts/validate_gnn_spec.py.gnn.importers checkcalls_validate_spec, which imports the installed parser and parses every spec file, so a tampered pinned parser ran before the pin digests were checked.Reproduced with a tampered pinned file (
src/gnn/parsers/markdown_parser.py, which the pin records) exposed on PYTHONPATH, running the repository gate arm:Before, the tampered parser is imported, the reader prints its verdict, and only then does the digest check abort:
A marker the tampered module writes on import exists after that run, so the parser did execute. After the reorder the digest failure is the first gnn step,
gnn.importers checknever runs, and the marker is absent.P2: --verify-tag-remote did not ask upstream when a local tag existed
tag_bindingreturned the locally resolved tag and never rangit ls-remotewhen the checkout had the tag.Reproduced offline with a local bare upstream whose tag moved to another commit after the clone:
and at CLI level with an unreachable upstream, the run exited 0 and recorded
local object store. After the fix the same invocation exits 2 (not run) when upstream cannot answer, and with upstream reachable the receipt recordsgit ls-remote.Change
scripts/release_check.py: the gnn arm runs the validator first, so the digests are verified before any arm command parses.scripts/validate_gnn_spec.py:tag_bindingalways queries upstream whenremoteis requested; a local tag no longer short-circuits it, and a failed query staysunresolvable-offline(never a pass).tests/test_release_gate.py: pins the arm order (digest verification before any parsing command) and keeps the exact plan assertion.tests/test_gnn_pin_binding.py: stale-local-tag and unanswerable-upstream cases, using real git and no network.docs/gate.md,docs/gnn.md,scripts/README.md, and the regenerateddocs/_generated/gate-metrics.md.Gate
Pre-fix, the new tests fail:
test_remote_is_consulted_when_the_local_tag_resolvesandtest_remote_that_cannot_answer_never_accepts_the_local_tag(binding came back verified from the local store),test_gnn_arm_verifies_the_pinned_parser_digests_before_it_parses(assert 2 < 1) andtest_gnn_arm_runs_the_shared_pin_reader_after_digest_verification(reported command order). All pass at a48cd78.