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

gh-112844: Update CPE references for external dependencies #118521

Merged
merged 2 commits into from
May 20, 2024
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
16 changes: 15 additions & 1 deletion Tools/build/generate_sbom.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,21 @@ def create_externals_sbom() -> None:

# Set the versionInfo and downloadLocation fields for all packages.
for package in sbom_data["packages"]:
package["versionInfo"] = externals_name_to_version[package["name"]]
package_version = externals_name_to_version[package["name"]]

# Update the version information in all the locations.
package["versionInfo"] = package_version
for external_ref in package["externalRefs"]:
if external_ref["referenceType"] != "cpe23Type":
continue
# Version is the fifth field of a CPE.
cpe23ref = external_ref["referenceLocator"]
external_ref["referenceLocator"] = re.sub(
r"\A(cpe(?::[^:]+){4}):[^:]+:",
fr"\1:{package_version}:",
cpe23ref
)

download_location = (
f"https://github.com/python/cpython-source-deps/archive/refs/tags/{externals_name_to_git_tag[package['name']]}.tar.gz"
)
Expand Down
Loading