Add SBOM artifact using cyclonedx-gomod#5220
Conversation
6f154d5 to
118f5bb
Compare
|
Converted to draft, while the scope of sbom is being discussed, and to exclude it from release concerns. The main shortcomings of the current report is that it doesn't include the "supplier" or the "copyright". NTIA (2021)SBOM Quality Score: 8.6/10.0 Grade: B Components: 107 EngineVersion: 8 File: bom.json Summary: NTIA (2025)SBOM Quality Score: 6.9/10.0 Grade: D Components: 107 EngineVersion: 8 File: bom.json Summary: Any value for the supplier is accepted, so it could be "name: Unknown" etc. The licenses needs to be asserted (from "evidence"), and 3 licenses added. The threshold for go-license-detector SPDX is currently hardcoded to 85%. Upgrading to github.com/go-enry/go-license-detector/v4 v4.3.1 will fix: [
{
"project": "vendor/github.com/balajiv113/fd",
"matches": [
{
"license": "MIT",
"confidence": 0.90066224,
"file": "LICENSE.MIT"
}
]
},
{
"project": "vendor/github.com/fatih/color",
"matches": [
{
"license": "MIT",
"confidence": 0.9096774,
"file": "LICENSE.md"
}
]
},
{
"project": "vendor/github.com/jinzhu/copier",
"matches": [
{
"license": "MIT",
"confidence": 0.9096774,
"file": "License"
}
]
}
]The missing hash on the top component (lima), is another such issue: if module.Main {
// We currently don't have an accurate way of hashing the main module, as it may contain
// files that are .gitignore'd and thus not part of the hashes in Go's sumdb.
logger.Debug().Str("module", module.Coordinates()).Msg("not calculating hash for main module")
return nil
}The new fields sbom_author and software_producer should be simple:
|
One for lima as a library, one for each cmd. https://github.com/CycloneDX/cyclonedx-gomod Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Currently there is no way to cross-compile, since it runs a go binary for the current GOOS/GOARCH/GOFLAGS. Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
The CLO monitor <https://clomonitor.io/> checks look for "Software Bill of Materials" or "SBOM" in the README.md file. Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
|
Here's the hack to get a perfect score with #!/usr/bin/env python3
import sys
import json
# organizationalContact
AUTHOR = {"name": "Unknown", "email": "unknown@example.com"}
# organizationalEntity
MANUFACTURER = {"name": "Unknown", "url": ["https://example.com"]}
# organizationalEntity
SUPPLIER = {"name": "Unknown"}
# organizationalEntity
NOASSERTION = {"name": "Unknown"}
def fix(sbom):
metadata = sbom.get("metadata", {})
if metadata.get("authors") is None:
metadata["authors"] = [AUTHOR]
if metadata.get("manufacturer") is None:
metadata["manufacturer"] = MANUFACTURER
if metadata.get("supplier") is None:
metadata["supplier"] = SUPPLIER
component = metadata.get("component", {})
if component.get("supplier") is None:
component["supplier"] = SUPPLIER
for component in sbom.get("components", []):
if component.get("supplier") is None:
component["supplier"] = NOASSERTION
sbom = json.load(sys.stdin)
fix(sbom)
json.dump(sbom, sys.stdout, indent=2)
print(file=sys.stdout)$ make sbom CYCLONEDX_GOMOD=cyclonedx-gomod CYCLONEDX_GOMOD_FLAGS="-licenses -assert-licenses"
$ ./bom-fix.py <bom.json >sbom.json
$ sbomqs score --profile ntia,ntia-2025 --basic sbom.json
10.0 A NTIA Minimum Elements (2021) 1.6 json sbom.json
10.0 A NTIA Minimum Elements (2025) - RFC 1.6 json sbom.jsonBut it is just a hack (even with the proper values), it doesn't add very much? Finding out the actual "supplier" for each go module is a bigger problem... |
One for lima as a library, one for each cmd.
https://github.com/CycloneDX/cyclonedx-gomod
Closes #5219
Minor license problem with one dependency:
WRN no licenses detected module=github.com/balajiv113/fd@v0.0.0-20230330094840-143eec500f3eDBG detection confidence for license is too low confidence=0.8476821 license=MIT minConfidence=0.85 module=github.com/balajiv113/fd@v0.0.0-20230330094840-143eec500f3ei.e. they forgot to say "MIT License" :-)
https://github.com/balajiv113/fd/blob/master/LICENSE.MIT
https://spdx.org/licenses/MIT.html
TODO:
Use GitHub Actions for installingcyclonedx-gomod, instead ofgo install? cyclonedx-gomod-generate-sbomUsing go hack/tools instead.
Published to GitHub Releases.
The scope of this PR is to declare what software source code that went into the compiled binaries:
It does not do any files (e.g. checksums) or architectures, and does not cover any external drivers.
EDIT: The "app" SBOM actually was per-arch, while the "mod" SBOM is the same for all architectures.
The tool doesn't support cross-compiling, since it needs to be able to run a binary for the OS/ARCH.