Skip to content

Commit bc7f324

Browse files
authored
Merge pull request #1172 from Xata/master
Add SBOM generation guide
2 parents 09267a9 + 818db50 commit bc7f324

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

docs/guides/sbom.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Crow has the ability to generate a SBOM (Software Bill of Materials) at build using [`cmake-sbom`](https://github.com/DEMCON/cmake-sbom) in SPDX format.
2+
3+
## Prerequisites
4+
5+
The CMake module `cmake-sbom` expects the `spdx-tools`, `reuse`, and `ntia-conformance-checker` Python packages as external prerequisites.
6+
7+
## Example Steps
8+
9+
Below you'll find the steps to add SBOM generation.
10+
11+
### Install Python Packages
12+
13+
Create a Python virtual environment first so you're not installing Python packages globally:
14+
15+
1. Create and navigate to the build directory:<br> `mkdir build && cd build`
16+
2. Create the venv:<br> `python3 -m venv .venv`
17+
3. Activate the venv (macOS/Linux):<br> `source .venv/bin/activate`
18+
4. Install the required Python packages:<br> `pip install spdx-tools reuse ntia-conformance-checker`
19+
20+
### Build Crow with cmake-sbom
21+
22+
Steps to generate a `.spdx` file using CMake for your project:
23+
24+
1. If you didn't create the `build` directory, create and navigate to the build directory:<br> `mkdir build && cd build`
25+
2. Enable the build option:<br> `cmake .. -DCROW_GENERATE_SBOM=ON -DPython3_EXECUTABLE=$(which python3)`
26+
3. Then run:<br> `cmake --build .`
27+
4. Run the install:<br> `cmake --install . --prefix /tmp/crow-install`
28+
29+
Check for the generated .spdx file in the `build/` directory. The file name follows this pattern:<br> `crow-<version>-<date>.spdx`
30+
31+
!!! note
32+
You must pass `-DPython3_EXECUTABLE=$(which python3)` so CMake uses the venv's Python instead of the system Python. Without it,
33+
the SBOM verification step will fail because the system Python won't have the required packages installed.
34+
35+
!!! note
36+
The .spdx file is generated when you run the `cmake --install . --prefix /tmp/crow-install`
37+
38+
!!! note
39+
You can also combine `-DCROW_GENERATE_SBOM=ON` with conditional dependencies:<br> `cmake .. -DCROW_GENERATE_SBOM=ON -DCROW_ENABLE_SSL=ON -DCROW_ENABLE_COMPRESSION=ON`

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ nav:
6767
- Multipart: guides/multipart.md
6868
- Query Strings: guides/query-string.md
6969
- Middleware: guides/middleware.md
70+
- SBOM Generation: guides/sbom.md
7071
- SSL: guides/ssl.md
7172
- Static Files: guides/static.md
7273
- Blueprints: guides/blueprints.md

0 commit comments

Comments
 (0)