Skip to content

Commit 0957bdf

Browse files
committed
Do not enable rekor2 signing yet
* Force Rekor tlog version 1 when signing * Make sure this is the case with a check in test_roundtrip() Not that rekor v2 entries are still considered valid in verification already, and that timestamps are included in the attestation even if the entry is from rekor v1
1 parent 8551339 commit 0957bdf

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/pypi_attestations/_cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ def _sign(args: argparse.Namespace) -> None:
430430
_die(f"Failed to detect identity: {identity_error}")
431431

432432
trust_config = ClientTrustConfig.staging() if args.staging else ClientTrustConfig.production()
433+
# Make sure we choose the rekor version: currently v1
434+
trust_config.force_tlog_version = 1
435+
433436
signing_ctx = SigningContext.from_trust_config(trust_config)
434437

435438
# Validates that every file we want to sign exist but none of their attestations

test/test_impl.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,19 @@ class TestAttestation:
7676
@online
7777
def test_roundtrip(self, id_token: IdentityToken) -> None:
7878
trust_config = ClientTrustConfig.staging()
79+
# Make sure we choose the rekor version: currently v1
80+
trust_config.force_tlog_version = 1
7981
sign_ctx = SigningContext.from_trust_config(trust_config)
8082

8183
with sign_ctx.signer(id_token) as signer:
8284
attestation = impl.Attestation.sign(signer, dist)
8385

8486
attestation.verify(policy.UnsafeNoOp(), dist, staging=True)
8587

88+
# ensure we only produce attestations with rekor v1 entries for now:
89+
for entry in attestation.verification_material.transparency_entries:
90+
assert entry["kindVersion"] == {"kind": "dsse", "version": "0.0.1"}
91+
8692
# converting to a bundle and verifying as a bundle also works
8793
bundle = attestation.to_bundle()
8894
Verifier.staging().verify_dsse(bundle, policy.UnsafeNoOp())
@@ -111,6 +117,8 @@ def in_validity_period(_: IdentityToken) -> bool:
111117
monkeypatch.setattr(IdentityToken, "in_validity_period", in_validity_period)
112118

113119
trust_config = ClientTrustConfig.staging()
120+
# Make sure we choose the rekor version: currently v1
121+
trust_config.force_tlog_version = 1
114122
sign_ctx = SigningContext.from_trust_config(trust_config)
115123

116124
with sign_ctx.signer(id_token, cache=False) as signer:
@@ -130,6 +138,8 @@ def get_bundle(*_: Any) -> Bundle:
130138
monkeypatch.setattr(sigstore.sign.Signer, "sign_dsse", get_bundle)
131139

132140
trust_config = ClientTrustConfig.staging()
141+
# Make sure we choose the rekor version: currently v1
142+
trust_config.force_tlog_version = 1
133143
sign_ctx = SigningContext.from_trust_config(trust_config)
134144

135145
with pytest.raises(impl.AttestationError):
@@ -240,6 +250,9 @@ def test_verify_with_timestamp(self) -> None:
240250
Verifier.production(offline=True).verify_dsse(bundle, policy.UnsafeNoOp())
241251

242252
def test_verify_with_timestamp_and_rekor2_entry(self) -> None:
253+
# Note that the pypi-attestations does not currently create attestatations with rekor2
254+
# entries. This test still asserts that verification works
255+
243256
# Our checked-in asset has this identity.
244257
pol = policy.Identity(identity="jku@goto.fi", issuer="https://github.com/login/oauth")
245258

0 commit comments

Comments
 (0)