-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
SBOM #403
Comments
Second this. I'm currently working on manually writing a CycloneDX SBOM for a specific build of PBS we use downstream, following which I'll be working on some automated tooling. I'll share both as and when I can to hopefully get the ball rolling on upstreaming this 👍 |
thank you! |
I've attached an SBOM I've made for one of the past builds of PBS. It's the first SBOM I've written and I don't have particular expertise in this area, but I believe it is a good starting point. Notable exclusionsThe SBOM is mostly "complete", with a few exceptions I've outlined below. Of course one could always include more information and fill every possible field, but that way lies madness.
Guide to the formatSince a large blob of JSON can be intimidating at first, I'll quickly go over the general structure. At the top level there is some generic boilerplate to do with the SBOM itself: {
"$schema": "https://cyclonedx.org/schema/bom-1.6.schema.json",
"bomFormat": "CycloneDX",
"specVersion": "1.6",
"serialNumber": "urn:uuid:f6a24d2b-f989-426f-a9af-19324d8b6949",
"version": 1,
"metadata": {
"timestamp": "2024-12-16T16:00:00+00:00",
"component": {...}
},
"components": [...]
} There is a "metadata component" and another list of "components". These all follow the same format. The "metadata component" is the one the SBOM is about, i.e. a particular build of PBS: {
"type": "application",
"mime-type": "application/zstd",
"bom-ref": "pkg:generic/python-build-standalone@20231002?download_url=https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-x86_64_v2-unknown-linux-gnu-pgo-full.tar.zst&checksum=sha256:f1121cc0fccb1c5e867923f39e3e7d6413720554ec079eac022f5fc69e7ee83a",
"authors": [
{
"name": "Gregory Szorc",
"email": "[email protected]"
}
],
"name": "python-build-standalone",
"version": "20231002",
"description": "This project produces self-contained, highly-portable Python distributions. These Python distributions contain a fully-usable, full-featured Python installation: most extension modules from the Python standard library are present and their library dependencies are either distributed with the distribution or are statically linked.",
"hashes": [
{
"alg": "SHA-256",
"content": "f1121cc0fccb1c5e867923f39e3e7d6413720554ec079eac022f5fc69e7ee83a"
}
],
"purl": "pkg:generic/python-build-standalone@20231002?download_url=https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-x86_64_v2-unknown-linux-gnu-pgo-full.tar.zst&checksum=sha256:f1121cc0fccb1c5e867923f39e3e7d6413720554ec079eac022f5fc69e7ee83a",
"externalReferences": [
{
"url": "https://github.com/indygreg/python-build-standalone",
"type": "vcs"
},
{
"url": "https://github.com/indygreg/python-build-standalone/releases/tag/20231002",
"type": "release-notes"
},
{
"url": "https://github.com/indygreg/python-build-standalone/releases/download/20231002/cpython-3.10.13+20231002-x86_64_v2-unknown-linux-gnu-pgo-full.tar.zst",
"type": "distribution",
"hashes": [
{
"alg": "SHA-256",
"content": "f1121cc0fccb1c5e867923f39e3e7d6413720554ec079eac022f5fc69e7ee83a"
}
]
}
]
} This SBOM is for a specific release tarball and the The array of components is then a list of the dependencies. I wrote the CPython one by hand, and have included a short bit of Python code that I used to generate the rest from the {
"type": "application",
"mime-type": "application/x-xz",
"bom-ref": "pkg:generic/[email protected]?download_url=https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tar.xz&checksum=sha256:5c88848668640d3e152b35b4536ef1c23b2ca4bd2c957ef1ecbb053f571dd3f6",
"manufacturer": {
"name": "Python Software Foundation",
"address": {
"country": "US",
"region": "Oregon",
"locality": "Beaverton",
"postalCode": "OR 97008",
"streetAddress": "9450 SW Gemini Dr. ECM# 90772"
},
"url": [
"https://www.python.org"
]
},
"name": "CPython",
"version": "3.10.13",
"hashes": [
{
"alg": "SHA-256",
"content": "5c88848668640d3e152b35b4536ef1c23b2ca4bd2c957ef1ecbb053f571dd3f6"
}
],
"purl": "pkg:generic/[email protected]?download_url=https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tar.xz&checksum=sha256:5c88848668640d3e152b35b4536ef1c23b2ca4bd2c957ef1ecbb053f571dd3f6",
"externalReferences": [
{
"url": "https://www.python.org/ftp/python/3.10.13/Python-3.10.13.tar.xz",
"type": "distribution",
"hashes": [
{
"alg": "SHA-256",
"content": "5c88848668640d3e152b35b4536ef1c23b2ca4bd2c957ef1ecbb053f571dd3f6"
}
]
}
]
} As noted above, all the "components" have a similar structure, the only difference is that I've set the Attachments and useful links
|
I've been looking at software that consumes SBOMs (in this case Dependency-Track), and it seems like the generic purls (package URLs) aren't used for matching against vulnerability databases. My testing shows that CPE (Common Platform Enumeration) IDs do work though - using a CPE of |
Charlie et. al, a few implementation questions:
From the looks of it we could maybe do it:
It looks like we need information available to the Python script at build time (the versions of dependencies). For us to make the SBOM specifically about the tarball we'd need to at least update it with the tarball hash after it has been created. I presume this would form an extra build artefact alongside each tarball |
@zanieb I've got some time coming up to work on this, would this be a contribution you would accept or should I implement this outside the project? |
I'm interested! Sorry for the lack of reply — got lost / I don't have great answers.
After the Note we create derived artifacts at release time. This was relevant, e.g., for #343, and presume would be relevant here if you need the archive hash? Are you going to create a SBOM for every release artifact? I worry about doubling the number of release artifacts — I'm not sure when GitHub will start enforcing a limit but we're already at more than 1000. Also vaguely relevant, we were considering #284 to improve consumption of the download metadata outside of Python. |
Thanks! I'll keep in mind the "derived artifacts" 👍 I was planning on making one SBOM per release artifact tarball... which would increase the number of artifacts by another 50%.... Would you be open to getting rid of the |
RE: number of release assets, GitHub do specifically say there is "no limit" to the total size (although don't talk about number of assets directly). Of course I'm sure there is some limit, but we could "call their bluff" so to speak
|
I guess let's go for it and we can deal with it if there are problems. We could collapse the checksums into a single file if we have to, yeah. They seems slightly easier to use as separate files though, |
While the standalone builds already contain licensing info in the PYTHON.json file it would be great if it could also contain a full SBOM in a standard format such as SPDX, similar to the binaries on python.org.
The text was updated successfully, but these errors were encountered: