Skip to content

Commit fdf2edb

Browse files
committed
refactor: drop sigstore-protobuf-specs dependency
Closes #131.
1 parent c69b4c8 commit fdf2edb

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

pyproject.toml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@ readme = "README.md"
1010
license = "Apache-2.0"
1111
license-files = ["LICENSE"]
1212
authors = [{ name = "Trail of Bits", email = "opensource@trailofbits.com" }]
13-
classifiers = [
14-
"Programming Language :: Python :: 3",
15-
]
13+
classifiers = ["Programming Language :: Python :: 3"]
1614
dependencies = [
1715
"cryptography",
1816
"packaging",
1917
"pyasn1 ~= 0.6",
2018
"pydantic >= 2.10.0",
2119
"requests",
2220
"rfc3986",
23-
"sigstore >= 3.5.3, < 3.7",
24-
"sigstore-protobuf-specs",
21+
"sigstore @ git+https://github.com/sigstore/sigstore-python.git@ww/rm-protobufs",
22+
"sigstore-models",
2523
]
2624
requires-python = ">=3.9"
2725

@@ -108,10 +106,6 @@ pyupgrade.keep-runtime-typing = true
108106
[tool.interrogate]
109107
# don't enforce documentation coverage for packaging, testing, the virtual
110108
# environment, or the CLI (which is documented separately).
111-
exclude = [
112-
"env",
113-
"test",
114-
"src/pypi_attestations/__main__.py",
115-
]
109+
exclude = ["env", "test", "src/pypi_attestations/__main__.py"]
116110
ignore-semiprivate = true
117111
fail-under = 100

src/pypi_attestations/_impl.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@
2727
from sigstore._utils import _sha256_streaming
2828
from sigstore.dsse import DigestSet, StatementBuilder, Subject, _Statement
2929
from sigstore.dsse import Envelope as DsseEnvelope
30-
from sigstore.dsse import Error as DsseError
31-
from sigstore.models import Bundle, LogEntry
30+
from sigstore.errors import Error as SigstoreError
31+
from sigstore.models import Bundle
32+
from sigstore.models import TransparencyLogEntry as _TransparencyLogEntry
3233
from sigstore.sign import ExpiredCertificate, ExpiredIdentity
3334
from sigstore.verify import Verifier, policy
34-
from sigstore_protobuf_specs.io.intoto import Envelope as _Envelope
35-
from sigstore_protobuf_specs.io.intoto import Signature as _Signature
35+
from sigstore_models.intoto import Envelope as _Envelope
36+
from sigstore_models.intoto import Signature as _Signature
37+
from sigstore_models.rekor.v1 import TransparencyLogEntry as _TransparencyLogEntryInner
3638

3739
if TYPE_CHECKING: # pragma: no cover
3840
from pathlib import Path
@@ -198,7 +200,7 @@ def sign(cls, signer: Signer, dist: Distribution) -> Attestation:
198200
.predicate_type(AttestationType.PYPI_PUBLISH_V1)
199201
.build()
200202
)
201-
except DsseError as e:
203+
except SigstoreError as e:
202204
raise AttestationError(str(e))
203205

204206
try:
@@ -327,9 +329,9 @@ def to_bundle(self) -> Bundle:
327329

328330
evp = DsseEnvelope(
329331
_Envelope(
330-
payload=statement,
332+
payload=base64.b64encode(statement),
331333
payload_type=DsseEnvelope._TYPE, # noqa: SLF001
332-
signatures=[_Signature(sig=signature)],
334+
signatures=[_Signature(sig=base64.b64encode(signature))],
333335
)
334336
)
335337

@@ -340,7 +342,8 @@ def to_bundle(self) -> Bundle:
340342
raise ConversionError("invalid X.509 certificate") from err
341343

342344
try:
343-
log_entry = LogEntry._from_dict_rekor(tlog_entry) # noqa: SLF001
345+
inner = _TransparencyLogEntryInner.from_dict(tlog_entry)
346+
log_entry = _TransparencyLogEntry(inner)
344347
except (ValidationError, sigstore.errors.Error) as err:
345348
raise ConversionError("invalid transparency log entry") from err
346349

@@ -359,6 +362,9 @@ def from_bundle(cls, sigstore_bundle: Bundle) -> Attestation:
359362

360363
envelope = sigstore_bundle._inner.dsse_envelope # noqa: SLF001
361364

365+
if not envelope:
366+
raise ConversionError("bundle does not contain a DSSE envelope")
367+
362368
if len(envelope.signatures) != 1:
363369
raise ConversionError(f"expected exactly one signature, got {len(envelope.signatures)}")
364370

@@ -367,7 +373,7 @@ def from_bundle(cls, sigstore_bundle: Bundle) -> Attestation:
367373
verification_material=VerificationMaterial(
368374
certificate=base64.b64encode(certificate),
369375
transparency_entries=[
370-
sigstore_bundle.log_entry._to_rekor().to_dict() # noqa: SLF001
376+
sigstore_bundle.log_entry._inner.to_dict() # noqa: SLF001
371377
],
372378
),
373379
envelope=Envelope(

0 commit comments

Comments
 (0)