sbom-tool
The SBOM tool is a highly scalable and enterprise ready tool to create SPDX 2.2 compatible SBOMs for any variety of artifacts.
Top Related Projects
Quick Overview
The Microsoft SBOM Tool is an open-source command-line utility and library for generating Software Bill of Materials (SBOM) for software projects. It supports various SBOM formats and can be integrated into build pipelines to automate SBOM generation, helping organizations improve their software supply chain security and compliance.
Pros
- Supports multiple SBOM formats, including SPDX and CycloneDX
- Can be easily integrated into CI/CD pipelines for automated SBOM generation
- Provides both a command-line interface and a .NET library for flexibility in usage
- Actively maintained by Microsoft with regular updates and improvements
Cons
- Limited support for non-Windows platforms (though improving)
- May require additional configuration for complex project structures
- Documentation could be more comprehensive, especially for advanced use cases
- Learning curve for users unfamiliar with SBOM concepts and formats
Code Examples
- Generate an SBOM using the command-line interface:
sbom-tool generate -b <path-to-build-directory> -bc <path-to-build-components-directory> -pn <product-name> -pv <product-version> -nsb <namespace-uri> -V Verbose
- Generate an SBOM using the .NET library:
using Microsoft.Sbom.Api;
using Microsoft.Sbom.Api.Manifest;
var manifestInfo = new ManifestInfo
{
Name = "MyProduct",
Version = "1.0.0",
BuildPath = @"C:\path\to\build",
OutputPath = @"C:\path\to\output"
};
var generator = new SBOMGenerator();
var result = await generator.GenerateSBOMAsync(manifestInfo);
- Validate an existing SBOM:
sbom-tool validate -b <path-to-build-directory> -m <path-to-manifest-file>
Getting Started
To get started with the Microsoft SBOM Tool:
-
Install the tool using .NET CLI:
dotnet tool install --global Microsoft.Sbom.Tool
-
Generate an SBOM for your project:
sbom-tool generate -b <path-to-build-directory> -bc <path-to-build-components-directory> -pn <product-name> -pv <product-version> -nsb <namespace-uri>
-
Review the generated SBOM file in the output directory.
For more detailed instructions and options, refer to the official documentation.
Competitor Comparisons
CLI tool and library for generating a Software Bill of Materials from container images and filesystems
Pros of Syft
- Supports a wider range of package ecosystems and file formats
- Offers more detailed software composition analysis
- Provides a user-friendly CLI interface with extensive options
Cons of Syft
- May have a steeper learning curve for beginners
- Lacks some of the integration features found in SBOM Tool
Code Comparison
Syft:
syft packages alpine:latest -o cyclonedx-json
SBOM Tool:
sbom-tool generate -b . -bc . -pn MyProject -pv 1.0.0 -ps MyCompany -nsb https://mycompany.com
Both tools generate SBOMs, but Syft focuses on container image analysis, while SBOM Tool is more oriented towards general project scanning. Syft's command is simpler for quick container scans, whereas SBOM Tool requires more parameters for project-specific information.
Syft excels in comprehensive package detection across various ecosystems, making it ideal for complex, multi-language projects. SBOM Tool, being a Microsoft product, may offer better integration with Azure DevOps and other Microsoft services.
Choose Syft for detailed software composition analysis, especially for container-based projects. Opt for SBOM Tool if you're working within a Microsoft-centric environment or need specific integrations with their toolchain.
Find vulnerabilities, misconfigurations, secrets, SBOM in containers, Kubernetes, code repositories, clouds and more
Pros of Trivy
- Broader scope: Scans for vulnerabilities, misconfigurations, and secrets in addition to generating SBOMs
- Multi-platform support: Works with various operating systems and container formats
- Active community: More frequent updates and contributions from the open-source community
Cons of Trivy
- Potentially slower for large-scale scans due to its comprehensive nature
- May require more configuration for specific use cases compared to SBOM-tool's focused approach
Code Comparison
SBOM-tool (PowerShell):
.\sbom-tool generate -b <drop-path> -bc <build-components-path> -pn <package-name> -pv <package-version> -nsb <namespace-uri> -V Verbose
Trivy (CLI):
trivy image --format cyclonedx --output sbom.json <image-name>
Both tools can generate SBOMs, but Trivy offers additional scanning capabilities beyond SBOM generation. SBOM-tool is more focused on Microsoft ecosystems, while Trivy provides broader platform support and vulnerability scanning features. The choice between them depends on specific project requirements and the desired scope of analysis.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
SBOM Tool
Introduction
The SBOM tool is a highly scalable and enterprise ready tool to create SPDX 2.2 compatible SBOMs for any variety of artifacts. The tool uses the Component Detection libraries to detect components and the ClearlyDefined API to populate license information for these components.
Table of Contents
- Download and Installation
- Run the tool
- Integrating SBOM tool to your CI/CD pipelines
- Telemetry
- Contributing
- Security
- Trademarks
Download and Installation
Executables for Windows, Linux, macOS
We distribute executables and SBOM files of the tool in GitHub Releases page. You can go and download binaries manually or use commands below to get the latest version of the tool for your platform.
Please check the CLI Reference document for additional help regarding the CLI tool.
Package managers
WinGet
winget install Microsoft.SbomTool
Homebrew
brew install sbom-tool
Manual download
Windows (PowerShell)
Invoke-WebRequest -Uri "https://github.com/microsoft/sbom-tool/releases/latest/download/sbom-tool-win-x64.exe" -OutFile "sbom-tool.exe"
Linux (curl)
curl -Lo sbom-tool https://github.com/microsoft/sbom-tool/releases/latest/download/sbom-tool-linux-x64
chmod +x sbom-tool
macOS (curl)
curl -Lo sbom-tool https://github.com/microsoft/sbom-tool/releases/latest/download/sbom-tool-osx-x64
chmod +x sbom-tool
Building SBOM tool as docker image
Clone this repo and build the docker image.
git clone https://github.com/microsoft/sbom-tool
cd sbom-tool
docker build . -t ms_sbom_tool
You can then use the tool normally, by mounting the directories to be scanned using docker bind mounts.
SBOM .NET Tool
The sbom-tool can also be installed as a .NET tool using the following command:
dotnet tool install --global Microsoft.Sbom.DotNetTool
SBOM API NuGet package
Please add and authenticate the Microsoft GitHub NuGet package registry to your nuget.config. Then install the Microsoft.Sbom.Api
package to your project using these instructions
Please check the API Reference document for addditional help regarding the SBOM tool C# Api.
Run the tool
SBOM Generation
Once you have installed the command line tool for your OS, run the tool using this command:
sbom-tool generate -b <drop path> -bc <build components path> -pn <package name> -pv <package version> -ps <package supplier> -nsb <namespace uri base>
The drop path is the folder where all the files to be shipped are located. All these files will be hashed and added to the files section of the SBOM. The build components path is usually your source folder, tool will scan this folder to search for project files like *.csproj or package.json to see what components were used to build the package. Tool uses component-detection to scan for components and dependencies, visit its Github page to get more information about supported components. The package name and version represent the package the SBOM is describing.
Each SBOM has a unique namespace that uniquely identifies the SBOM, we generate a unique identifier for the namespace field inside the SBOM, however we need a base URI that would be common for your entire organization. For example, a sample value for the -nsb
parameter could be https://companyName.com/teamName
, then the generator will create the namespace that would look like https://companyName.com/teamName/<packageName>/<packageVersion>/<new-guid>
. Read more about the document namespace field here.
A more detailed list of available CLI arguments for the tool can be found here
SBOM Validation
With an SBOM file in hand, use the tool to validate the output file with the command:
sbom-tool validate -b <drop path> -o <output path> -mi SPDX:2.2
This sample command provides the minimum mandatory arguments required to validate an SBOM:
-b
should be the path same path used to generate the SBOM file.
In this scenario, the tool will default to searching for an SBOM at the <drop path>\_manifest\spdx_2.2\manifest.spdx.json
path.
-o
is the output path, including file name, where the tool should write the results to.
-mi
is the ManifestInfo, which provides the user's desired name and version of the manifest format.
Currently only SPDX2.2 is supported.
SBOM Redact
Use the tool to redact any references to files from a given SBOM or set of SBOMs with either of the following commands:
sbom-tool redact -sd <directory containing SBOMs to redact> -o <output path>
sbom-tool redact -sp <path to the SBOM to redact> -o <output path>
This command will generate a mirrored set of SBOMs in the output directory, but with the file references removed. Note that the SBOM directory and output path arguments can not reference the same directory and the output path should point to an existing, empty directory.
Integrating SBOM tool to your CI/CD pipelines.
You can follow these guides to integrate the SBOM tool into your CI/CD pipelines
- Setting up GitHub Actions to use the SBOM tool.
- Setting up Azure DevOps Pipelines to use the SBOM tool.
Telemetry
By default, telemetry will output to your output file path and will be a JSON blob. No data is submitted to Microsoft.
Contributing
Please follow the steps here to clone and build this repository from source.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include Microsoft, Azure, DotNet, AspNet, Xamarin, and our GitHub organizations.
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets Microsoft's definition of a security vulnerability, please report it to us as described in the Security.md.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot