-
Notifications
You must be signed in to change notification settings - Fork 652
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
Generate SBOM during build/release process #3805
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from json import dumps | ||
|
||
from requests import get | ||
|
||
with open("opentelemetry-python.spdx.json", "w") as sbom_file: | ||
sbom_file.write( | ||
dumps( | ||
get( | ||
( | ||
"https://api.github.com/repos/open-telemetry/" | ||
"opentelemetry-python/dependency-graph/sbom" | ||
Comment on lines
+10
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This API seems pretty barebones, I'm guessing this just generates an SBOM against the main branch and maybe cached at some random commit? What if you are making a patch release, would the dep graph be correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, apparently this functionality creates an SBOM file using the latest commit in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The reason why the SBOM file includes released versions is because we have diff --git a/docs/examples/metrics/reader/requirements.txt b/docs/examples/metrics/reader/requirements.txt
index 2ccffaf3..23ff5bf6 100644
--- a/docs/examples/metrics/reader/requirements.txt
+++ b/docs/examples/metrics/reader/requirements.txt
@@ -1,5 +1,5 @@
Deprecated==1.2.13
-opentelemetry-api==1.15.0
+opentelemetry-api==1.20.0
opentelemetry-sdk==1.15.0
opentelemetry-semantic-conventions==0.36b0
typing_extensions==4.3.0
diff --git a/docs/examples/metrics/views/requirements.txt b/docs/examples/metrics/views/requirements.txt
index be612711..d9590b3f 100644
--- a/docs/examples/metrics/views/requirements.txt
+++ b/docs/examples/metrics/views/requirements.txt
@@ -1,5 +1,5 @@
Deprecated==1.2.13
-opentelemetry-api==1.12.0
+opentelemetry-api==1.20.0
opentelemetry-sdk==1.12.0
opentelemetry-semantic-conventions==0.33b0
typing_extensions==4.3.0 Those changes produced the following changes in the SBOM file: 5c5
< "created": "2024-04-03T19:17:07Z",
---
> "created": "2024-04-03T17:15:55Z",
16c16
< "documentNamespace": "https://github.com/SecuringCarter/opentelemetry-python/dependency_graph/sbom-7c05aa1b812baa89",
---
> "documentNamespace": "https://github.com/SecuringCarter/opentelemetry-python/dependency_graph/sbom-75a76526c2dd97b4",
814a815,830
> "SPDXID": "SPDXRef-pip-opentelemetry-api-1.15.0",
> "name": "pip:opentelemetry-api",
> "versionInfo": "1.15.0",
> "downloadLocation": "NOASSERTION",
> "filesAnalyzed": false,
> "licenseConcluded": "Apache-2.0",
> "supplier": "NOASSERTION",
> "externalRefs": [
> {
> "referenceCategory": "PACKAGE-MANAGER",
> "referenceLocator": "pkg:pypi/[email protected]",
> "referenceType": "purl"
> }
> ]
> },
> {
878a895,910
> "SPDXID": "SPDXRef-pip-opentelemetry-api-1.12.0",
> "name": "pip:opentelemetry-api",
> "versionInfo": "1.12.0",
> "downloadLocation": "NOASSERTION",
> "filesAnalyzed": false,
> "licenseConcluded": "Apache-2.0",
> "supplier": "NOASSERTION",
> "externalRefs": [
> {
> "referenceCategory": "PACKAGE-MANAGER",
> "referenceLocator": "pkg:pypi/[email protected]",
> "referenceType": "purl"
> }
> ]
> },
> {
2317a2350,2354
> "relatedSpdxElement": "SPDXRef-pip-opentelemetry-api-1.15.0"
> },
> {
> "relationshipType": "DEPENDS_ON",
> "spdxElementId": "SPDXRef-com.github.SecuringCarter-opentelemetry-python",
2333a2371,2375
> },
> {
> "relationshipType": "DEPENDS_ON",
> "spdxElementId": "SPDXRef-com.github.SecuringCarter-opentelemetry-python",
> "relatedSpdxElement": "SPDXRef-pip-opentelemetry-api-1.12.0" So, I now think that we probably should do something about these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After many more changes I managed to reduce the amount of packages in the SBOM file with an empty value of
I think the mechanism to generate an SBOM file that this PR introduces is valid. We probably need to change our repo in order to produce a "better" or more useful SBOM file. Can we merge this and work on making the SBOM file better in subsequent PRs? |
||
), | ||
headers={ | ||
"Accept": "application/vnd.github+json", | ||
"X-GitHub-Api-Version": "2022-11-28", | ||
}, | ||
).json(), | ||
indent=4, | ||
) | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: SBOM | ||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
generate-sbom: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout core repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.10' | ||
architecture: 'x64' | ||
|
||
- name: Install requests | ||
run: pip install requests | ||
|
||
- name: Generate SBOM | ||
run: python3 .github/workflows/generate_sbom.py | ||
|
||
- name: Zip the SBOM file | ||
run: zip sbom.zip opentelemetry-python.spdx.json | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: SBOM.zip | ||
path: ./sbom.zip | ||
|
||
add-release-artifact: | ||
needs: generate-sbom | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Download artifact from generate-sboms | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: SBOM.zip | ||
|
||
- name: Upload release asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./sbom.zip | ||
asset_name: SBOM.zip | ||
asset_content_type: application/zip | ||
ocelotl marked this conversation as resolved.
Show resolved
Hide resolved
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a look at the actual API response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I looked into the SBOM file, found several packages with an empty value for
versionInfo
, here they are: