public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/python] main: Add a test to verify tarballs with sigstore
@ 2026-10-27 10:43 
  0 siblings, 0 replies; only message in thread
From:  @ 2026-10-27 10:43 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : tests/python
            Branch : main
            Commit : b638ee25c2055d19bb431ac3c8fcacab962e847c
            Author : Miro Hrončok <miro@hroncok.cz>
            Date   : 2026-10-27T11:33:56+01:00
            Stats  : +58/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/tests/python/c/b638ee25c2055d19bb431ac3c8fcacab962e847c?branch=main

            Log:
            Add a test to verify tarballs with sigstore

Assisted-By: Claude Sonnet 5

---
diff --git a/sigstore/sigstore.fmf b/sigstore/sigstore.fmf
new file mode 100644
index 0000000..618361c
--- /dev/null
+++ b/sigstore/sigstore.fmf
@@ -0,0 +1,24 @@
+summary: Verify the CPython release tarball used for the build with Sigstore
+description: |
+    Verifies that the upstream CPython source release tarball actually
+    used to build the package was signed by the expected release manager
+    identity, as documented at
+    https://www.python.org/downloads/metadata/sigstore/ (see PEP 761).
+
+    The tarball is found in $TMT_SOURCE_DIR, which tmt populates when
+    this test runs as part of a discover phase with
+    dist-git-source: true (and no url, so it resolves to the dist-git
+    checkout of the package itself rather than this shared tests repo).
+    This fails if that directory does not contain exactly one release
+    tarball.
+
+    IDENTITY and ISSUER must be set to the release manager identity.
+
+path: /sigstore
+test: ./sigstore.sh
+require: [python3, bash, wget]
+
+tier: 1
+tag: [sigstore]
+
+duration: 5m

diff --git a/sigstore/sigstore.sh b/sigstore/sigstore.sh
new file mode 100755
index 0000000..6f5d27d
--- /dev/null
+++ b/sigstore/sigstore.sh
@@ -0,0 +1,34 @@
+#!/bin/bash -eux
+TMT_SOURCE_DIR=${TMT_SOURCE_DIR:?TMT_SOURCE_DIR must be set; run this test from a discover phase with dist-git-source: true}
+IDENTITY=${IDENTITY:?IDENTITY must be set (see https://www.python.org/downloads/metadata/sigstore/)}
+ISSUER=${ISSUER:?ISSUER must be set (see https://www.python.org/downloads/metadata/sigstore/)}
+
+# Find the one release tarball among the downloaded dist-git sources
+tarballs=$(find "$TMT_SOURCE_DIR" -maxdepth 1 -type f \
+    \( -name '*.tar.gz' -o -name '*.tar.xz' -o -name '*.tar.bz2' -o -name '*.tgz' \))
+tarball_count=$(printf '%s\n' "$tarballs" | grep -c . || true)
+
+if [ "$tarball_count" -ne 1 ]; then
+    echo "FAIL: expected exactly one release tarball in \$TMT_SOURCE_DIR ($TMT_SOURCE_DIR), found $tarball_count" >&2
+    printf '%s\n' "$tarballs" >&2
+    exit 1
+fi
+
+FILE="$tarballs"
+FILENAME="$(basename "$FILE")"
+
+# The upstream ftp directory drops any prerelease suffix from the file's
+# version, e.g. Python-3.14.0rc3.tar.xz is published under .../3.14.0/
+VERSION="$(echo "$FILENAME" | sed -E 's/^Python-([0-9]+\.[0-9]+\.[0-9]+).*/\1/')"
+BUNDLEURL="https://www.python.org/ftp/python/${VERSION}/${FILENAME}.sigstore"
+wget -O "${FILENAME}.sigstore" "$BUNDLEURL"
+
+python3 -m venv sigstore_venv
+sigstore_venv/bin/pip install sigstore
+
+sigstore_venv/bin/python -m sigstore verify identity \
+    --bundle "${FILENAME}.sigstore" \
+    --cert-identity "$IDENTITY" \
+    --cert-oidc-issuer "$ISSUER" \
+    "$FILE"
+

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-27 10:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-27 10:43 [tests/python] main: Add a test to verify tarballs with sigstore 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox