Skip to content

Commit 64dd17c

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 af0955c commit 64dd17c

File tree

2 files changed

+53
-14
lines changed

2 files changed

+53
-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: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,29 @@
44
A wrapper to convert `sigstore-conformance` CLI protocol invocations to match `sigstore-python`.
55
"""
66

7-
87
import os
98
import sys
9+
from contextlib import suppress
10+
from string import Template
11+
from tempfile import NamedTemporaryFile
12+
13+
# The signing config in the template is just filler: it is not used
14+
TRUST_CONFIG_TEMPLATE = Template("""
15+
{
16+
"mediaType": "application/vnd.dev.sigstore.clienttrustconfig.v0.1+json",
17+
"trustedRoot": ${trusted_root},
18+
"signing_config": {
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+
}
28+
""")
29+
1030

1131
SUBCMD_REPLACEMENTS = {
1232
"sign-bundle": "sign",
@@ -32,17 +52,36 @@ if "--staging" in fixed_args:
3252
command.append("--staging")
3353
fixed_args.remove("--staging")
3454

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}")
55+
# We may get "--trusted-root" as argument but sigstore-python wants "--trust-config":
56+
trusted_root = None
57+
with suppress(ValueError):
58+
i = fixed_args.index("--trusted-root")
59+
trusted_root = fixed_args[i+1]
60+
fixed_args.pop(i)
61+
fixed_args.pop(i)
62+
63+
# If we did get a trustedroot, write a matching trustconfig into a temp file
64+
with NamedTemporaryFile(mode="wt") as temp_file:
65+
if trusted_root is not None:
66+
with open(trusted_root) as f:
67+
content = TRUST_CONFIG_TEMPLATE.substitute(trusted_root=f.read())
68+
temp_file.write(content)
69+
command.extend(["--trust-config", temp_file.name])
70+
temp_file.flush()
71+
72+
# Fix-up the subcommand: the conformance suite uses `verify`, but
73+
# `sigstore` requires `verify identity` for identity based verifications.
74+
subcommand, *fixed_args = fixed_args
75+
if subcommand == "sign":
76+
command.append("sign")
77+
elif subcommand == "verify":
78+
command.extend(["verify", "identity"])
79+
else:
80+
raise ValueError(f"unsupported subcommand: {subcommand}")
4481

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

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

0 commit comments

Comments
 (0)