Skip to content

Commit add5ac4

Browse files
committed
conformance: Support --trusted-root
conformance clients are given "--trusted-root" but sigstore-python requires "--trust-config". Build a trust config and provide that in the conformance client script. The conformance scipt is getting closer and closer to the point where just tweaking argv is not really the smart thing to do... but it's still manageable. This revealed a new bug so one test remains "xfail". Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 606c077 commit add5ac4

File tree

2 files changed

+54
-14
lines changed

2 files changed

+54
-14
lines changed

.github/workflows/conformance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
- uses: sigstore/sigstore-conformance@fd90e6b0f3046f2276a6659481de6df495dea3b9 # v0.0.18
2828
with:
2929
entrypoint: ${{ github.workspace }}/test/integration/sigstore-python-conformance
30-
xfail: "test_verify_with_trust_root test_verify_dsse_bundle_with_trust_root" # see issue 821
30+
xfail: "test_verify_dsse_bundle_with_trust_root" # see issue 1442

test/integration/sigstore-python-conformance

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,27 @@
44
A wrapper to convert `sigstore-conformance` CLI protocol invocations to match `sigstore-python`.
55
"""
66

7-
7+
import json
88
import os
99
import sys
10+
from contextlib import suppress
11+
from string import Template
12+
from tempfile import NamedTemporaryFile
13+
14+
# The signing config in this trust_config is not used: it's just here
15+
# so the built trustconfig is complete
16+
trust_config = {
17+
"mediaType": "application/vnd.dev.sigstore.clienttrustconfig.v0.1+json",
18+
"SigningConfig": {
19+
"mediaType": "application/vnd.dev.sigstore.signingconfig.v0.2+json",
20+
"caUrls": [{ "url": "https://fulcio.example.com" }],
21+
"oidcUrls": [],
22+
"rekorTlogUrls": [{ "url": "https://rekor.example.com" }],
23+
"tsaUrls": [],
24+
"rekorTlogConfig": {"selector": "ANY"},
25+
"tsaConfig": {"selector": "ANY"}
26+
}
27+
}
1028

1129
SUBCMD_REPLACEMENTS = {
1230
"sign-bundle": "sign",
@@ -32,17 +50,39 @@ if "--staging" in fixed_args:
3250
command.append("--staging")
3351
fixed_args.remove("--staging")
3452

35-
# Fix-up the subcommand: the conformance suite uses `verify`, but
36-
# `sigstore` requires `verify identity` for identity based verifications.
37-
subcommand, *fixed_args = fixed_args
38-
if subcommand == "sign":
39-
command.append("sign")
40-
elif subcommand == "verify":
41-
command.extend(["verify", "identity"])
42-
else:
43-
raise ValueError(f"unsupported subcommand: {subcommand}")
53+
# We may get "--trusted-root" as argument but sigstore-python wants "--trust-config":
54+
trusted_root_path = None
55+
with suppress(ValueError):
56+
i = fixed_args.index("--trusted-root")
57+
trusted_root_path = fixed_args[i+1]
58+
fixed_args.pop(i)
59+
fixed_args.pop(i)
60+
61+
# If we did get a trustedroot, write a matching trustconfig into a temp file
62+
with NamedTemporaryFile(mode="wt") as temp_file:
63+
if trusted_root_path is not None:
64+
with open(trusted_root_path) as f:
65+
trusted_root=json.load(f)
66+
trust_config["trustedRoot"] = trusted_root
67+
68+
json.dump(trust_config, temp_file)
69+
temp_file.flush()
70+
71+
command.extend(["--trust-config", temp_file.name])
72+
73+
# Fix-up the subcommand: the conformance suite uses `verify`, but
74+
# `sigstore` requires `verify identity` for identity based verifications.
75+
subcommand, *fixed_args = fixed_args
76+
if subcommand == "sign":
77+
command.append("sign")
78+
elif subcommand == "verify":
79+
command.extend(["verify", "identity"])
80+
else:
81+
raise ValueError(f"unsupported subcommand: {subcommand}")
4482

45-
# Replace incompatible flags.
46-
command.extend(ARG_REPLACEMENTS[arg] if arg in ARG_REPLACEMENTS else arg for arg in fixed_args)
83+
# Replace incompatible flags.
84+
command.extend(
85+
ARG_REPLACEMENTS[arg] if arg in ARG_REPLACEMENTS else arg for arg in fixed_args
86+
)
4787

48-
os.execvp("sigstore", command)
88+
os.execvp("sigstore", command)

0 commit comments

Comments
 (0)