Lib4SBOM is a Python library designed for parsing, generating, and validating Software Bills of Materials (SBOMs). It supports both SPDX and CycloneDX formats, offering a generic abstraction for SBOM data regardless of the underlying specification. Currently at version 0.10.3, the library maintains an active development pace with frequent minor releases and regular feature updates, addressing new specification versions and user-reported issues.
pip install lib4sbomVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to parse an existing SBOM file using the `SBOMParser` class. It creates a simple SPDX 2.3 TagValue file, parses it, and then extracts package information. The `sbom_type` parameter can be set to 'spdx', 'cyclonedx', or 'auto' for automatic detection.
Review the release notes for specific version changes. Explicitly set SBOM versions during generation using environment variables like `LIB4SBOM_CYCLONEDX_VERSION` or `LIB4SBOM_SPDX_VERSION` to match your target specification. For SPDX3, set `LIB4SBOM_SPDX3` environment variable.
Explicitly set the `sbom_type` parameter when initializing `SBOMParser` (e.g., `SBOMParser(sbom_type='spdx')`) if the SBOM format is known to avoid misdetection. Ensure file extensions align with standard SBOM formats (e.g., `.spdx`, `.cdx.json`).
Test conversions thoroughly for critical license information. Monitor GitHub issues #88 and #89 for official fixes. Manual verification and correction of license fields may be necessary post-conversion for affected versions.
Ensure all required dependencies are installed and up-to-date. If validation errors occur, check the specific error messages for clues about schema violations. Consider using debug output (`debug=True` in `SBOMValidator`) to get more verbose validation feedback.
Examine the traceback for more details. Check the input SBOM file for syntax errors or adherence to its declared specification. Try parsing with `sbom_type='auto'` or explicitly specifying the type to help narrow down the issue.
Verify that the file path provided to `parse_file()` is correct and accessible. Use an absolute path or ensure the file is in the current working directory.
Explicitly set `sbom_type='cyclonedx'` in the `SBOMParser` constructor. If the issue persists, consider downgrading the CycloneDX spec version if possible, or review GitHub issues for specific fixes related to CycloneDX 1.5+ parsing.