Skip to content

Commit 6258926

Browse files
worarkound entry body parsing
Signed-off-by: Ramon Petgrave <ramon.petgrave64@gmail.com>
1 parent cd52b93 commit 6258926

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

sigstore/verify/verifier.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import logging
2323
from datetime import datetime, timezone
2424
from typing import cast
25+
import json
2526

2627
import rekor_types
2728
from cryptography.exceptions import InvalidSignature
@@ -432,7 +433,19 @@ def verify_dsse(
432433
and entry._kind_version.version == "0.0.2"
433434
):
434435
try:
435-
entry_body = v2.Entry().from_json(base64.b64decode(entry.body))
436+
# entry_body = v2.Entry().from_json(base64.b64decode(entry.body))
437+
# A potential issue with the returned body not parsing properly.
438+
# perhaps the json_name in the protos.
439+
_dict = json.loads(base64.b64decode(entry.body))
440+
actual_body = v2.Entry(
441+
kind=_dict['kind'],
442+
api_version=_dict['apiVersion'],
443+
spec=v2.Spec(
444+
hashed_rekord_v0_0_2=v2.HashedRekordLogEntryV002.from_dict(
445+
_dict['spec']['dsseV002']
446+
)
447+
)
448+
)
436449
except ValidationError as exc:
437450
raise VerificationError(f"invalid DSSE log entry: {exc}")
438451

@@ -546,7 +559,19 @@ def verify_artifact(
546559
entry._kind_version.kind == "hashedrekord"
547560
and entry._kind_version.version == "0.0.2"
548561
):
549-
actual_body = v2.Entry().from_json(base64.b64decode(entry.body))
562+
_dict = json.loads(base64.b64decode(entry.body))
563+
print(_dict)
564+
# A potential issue with the returned body not parsing properly.
565+
# perhaps the json_name in the protos.
566+
actual_body = v2.Entry(
567+
kind=_dict['kind'],
568+
api_version=_dict['apiVersion'],
569+
spec=v2.Spec(
570+
hashed_rekord_v0_0_2=v2.HashedRekordLogEntryV002.from_dict(
571+
_dict['spec']['hashedRekordV002']
572+
)
573+
)
574+
)
550575
expected_body = v2.Entry(
551576
kind=entry._kind_version.kind,
552577
api_version=entry._kind_version.version,

0 commit comments

Comments
 (0)