Skip to content

Commit

Permalink
pythongh-112844: Update CPE references for external dependencies (pyt…
Browse files Browse the repository at this point in the history
  • Loading branch information
sethmlarson authored May 20, 2024
1 parent 19c11f2 commit 1195c16
Showing 1 changed file with 15 additions and 1 deletion.
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

0 comments on commit 1195c16

Please sign in to comment.