meta_package_manager.sbom.base module¶
Format-agnostic SBOM base class and export-format enum.
Kept deliberately free of SPDX or CycloneDX dependencies: instantiating
SBOM directly is meaningless, but importing the symbols here
is safe even when the optional [sbom-offline] extra is not installed.
- class meta_package_manager.sbom.base.ExportFormat(*values)[source]¶
Bases:
StrEnumA user-friendly version of
spdx_tools.spdx.formats.FileFormat.Map format to user-friendly IDs.
- JSON = 'json'¶
- XML = 'xml'¶
- YAML = 'yaml'¶
- TAG_VALUE = 'tag'¶
- RDF_XML = 'rdf'¶
- class meta_package_manager.sbom.base.SBOM(export_format=ExportFormat.JSON)[source]¶
Bases:
objectUtilities shared by all SBOM classes.
See also
Anchore’s Syft and Microsoft’s sbom-tool are mature SPDX and CycloneDX emitters, useful references for field-population conventions. Both inventory packages by parsing on-disk databases and lockfiles, whereas
mpmqueries the live managers directly.Defaults to JSON export format.
- vulnerabilities_by_purl: dict[str, tuple[Vulnerability, ...]]¶
- all_purls()[source]¶
Yield every package purl present in the document.
Powers the vulnerability scan: the network layer queries OSV once with the full purl set rather than once per package. Subclasses implement this against their own component index.
- attach_vulnerabilities(vulnerabilities)[source]¶
Bind cross-package vulnerability data to the document.
Called by the CLI between the per-package
add_packageloop andfinalize, only in--networkmode. Renderers read the stored data in theirfinalizeoverride and project it into the format-native vulnerability surface (CycloneDXvulnerabilitiesarray, SPDX securityexternalRefs).- Return type:
- stats()[source]¶
Return a summary of what landed in the document.
Format-agnostic counters live in the base implementation; SPDX and CycloneDX subclasses extend the returned dict with their own merged-documents, dependency-graph, and any other format-specific counts. Surfaced by the CLI as a post-run INFO-level summary and usable by tests or programmatic consumers without re-parsing the rendered document.
- finalize()[source]¶
Resolve any deferred state before
export().Some constructs cannot be emitted at
add_package()time because they reference packages that may not have been added yet: a Homebrew formula’s runtime dependency on another formula listed later in the scan, for example. Subclasses queue those duringadd_packageand flush them here. The base implementation is a no-op so subclasses can rely on it being called exactly once.- Return type: