From f08bd47168f40308211a2c6e2805c0ef5bbbc92c Mon Sep 17 00:00:00 2001 From: William Woodruff Date: Sun, 4 Feb 2024 09:24:16 +0100 Subject: [PATCH] rekor/checkpoint: handle missing ancillary data Signed-off-by: William Woodruff --- sigstore/_internal/rekor/checkpoint.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sigstore/_internal/rekor/checkpoint.py b/sigstore/_internal/rekor/checkpoint.py index 177b9e2c..3c130054 100644 --- a/sigstore/_internal/rekor/checkpoint.py +++ b/sigstore/_internal/rekor/checkpoint.py @@ -58,7 +58,7 @@ class LogCheckpoint(BaseModel): - an origin, e.g. "rekor.sigstage.dev - 8050909264565447525" - the size of the log, - the hash of the log, - - and any ancillary contants, e.g. "Timestamp: 1679349379012118479" + - and any optional ancillary contants, e.g. "Timestamp: 1679349379012118479" See: """ @@ -75,7 +75,7 @@ def from_text(cls, text: str) -> LogCheckpoint: """ lines = text.strip().split("\n") - if len(lines) < 4: + if len(lines) < 3: raise CheckpointError("Malformed LogCheckpoint: too few items in header!") origin = lines[0] @@ -99,12 +99,7 @@ def to_text(self) -> str: See class definition for a prose description of the format. """ return "\n".join( - [ - self.origin, - str(self.log_size), - self.log_hash, - ] - + self.other_content + [self.origin, str(self.log_size), self.log_hash, *self.other_content] )