Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Verify after signing that identity and provider are as documented #51

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

Merged
merged 2 commits into from
Jul 26, 2023
Merged
Changes from all commits
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
46 changes: 46 additions & 0 deletions add-to-pydotorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ def run_cmd(cmd, silent=False, shell=True, **kwargs):

headers = {'Authorization': 'ApiKey %s' % auth_info, 'Content-Type': 'application/json'}

github_oidc_provider = 'https://github.com/login/oauth'
google_oidc_provider = 'https://accounts.google.com'

# Update this list when new release managers are added.
release_to_sigstore_identity_and_oidc_issuer = {
'3.7': ('[email protected]', github_oidc_provider),
'3.8': ('[email protected]', github_oidc_provider),
'3.9': ('[email protected]', github_oidc_provider),
'3.10': ('[email protected]', google_oidc_provider),
'3.11': ('[email protected]', google_oidc_provider),
'3.12': ('[email protected]', google_oidc_provider),
'3.13': ('[email protected]', google_oidc_provider),
}

def get_file_descriptions(release):
v = minor_version_tuple(release)
rx = re.compile
Expand Down Expand Up @@ -262,6 +276,38 @@ def has_sigstore_signature(filename):
else:
print('All release files already signed with Sigstore')

# Verify all the files we expect to be signed with sigstore
# against the documented release manager identities and providers.
try:
sigstore_identity_and_oidc_issuer = release_to_sigstore_identity_and_oidc_issuer[base_version(release)]
except KeyError:
error(["No release manager defined for Python release " + release])
sigstore_identity, sigstore_oidc_issuer = sigstore_identity_and_oidc_issuer

print('Verifying release files were signed correctly with Sigstore')
sigstore_verify_argv = [
'python3', '-m', 'sigstore', 'verify', 'identity',
'--cert-identity', sigstore_identity,
'--cert-oidc-issuer', sigstore_oidc_issuer,
]
for filename in filenames:
filename_crt = filename + '.crt'
filename_sig = filename + '.sig'
filename_sigstore = filename + '.sigstore'

if os.path.exists(filename_sigstore):
run_cmd(
sigstore_verify_argv
+ ['--bundle', filename_sigstore, filename]
)

# We use an 'or' here to error out if one of the files is missing.
if os.path.exists(filename_sig) or os.path.exists(filename_crt):
run_cmd(
sigstore_verify_argv
+ ['--certificate', filename_crt, '--signature', filename_sig, filename]
)

def main():
rel = sys.argv[1]
print('Querying python.org for release', rel)
Expand Down