Skip to content

Commit 78577ff

Browse files
authored
Merge branch 'master' into dependabot/pip/pip-5cdcf6c19f
2 parents 912445d + 51b5905 commit 78577ff

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

.github/workflows/source-and-docs-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ name: "Build Python source and docs artifacts"
4040
# Set from inputs for workflow_dispatch, or set defaults to test push/PR events
4141
env:
4242
GIT_REMOTE: ${{ github.event.inputs.git_remote || 'python' }}
43-
GIT_COMMIT: ${{ github.event.inputs.git_commit || 'f6650f9ad73359051f3e558c2431a109bc016664' }}
44-
CPYTHON_RELEASE: ${{ github.event.inputs.cpython_release || '3.12.3' }}
43+
GIT_COMMIT: ${{ github.event.inputs.git_commit || '4f8bb3947cfbc20f970ff9d9531e1132a9e95396' }}
44+
CPYTHON_RELEASE: ${{ github.event.inputs.cpython_release || '3.13.2' }}
4545

4646
jobs:
4747
verify-input:
@@ -105,7 +105,7 @@ jobs:
105105
python ../release.py --export "$CPYTHON_RELEASE" --skip-docs
106106
107107
- name: "Upload the source artifacts"
108-
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
108+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
109109
with:
110110
name: source
111111
path: |
@@ -148,7 +148,7 @@ jobs:
148148
SPHINXOPTS="-j10" make dist
149149
150150
- name: "Upload the docs artifacts"
151-
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
151+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
152152
with:
153153
name: docs
154154
path: |

sbom.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,38 @@ def recursive_sort_in_place(value: list[Any] | dict[str, Any]) -> None:
223223
recursive_sort_in_place(cast(dict[str, Any], sbom_data))
224224

225225

226+
def check_sbom_data(sbom_data: SBOM) -> None:
227+
"""Check SBOM data for common issues"""
228+
229+
def check_id_duplicates(sbom_components: list[Package] | list[File]) -> set[str]:
230+
all_ids = set()
231+
for sbom_component in sbom_components:
232+
sbom_component_id = sbom_component["SPDXID"]
233+
assert sbom_component_id not in all_ids
234+
all_ids.add(sbom_component_id)
235+
return all_ids
236+
237+
all_package_ids = check_id_duplicates(sbom_data["packages"])
238+
all_file_ids = check_id_duplicates(sbom_data["files"])
239+
240+
# Check that no files and packages have the same ID.
241+
assert not all_package_ids.intersection(all_file_ids)
242+
all_sbom_ids = all_package_ids | all_file_ids
243+
244+
# Check that all relationships use existing IDs.
245+
for sbom_relationship in sbom_data["relationships"]:
246+
247+
# The exception being 'DESCRIBES' with the meta 'document' ID
248+
if (
249+
sbom_relationship["spdxElementId"] == "SPDXRef-DOCUMENT"
250+
and sbom_relationship["relationshipType"] == "DESCRIBES"
251+
):
252+
continue
253+
254+
assert sbom_relationship["spdxElementId"] in all_sbom_ids
255+
assert sbom_relationship["relatedSpdxElement"] in all_sbom_ids
256+
257+
226258
def fetch_package_metadata_from_pypi(
227259
project: str, version: str, filename: str | None = None
228260
) -> tuple[str, str]:
@@ -686,6 +718,11 @@ def create_sbom_for_windows_artifact(
686718
with (cpython_source_dir / "Misc/sbom.spdx.json").open() as f:
687719
source_sbom_data = json.loads(f.read())
688720
for sbom_package in source_sbom_data["packages"]:
721+
# Update the SPDX ID to avoid collisions with
722+
# the 'externals' SBOM.
723+
sbom_package["SPDXID"] = spdx_id(
724+
f"SPDXRef-PACKAGE-{sbom_package['name']}-{sbom_package['versionInfo']}"
725+
)
689726
sbom_data["packages"].append(sbom_package)
690727

691728
create_cpython_sbom(
@@ -755,6 +792,10 @@ def main() -> None:
755792

756793
# Normalize SBOM data for reproducibility.
757794
normalize_sbom_data(sbom_data)
795+
796+
# Check SBOM for validity.
797+
check_sbom_data(sbom_data)
798+
758799
with open(artifact_path + ".spdx.json", mode="w") as f:
759800
f.truncate()
760801
f.write(json.dumps(sbom_data, indent=2, sort_keys=True))

0 commit comments

Comments
 (0)