This tutorial illustrates how to create an sbom from a container image using the Syft CLI.
A container software e.g.:
-
Docker
-
Podman
- Curl
-
Chocolatey
-
Scoop
- Homebrew
Run the following command:
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/binbrew install syftchoco install syft -yor
scoop install syftTo generate an SBOM, run the command:
syft <image>Where image is:
-
A remote image from a repository.
-
A local image dictionary.
-
A local compressed image dictionary.
An SBOM will be printed to your terminal.
To create an SBOM in a standardized SBOM format, use the -o flag:
syft <image> -o <format>Where <format> is one of:
cyclonedx-jsoncyclonedx-xmlspdx-jsonspdx-tag-valuesyft-jsonsyft-tablesyft-textgithub-json
To output the SBOM to a file, run the above command but add =<output_file> to the -o format:
syft <image> -o <format>=<output_file_name>An SBOM file of your specified name and format will be created.
In Linux, sudo may be required.
This section illustrates CycloneDX and SPDX JSON SBOMs of an Nginx image, produced via Syft.
<title>Pretty JSON Display</title> <style> #json-container { height: 400px; /* Set a fixed height */ overflow-y: auto; /* Enable vertical scrolling */ border: 2px solid #ccc; /* Optional: add a border for visibility */ padding: 10px; } #xml-container { height: 400px; /* Set a fixed height */ overflow-y: auto; /* Enable vertical scrolling */ border: 2px solid #ccc; /* Optional: add a border for visibility */ padding: 10px; } pre { margin: 0; white-space: pre-wrap; word-wrap: break-word; } </style>- Anchore. (n.d.). Anchore/syft: CLI Tool and library for generating a software bill of materials from container images and filesystems. GitHub. https://github.com/anchore/syft