Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Sigstore v3 is installed in download server #167

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions add_to_pydotorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import subprocess
import sys
from os import path
from typing import Any, Generator
from typing import Any, Generator, NoReturn

import requests


# Copied from release.py
def error(*msgs: Any) -> None:
def error(*msgs: Any) -> NoReturn:
print("**ERROR**", file=sys.stderr)
for msg in msgs:
print(msg, file=sys.stderr)
Expand Down Expand Up @@ -333,6 +333,29 @@
os.path.exists(filename + ".sig") and os.path.exists(filename + ".crt")
)

# Ensure that Sigstore CLI installed on the download server is
# at least v3.0.0 or later to ensure valid Sigstore bundles are generated.
try:
sigstore_version_stdout = subprocess.check_output(

Check warning on line 339 in add_to_pydotorg.py

View check run for this annotation

Codecov / codecov/patch

add_to_pydotorg.py#L338-L339

Added lines #L338 - L339 were not covered by tests
["python3", "-m", "sigstore", "--version"]
)
sigstore_version_match = re.search(

Check warning on line 342 in add_to_pydotorg.py

View check run for this annotation

Codecov / codecov/patch

add_to_pydotorg.py#L342

Added line #L342 was not covered by tests
r"([0-9][0-9.]*[0-9])", sigstore_version_stdout.decode()
)
if not sigstore_version_match:
error(

Check warning on line 346 in add_to_pydotorg.py

View check run for this annotation

Codecov / codecov/patch

add_to_pydotorg.py#L345-L346

Added lines #L345 - L346 were not covered by tests
f"Couldn't determine version of Sigstore CLI: {sigstore_version_stdout.decode()}"
sethmlarson marked this conversation as resolved.
Show resolved Hide resolved
)
sigstore_version = sigstore_version_match.group(1)
sigstore_major_version = int(sigstore_version.partition(".")[0])
if sigstore_major_version < 3:
error(

Check warning on line 352 in add_to_pydotorg.py

View check run for this annotation

Codecov / codecov/patch

add_to_pydotorg.py#L349-L352

Added lines #L349 - L352 were not covered by tests
f"Sigstore v3 or later must be installed (currently {sigstore_version}), run python -m pip install -r requirements.txt"
sethmlarson marked this conversation as resolved.
Show resolved Hide resolved
)
except subprocess.CalledProcessError:
error("Couldn't determine version of Sigstore CLI")
print(f"Sigstore CLI installed is version v{sigstore_version}")

Check warning on line 357 in add_to_pydotorg.py

View check run for this annotation

Codecov / codecov/patch

add_to_pydotorg.py#L355-L357

Added lines #L355 - L357 were not covered by tests

# Skip files that already have a signature (likely source distributions)
unsigned_files = [
filename for filename in filenames if not has_sigstore_signature(filename)
Expand Down