meta_package_manager.sbom.cyclonedx module¶
CycloneDX 1.7 writer.
Heavy cyclonedx-python-lib imports are guarded behind a try/except
block; cyclonedx_support reports whether the
CycloneDX class can actually be used.
The license-normalization helper is shared with spdx and is
imported from there rather than duplicated: SPDX license expressions are
the lingua franca CycloneDX builds on, so the dependency direction is
intentional and acyclic.
- class meta_package_manager.sbom.cyclonedx.CycloneDX(export_format=ExportFormat.JSON)[source]¶
Bases:
SBOMGenerates a CycloneDX document from a list of packages.
Defaults to JSON export format.
- document: Bom¶
- init_doc()[source]¶
CycloneDX document metadata specifications.
- Return type:
- add_package(manager, package, metadata=PackageMetadata(download_url=None, homepage=None, vcs_url=None, issue_tracker_url=None, distribution_url=None, license_declared=None, license_concluded=None, copyright_text=None, supplier=None, originator=None, description=None, summary=None, cpe=None, dependencies=(), checksums=(), files=(), files_analyzed=False, install_date=None, build_date=None, release_date=None, external_sbom_path=None, extra_purls=(), extras={}))[source]¶
CycloneDX package metadata specifications.
- Return type:
- all_purls()[source]¶
Yield every component purl in insertion order.
Each component’s
bom_refis its purl string, so the same values double as the vulnerabilityaffectstargets infinalize().
- finalize()[source]¶
Resolve queued dependency edges and attach vulnerability records.
Mirrors
meta_package_manager.sbom.spdx.SPDX.finalize(). Dangling references (the dependency target is not in the inventory) are dropped silently.Vulnerability data bound via
meta_package_manager.sbom.base.SBOM.attach_vulnerabilities()is projected into the CycloneDXvulnerabilitiesarray. Each advisory is described once at the document level with anaffectslist pointing at every component (bybom_ref, which equals the purl) it impacts.- Return type:
- stats()[source]¶
Extend the base stats with CycloneDX-specific counters.
CycloneDX has no merge-content equivalent: per-package upstream SBOMs are linked through
externalReferences[type=bom]rather than spliced in. The merged-document count therefore reports the number of components carrying a BOM external reference. The dependency-edge total walks the registered dependency graph and sums thedependsOncollection size across every entry.
- export()[source]¶
Serialize the document to its string representation.
Note
Unlike
meta_package_manager.sbom.spdx.SPDX.export(), the generated document is not validated against its schema here. CycloneDX schema validation relies oncyclonedx-python-lib’s[validation]extra, which pulls injsonschemaand, transitively,rfc3987-syntax,lark, andlxml. To keep that stack out ofmpm’s runtime dependencies, the validation runs in the test suite instead. Seetests/test_cli_sbom.py.- Return type: