Repository navigation
fix(trace_verify/_witness): enforce lowercase hex on signature, registry_key, and witness_key and reject non-finite JSON constants (#149) - #153
Conversation
rajnisht7
left a comment
There was a problem hiding this comment.
the changes looks good, just one thing kindly expand the regression test right now it only hits NaN. Explicit cases for Infinity / -Infinity (and a couple of the other hex edges the new checks already reject)
|
Thanks @rajnisht7! Addressed in the latest commit: expanded |
rajnisht7
left a comment
There was a problem hiding this comment.
the expansion in 185ec39 is good overall, but it dropped the independent REGISTRY_KEY coverage that 0eaba72 had.
Currently bad_key is derived only from WITNESS_KEY and then passed to both parameters.
kindly mutate REGISTRY_KEY for the registry_key cases as well (at least .upper(), whitespace, truncated, non-hex), same as was done for WITNESS_KEY.
Something like:
for key, base in (('witness_key', WITNESS_KEY), ('registry_key', REGISTRY_KEY)):
for bad in (base.upper(), ' ' + base, base[:-2], 'zz' * 32):
with self.subTest(key=key, bad=bad):
self.assertFalse(self.check(**{key: bad})['verified'])|
Thanks @rajnisht7! Updated |
…try_key, and witness_key and reject non-finite JSON constants (agentrust-io#149) - Require 64-character lowercase hex on registry_key and witness_key and 128-character lowercase hex on checkpoint['signature'] in trace_verify._witness.verify. - Reject non-finite JSON constants (NaN, Infinity, -Infinity) in trace_verify._witness.load_json. - Expand tests/test_witness_receipt.py to independently mutate WITNESS_KEY and REGISTRY_KEY across uppercase, whitespace-padded, truncated, and non-hex inputs alongside signature and non-finite JSON edge cases. Closes agentrust-io#149 Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@users.noreply.github.com>
cc9df63 to
ef6637f
Compare
|
Thanks @rajnisht7! Updated |
What and why
Closes #149
^[0-9a-f]{64}$) onregistry_keyandwitness_keyand 128-character lowercase hex (^[0-9a-f]{128}$) oncheckpoint['signature']intrace_verify._witness.verify.NaN,Infinity,-Infinity) intrace_verify._witness.load_json.subTest-isolated regression tests intests/test_witness_receipt.pyindependently mutatingWITNESS_KEYandREGISTRY_KEYalongsidesignatureand non-finite JSON inputs.Validation
python -m unittest discover -s tests -q— passed (407 tests)python -m pytest tests/test_witness_receipt.py -q— passed (31 passed, 22 subtests passed)python tools/validate_registry.py— passed (OK: 3 day file(s) valid)python tools/validate_producers.py— passed (OK: 3 producer key file(s) valid)python -m ruff check src/trace_verify/_witness.py tests/test_witness_receipt.py— passed (All checks passed!)Registry impact
registry/Existing entries are append-only. If you are changing one, say why here: mirrors
and auditors may already have observed the current commit hashes, and a rewrite
diverges them.
Checks
pytestpassestools/validate_registry.py,tools/validate_producers.py)docs/anchor-format.mdis updated in the same PR, and existing inclusion proofs still verify