8000 cache the kindversion · ramonpetgrave64/sigstore-python@e4470a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit e4470a9

Browse files
cache the kindversion
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
1 parent f2e6479 commit e4470a9

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

sigstore/models.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
from sigstore_protobuf_specs.dev.sigstore.common.v1 import Rfc3161SignedTimestamp
5959
from sigstore_protobuf_specs.dev.sigstore.rekor import v1 as rekor_v1
6060
from sigstore_protobuf_specs.dev.sigstore.rekor.v1 import (
61-
InclusionProof,
61+
InclusionProof, KindVersion
6262
)
6363

6464
from sigstore import dsse
@@ -172,6 +172,11 @@ class LogEntry:
172172
log entry.
173173
"""
174174

175+
kind_version: KindVersion
176+
"""
177+
The kind and version of the log entry.
178+
"""
179+
175180
@classmethod
176181
def _from_response(cls, dict_: dict[str, Any]) -> LogEntry:
177182
"""
@@ -230,6 +235,7 @@ def _from_dict_rekor(cls, dict_: dict[str, Any]) -> LogEntry:
230235
tlog_entry.inclusion_promise.signed_entry_timestamp
231236
).decode()
232237
),
238+
kind_version=tlog_entry.kind_version,
233239
)
234240

235241
def _to_rekor(self) -> rekor_v1.TransparencyLogEntry:
@@ -258,32 +264,10 @@ def _to_rekor(self) -> rekor_v1.TransparencyLogEntry:
258264
integrated_time=self.integrated_time,
259265
inclusion_promise=inclusion_promise, # type: ignore[arg-type]
260266
inclusion_proof=inclusion_proof,
267+
kind_version=self.kind_version,
261268
canonicalized_body=base64.b64decode(self.body),
262269
)
263270

264-
# NOTE fix the canonicalized_body
265-
import json
266-
tlog_entry.canonicalized_body = bytes(json.dumps({
267-
# **json.loads(tlog_entry.canonicalized_body),
268-
'kind': 'hashedrekord',
269-
'api_version': '0.0.2',
270-
'spec': {
271-
'signature': json.loads(tlog_entry.canonicalized_body)['signature'],
272-
'data': json.loads(tlog_entry.canonicalized_body)['data']
273-
}
274-
}), encoding='utf-8')
275-
276-
# Fill in the appropriate kind
277-
body_entry: ProposedEntry = TypeAdapter(ProposedEntry).validate_json(
278-
tlog_entry.canonicalized_body
279-
)
280-
if not isinstance(body_entry, (Hashedrekord, Dsse)):
281-
raise InvalidBundle("log entry is not of expected type")
282-
283-
tlog_entry.kind_version = rekor_v1.KindVersion(
284-
kind=body_entry.kind, version=body_entry.api_version
285-
)
286-
287271
return tlog_entry
288272

289273
def encode_canonical(self) -> bytes:

0 commit comments

Comments
 (0)
0