Skip to content

Commit 12c20fb

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 12c20fb

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-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: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,22 @@ 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"] == {
91+
"kind": "dsse",
92+
"version": "0.0.1"
93+
}
94+
8695
# converting to a bundle and verifying as a bundle also works
8796
bundle = attestation.to_bundle()
8897
Verifier.staging().verify_dsse(bundle, policy.UnsafeNoOp())
@@ -111,6 +120,8 @@ def in_validity_period(_: IdentityToken) -> bool:
111120
monkeypatch.setattr(IdentityToken, "in_validity_period", in_validity_period)
112121

113122
trust_config = ClientTrustConfig.staging()
123+
# Make sure we choose the rekor version: currently v1
124+
trust_config.force_tlog_version = 1
114125
sign_ctx = SigningContext.from_trust_config(trust_config)
115126

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

132143
trust_config = ClientTrustConfig.staging()
144+
# Make sure we choose the rekor version: currently v1
145+
trust_config.force_tlog_version = 1
133146
sign_ctx = SigningContext.from_trust_config(trust_config)
134147

135148
with pytest.raises(impl.AttestationError):
@@ -240,6 +253,9 @@ def test_verify_with_timestamp(self) -> None:
240253
Verifier.production(offline=True).verify_dsse(bundle, policy.UnsafeNoOp())
241254

242255
def test_verify_with_timestamp_and_rekor2_entry(self) -> None:
256+
# Note that the pypi-attestations does not currently create attestatations with rekor2
257+
# entries. This test still asserts that verification works
258+
243259
# Our checked-in asset has this identity.
244260
pol = policy.Identity(identity="jku@goto.fi", issuer="https://github.com/login/oauth")
245261

0 commit comments

Comments
 (0)