Skip to content

Commit 095f27d

Browse files
authored
Merge pull request #49 from jasinner/cdx-rpm-jshepher
Cdx rpm jshepher
2 parents a1101ce + 5ff33ec commit 095f27d

26 files changed

+193096
-11962
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ jobs:
1818
- name: Run all envs
1919
uses: fedora-python/tox-github-action@main
2020
with:
21-
tox_env: ${{ matrix.tox_env }}
21+
# tox_env: ${{ matrix.tox_env }}
22+
tox_env: py313
2223
strategy:
2324
matrix:
2425
tox_env: [black, ruff, spdx-schema, cdx-schema]

docs/sbom.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,16 @@ purl identifiers
477477
they should only ever differ in their qualifier values, not the main components such as package type, name, or
478478
version; multiple package objects should be used if those values differ.
479479

480+
[`checksums`](https://spdx.github.io/spdx-spec/v2.3/package-information/#710-package-checksum-field)
481+
: Minimally, the list of checksums must include the SHA256 checksum of the RPM file or source archive itself.
482+
All other checksums should be specified as annotations (see below).
483+
480484
[`annotations`](https://spdx.github.io/spdx-spec/v2.3/annotations/)
481485
: A list of annotations may provide additional information that is specific to the RPM format. In the example
482-
above, the MD5 checksum the signed header of the RPM package is included.
486+
above, two checksum values are included:
487+
- The MD5 checksum of the signed header of the RPM package is included.
488+
- The SHA256 checksum of the RPM header (this value does not change when an RPM is signed; unlike the file SHA256 \
489+
checksum used in `checksums`).
483490

484491
Each set of architecture-specific RPMs also have an associated source RPM (SRPM) that bundles all the source code
485492
that was used to build those RPMs. SRPMs should be represented as a separate package object in an SBOM, and their

requirements/dev-requirements.txt

Lines changed: 372 additions & 435 deletions
Large diffs are not rendered by default.

sbom/cyclonedx-1.5.schema.json

Lines changed: 0 additions & 3799 deletions
This file was deleted.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"bomFormat": "CycloneDX",
3+
"serialNumber": "urn:uuid:930fffb2-c807-4b92-9029-228a5cf711aa",
4+
"specVersion": "1.6",
5+
"version": 1,
6+
"metadata": {
7+
"component": {
8+
"name": "quarkus/mandrel-for-jdk-21-rhel8",
9+
"publisher": "Red Hat",
10+
"purl": "pkg:oci/mandrel-for-jdk-21-rhel8@sha256%3A65c139d16564a14b6832d1a393d18146e2fd921b8d263bf214df5720c1c79b19?arch=amd64&os=linux&tag=23.1-16",
11+
"supplier": {
12+
"name": "Red Hat",
13+
"url": [
14+
"https://www.redhat.com"
15+
]
16+
},
17+
"type": "container"
18+
},
19+
"timestamp": "2024-10-17T17:34:08Z"
20+
},
21+
"components": [
22+
{
23+
"bom-ref": "d9851388f78c0ae4",
24+
"name": "quarkus/mandrel-for-jdk-21-rhel8",
25+
"purl": "pkg:oci/mandrel-for-jdk-21-rhel8@sha256%3A65c139d16564a14b6832d1a393d18146e2fd921b8d263bf214df5720c1c79b19?arch=amd64&tag=23.1-16",
26+
"type": "container",
27+
"version": "sha256:65c139d16564a14b6832d1a393d18146e2fd921b8d263bf214df5720c1c79b19"
28+
},
29+
{
30+
"bom-ref": "pkg:rpm/redhat/[email protected]?arch=noarch",
31+
"licenses": [
32+
{
33+
"license": {
34+
"name": "OFL"
35+
}
36+
}
37+
],
38+
"name": "abattis-cantarell-fonts",
39+
"properties": [
40+
{
41+
"name": "sbomer:package:type",
42+
"value": "rpm"
43+
},
44+
{
45+
"name": "sbomer:location:0:path",
46+
"value": "/var/lib/rpm/Packages"
47+
}
48+
],
49+
"publisher": "Red Hat, Inc.",
50+
"purl": "pkg:rpm/redhat/[email protected]?arch=noarch",
51+
"type": "library",
52+
"version": "0.0.25-6.el8"
53+
},
54+
{
55+
"bom-ref": "pkg:maven/collections/[email protected]",
56+
"hashes": [
57+
{
58+
"alg": "MD5",
59+
"content": "c4337f3611f7bcb5c4253d1cbcec9796"
60+
},
61+
{
62+
"alg": "SHA-1",
63+
"content": "7af5cbeab522cea32d12779b9e4920f2acc943d5"
64+
},
65+
{
66+
"alg": "SHA-256",
67+
"content": "feae3a06020d1d33be26f469ca9d96c6f253bb807a581ea145b77b11561aec4c"
68+
}
69+
],
70+
"name": "collections",
71+
"properties": [
72+
{
73+
"name": "sbomer:package:language",
74+
"value": "java"
75+
},
76+
{
77+
"name": "sbomer:package:type",
78+
"value": "java-archive"
79+
},
80+
{
81+
"name": "sbomer:location:0:path",
82+
"value": "/usr/share/java/quarkus-mandrel-java/collections.jar"
83+
},
84+
{
85+
"name": "sbomer:metadata:virtualPath",
86+
"value": "/usr/share/java/quarkus-mandrel-java/collections.jar"
87+
}
88+
],
89+
"publisher": "Red Hat",
90+
"purl": "pkg:maven/org.graalvm.sdk/[email protected]?type=jar",
91+
"type": "library",
92+
"version": "23.1.5.0-1-redhat-00001"
93+
}
94+
],
95+
"dependencies": [
96+
{
97+
"dependsOn": [
98+
"pkg:rpm/redhat/[email protected]?arch=noarch&upstream=abattis-cantarell-fonts-0.0.25-6.el8.src.rpm&distro=rhel-8.10&package-id=a91121201ed3be00",
99+
"pkg:maven/collections/[email protected]?package-id=a7c3ff6d3594e20f",
100+
101+
],
102+
"ref": "d9851388f78c0ae4"
103+
},
104+
{
105+
"dependsOn": [],
106+
"ref": "pkg:rpm/redhat/[email protected]?arch=noarch&upstream=abattis-cantarell-fonts-0.0.25-6.el8.src.rpm&distro=rhel-8.10&package-id=a91121201ed3be00"
107+
},
108+
{
109+
"dependsOn": [],
110+
"ref": "pkg:maven/collections/[email protected]?package-id=a7c3ff6d3594e20f"
111+
}
112+
]
113+
}

sbom/examples/product/create_product_sbom.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
version="3.0.7-18.el9_2",
7676
filename="openssl-3.0.7-18.el9_2.src.rpm",
7777
license_concluded="Apache-2.0",
78-
checksums=["sha-256:31b5079268339cff7ba65a0aee77930560c5adef4b1b3f8f5927a43ee468dag0"],
78+
checksums=["sha-256:9215c64e7289a058248728089e4d98ed1cc392bb5eb9b8fcbe661d57e8145bbd"],
7979
purl_summary="pkg:rpm/redhat/[email protected]_2?arch=src",
8080
purls=[
8181
"pkg:rpm/redhat/[email protected]_2?arch=src&repository_id=rhel-9-for-aarch64-baseos-eus-source-rpms",
@@ -223,6 +223,7 @@ def create_cdx(product):
223223
# (for all other, non-OS products).
224224

225225
product_component = {
226+
"bom-ref": min(product.cpes, key=len),
226227
"type": "operating-system",
227228
"name": product.name,
228229
"version": product.version,
@@ -236,12 +237,14 @@ def create_cdx(product):
236237
"serialNumber": "urn:uuid:337d9115-4e7c-4e76-b389-51f7aed6eba8",
237238
"metadata": {
238239
"component": product_component,
240+
"supplier": {"name": "Red Hat", "url": ["https://www.redhat.com"]},
239241
"timestamp": product.released,
240242
"tools": [{"name": "example tool", "version": "1.2.3"}],
241243
},
242244
"components": [product_component.copy()],
243245
}
244246

247+
components = []
245248
for pkg in product.packages:
246249
component = {
247250
"type": "library",
@@ -262,7 +265,17 @@ def create_cdx(product):
262265
"identity": [{"field": "purl", "concludedValue": purl} for purl in pkg.purls]
263266
},
264267
}
265-
sbom["components"].append(component)
268+
components.append(component)
269+
270+
components = sorted(components, key=lambda x: x["purl"])
271+
sbom["components"].extend(components)
272+
sbom["dependencies"] = [
273+
{
274+
"ref": product_component["bom-ref"],
275+
"provides": [c["purl"] for c in components],
276+
"dependsOn": [],
277+
}
278+
]
266279

267280
return fname, sbom
268281

sbom/examples/product/rhel-9.2-eus.cdx.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"serialNumber": "urn:uuid:337d9115-4e7c-4e76-b389-51f7aed6eba8",
66
"metadata": {
77
"component": {
8+
"bom-ref": "cpe:/a:redhat:rhel_eus:9.2::baseos",
89
"type": "operating-system",
910
"name": "Red Hat Enterprise Linux",
1011
"version": "9.2 EUS",
@@ -27,6 +28,12 @@
2728
]
2829
}
2930
},
31+
"supplier": {
32+
"name": "Red Hat",
33+
"url": [
34+
"https://www.redhat.com"
35+
]
36+
},
3037
"timestamp": "2006-08-14T02:34:56Z",
3138
"tools": [
3239
{
@@ -37,6 +44,7 @@
3744
},
3845
"components": [
3946
{
47+
"bom-ref": "cpe:/a:redhat:rhel_eus:9.2::baseos",
4048
"type": "operating-system",
4149
"name": "Red Hat Enterprise Linux",
4250
"version": "9.2 EUS",
@@ -81,7 +89,7 @@
8189
"hashes": [
8290
{
8391
"alg": "SHA-256",
84-
"content": "31b5079268339cff7ba65a0aee77930560c5adef4b1b3f8f5927a43ee468dag0"
92+
"content": "9215c64e7289a058248728089e4d98ed1cc392bb5eb9b8fcbe661d57e8145bbd"
8593
}
8694
],
8795
"evidence": {
@@ -149,5 +157,14 @@
149157
]
150158
}
151159
}
160+
],
161+
"dependencies": [
162+
{
163+
"ref": "cpe:/a:redhat:rhel_eus:9.2::baseos",
164+
"provides": [
165+
"pkg:rpm/redhat/[email protected]_2?arch=src"
166+
],
167+
"dependsOn": []
168+
}
152169
]
153170
}

sbom/examples/product/rhel-9.2-eus.spdx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"checksums": [
120120
{
121121
"algorithm": "SHA256",
122-
"checksumValue": "31b5079268339cff7ba65a0aee77930560c5adef4b1b3f8f5927a43ee468dag0"
122+
"checksumValue": "9215c64e7289a058248728089e4d98ed1cc392bb5eb9b8fcbe661d57e8145bbd"
123123
}
124124
]
125125
}

0 commit comments

Comments
 (0)