Repository navigation
feat: verify endorsed receipt rotations - #38
Conversation
|
Warning Review limit reached
Next review available in: 18 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThis change adds strict rotation endorsement APIs, integrates endorsements into rotated-chain verification, exposes session and endorsement options in the CLI, updates version and documentation metadata, and adds cross-language conformance fixtures and failure-case tests. ChangesRotation verification
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant verify_chain
participant verify_rotation_endorsement
participant _verify_chain_list
CLI->>verify_chain: provide root key, session ID, and endorsements
verify_chain->>verify_rotation_endorsement: validate endorsements
verify_chain->>_verify_chain_list: verify receipt chain and transitions
_verify_chain_list-->>verify_chain: return ChainResult
verify_chain-->>CLI: report verification status
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (3)
pipelock_verify/_rotation.py (1)
208-215: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win"Bounded" read happens after the whole file is loaded.
read_bytes()pulls the entire file into memory; the_MAX_BYTESguard only applies afterwards insideverify_rotation_endorsement. Reading_MAX_BYTES + 1bytes keeps the docstring's bound honest for oversized or non-regular files.♻️ Proposed refactor
file = Path(path) try: - data = file.read_bytes() + with file.open("rb") as handle: + data = handle.read(_MAX_BYTES + 1) except OSError as exc: raise InvalidReceiptError(f"read rotation endorsement: {exc}") from exc return verify_rotation_endorsement(data)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pipelock_verify/_rotation.py` around lines 208 - 215, Update load_rotation_endorsement to read at most _MAX_BYTES + 1 bytes before calling verify_rotation_endorsement, preserving the existing OSError-to-InvalidReceiptError handling. Ensure the bounded read works for oversized or non-regular files and allows downstream validation to detect data exceeding _MAX_BYTES.pipelock_verify/_verify.py (1)
1170-1178: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winNormalize marker hex case like the successor key.
Line 1188 lowercases
receipt["signer_key"]andexpected_keyis lowercased at line 1111, butmarker.get("prior_signer_key")(and the endorsement'sprior_signer_key, which_rotation._require_hexforces to lowercase) are compared as-is. An emitter that writes uppercase hex inkey_transitionwould fail a legitimate rotation. Normalizing keeps the comparison symmetric across the four language implementations.♻️ Proposed refactor
- if marker.get("prior_signer_key") != expected_key: + if str(marker.get("prior_signer_key", "")).lower() != expected_key:🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pipelock_verify/_verify.py` around lines 1170 - 1178, Normalize marker.get("prior_signer_key") to lowercase before comparing it with expected_key in the key-transition validation, matching the existing normalization of receipt["signer_key"] and expected_key. Apply the same normalization to the endorsement prior_signer_key comparison so uppercase hex remains valid consistently across implementations.README.md (1)
98-101: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument the
session_openbinding requirement.
_verify_chain_list(pipelock_verify/_verify.py lines 1088-1107) requires, whenever endorsements are supplied, that everysession_control.openin the chain carryrecorder_session == session_idand that the root segment contain at least one such open. A chain without a signedsession_openfails closed with "root receipt segment has no signed session_open recorder binding", which this section does not prepare the reader for.📝 Proposed docs addition
The endorsement is verified under the retiring key and bound to the exact prior sequence, tail hash, recorder session, and successor key. Missing, altered, duplicate, replayed, cross-session, and unused endorsements fail closed. + +`session_id` must equal the `recorder_session` in the chain's signed +`session_open` records, and the root segment must contain one; chains without +a signed session open cannot be verified with endorsements.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@README.md` around lines 98 - 101, Update the endorsement verification documentation near the described binding requirements to state that supplied endorsements require every session_control.open to match session_id and the root segment to contain at least one signed session_open; document that chains without this binding fail closed with the corresponding validation error.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pipelock_verify/__main__.py`:
- Around line 107-114: Change the --rotation-endorsement argument in the
argument parser to use default=None instead of a mutable list, then normalize
args.rotation_endorsement at its consumption site (such as the
endorsement-loading comprehension) so missing values behave as an empty
collection while repeated main() calls remain isolated.
In `@pipelock_verify/_rotation.py`:
- Around line 199-204: Update the rotation endorsement verification flow around
Ed25519PublicKey.from_public_bytes: load the key separately from verify, catch
failures from key construction, and translate them into InvalidReceiptError.
Keep InvalidSignature handling for verification failures and preserve the
existing error message/context.
In `@pipelock_verify/_verify.py`:
- Line 1139: Update the sequencing logic around segment_base_seq and the gap
check so the root segment requires its first receipt to have chain_seq 0,
preserving the existing absolute-sequence validation. Apply segment-relative
sequencing only after a key_transition, and ensure the legacy _GENESIS_HASH path
cannot accept a truncated prefix without the bound g1: session_open genesis
validation.
---
Nitpick comments:
In `@pipelock_verify/_rotation.py`:
- Around line 208-215: Update load_rotation_endorsement to read at most
_MAX_BYTES + 1 bytes before calling verify_rotation_endorsement, preserving the
existing OSError-to-InvalidReceiptError handling. Ensure the bounded read works
for oversized or non-regular files and allows downstream validation to detect
data exceeding _MAX_BYTES.
In `@pipelock_verify/_verify.py`:
- Around line 1170-1178: Normalize marker.get("prior_signer_key") to lowercase
before comparing it with expected_key in the key-transition validation, matching
the existing normalization of receipt["signer_key"] and expected_key. Apply the
same normalization to the endorsement prior_signer_key comparison so uppercase
hex remains valid consistently across implementations.
In `@README.md`:
- Around line 98-101: Update the endorsement verification documentation near the
described binding requirements to state that supplied endorsements require every
session_control.open to match session_id and the root segment to contain at
least one signed session_open; document that chains without this binding fail
closed with the corresponding validation error.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 7ddda931-0148-42aa-93a2-c8b7511e9fba
📒 Files selected for processing (12)
CHANGELOG.mdREADME.mdpipelock_verify/__init__.pypipelock_verify/__main__.pypipelock_verify/_rotation.pypipelock_verify/_verify.pypyproject.tomltests/conformance/g1-rotated-close-count-valid.jsonltests/conformance/g1-rotated-twice-valid.jsonltests/conformance/g1-rotation-endorsement-2.jsontests/conformance/g1-rotation-endorsement.jsontests/test_conformance.py
8bf1ebc to
0c593bf
Compare
|
/review deep |
AI Review: security deep (
|
|
/review deep |
AI Review: security deep (
|
|
/review deep |
AI Review: security deep (
|
|
/review deep |
AI Review: security deep (
|
Summary
Summary by CodeRabbit
New Features
Documentation