Defer all GPG work to signing time - #31
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #31 +/- ##
==========================================
+ Coverage 95.08% 95.43% +0.35%
==========================================
Files 15 15
Lines 1057 1074 +17
==========================================
+ Hits 1005 1025 +20
+ Misses 52 49 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
TRO.__init__spawned agpgprocess, resolved the configured fingerprint against the local keyring, and wrote the exported public key into the declaration — on every instantiation, whatever the caller intended to do. This moves all of it to signing time.gpgbinary to construct a TRO, add arrangements or performances, save, report orverify-timestamp. A missing key no longer surfaces asKeyError(<fingerprint>)from a constructor, but asRuntimeErrornaming the key and the keyring, at signing time.import gnupgis lazy too, so the package works withoutpython-gnupginstalled.trov:publicKeyis now structurally the signing key. Previously everyTRO(...)overwrote it from its own keyring, so a long-lived TRO ended up with whatever the last process to touch it had - and any write after signing silently replaced the key the.sigwas computed over.signnow attaches the key, saves, and only then hashes and signs, so the declaration on disk, the.sigand the.tsralways agree by construction.Changes:
__init__stores config only; new lazy_gpg(),_resolve_key_id()andattach_public_key();request_timestamp()attaches the key and saves before hashing.cli.pyunchanged.tro.gpgis no longer a public attribute - the only in-repo user was a test helper.Compatibility: existing signed TROs are unaffected; nothing about the signature or timestamp format changes.
trov:publicKeyis defined but not required by the schema, so pre-signing declarations stay valid without it. A profile-suppliedtrov:publicKeynow survives until signing replaces it.Tests: the
create_tro_with_gpghelper loses its hand-assembly workaround and passes the fingerprint through normally. New coverage: key absent after a plainsave()and present after signing; build-and-save against an empty keyring; a test proving GPG is never reached outside signing; and a round-trip test asserting the timestamped payload matches what a keyless verifier recomputes from the saved files - confirmed to fail if the injection is moved intotrs_signature(). 146 passing.Docs:
README.md,docs/installation.mdanddocs/usage.mdnow mark GPG as needed forsignonly, and the Python example no longer callstrs_signature()beforerequest_timestamp()(that would write a.sigpredating the key injection).