Skip to content

Commit c2b788c

Browse files
committed
docs: update capabilities
1 parent 20c223a commit c2b788c

File tree

1 file changed

+77
-27
lines changed

1 file changed

+77
-27
lines changed

README.md

Lines changed: 77 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77

88
`rules_sbom` provides Bazel rules for generating Software Bill of Materials (SBOM) artifacts from Bazel targets using best-in-class external tooling.
99

10-
> ⚠️ This repository is under active development. The public APIs and toolchain integrations are not yet stable.
10+
The rules are production-ready and currently power SBOM generation in real workloads. They ship reproducible CycloneDX documents that track the dependencies that actually ship with your services as well as full workspace inventories.
11+
12+
## Capabilities
13+
14+
- Service-level SBOMs: point `sbom_artifact` at a single Bazel target (for example a binary, image, or library bundle) to enumerate only the artifacts that deploy with that unit.
15+
- Workspace-level SBOMs: aggregate manifests and lockfiles across the repository to emit a global view of every resolved dependency.
16+
- JavaScript and pnpm monorepos: the Syft wrapper synthesizes scoped `package.json` and lockfiles for each target, disables noisy catalogers, and can also ingest workspace-level node modules so you can switch between per-service and whole-repo reports.
17+
- Bundled Syft toolchain: pre-built binaries for macOS, Linux, and Windows ensure consistent output in CI and on developer machines.
1118

1219
## Getting started
1320

@@ -48,6 +55,73 @@
4855

4956
The [`docs/`](docs/overview.md) directory contains more detailed usage and toolchain notes (including [Windows testing via Parallels CLI](docs/windows_parallels.md)).
5057

58+
## Generating SBOMs
59+
60+
### Service-level SBOMs
61+
62+
The simplest configuration points `sbom_artifact` at the Bazel target you ship. The rule stages that target's runfiles, injects any language-specific metadata (for example `package.json`, `go.mod`, or `requirements.txt`), and hands the curated bundle to Syft:
63+
64+
```starlark
65+
load("@rules_sbom//sbom:defs.bzl", "sbom_artifact")
66+
67+
sbom_artifact(
68+
name = "payment_service_sbom",
69+
target = "//services/payment:binary",
70+
)
71+
```
72+
73+
### Workspace-level SBOMs
74+
75+
To capture a global view, wrap the manifests, lockfiles, and other workspace inputs you care about in a `filegroup`, then ask `sbom_artifact` to process that group:
76+
77+
```starlark
78+
load("@rules_sbom//sbom:defs.bzl", "sbom_artifact")
79+
80+
filegroup(
81+
name = "workspace_inputs",
82+
srcs = [
83+
"//:requirements.txt",
84+
"//:poetry.lock",
85+
"//:go.mod",
86+
"//:go.sum",
87+
],
88+
)
89+
90+
sbom_artifact(
91+
name = "workspace_sbom",
92+
target = ":workspace_inputs",
93+
)
94+
```
95+
96+
This pattern works for any combination of languages—add whatever manifests make sense for your repository.
97+
98+
### JavaScript and pnpm workspaces
99+
100+
JavaScript targets receive additional handling so you can switch between service and workspace scopes without manual staging:
101+
102+
- **Service SBOMs**: point `sbom_artifact` at the Bazel binary (for example a `js_binary`). The wrapper reduces the runfiles to the service's published assets, synthesizes a scoped `package.json`/`package-lock.json`, and disables unrelated catalogers so the SBOM contains only the dependencies that ship with that service.
103+
- **Workspace SBOMs**: collect the node workspace inputs and hand them to `sbom_artifact` for a holistic view:
104+
105+
```starlark
106+
load("@rules_sbom//sbom:defs.bzl", "sbom_artifact")
107+
108+
filegroup(
109+
name = "pnpm_workspace_inputs",
110+
srcs = [
111+
"//:node_modules",
112+
"//:package.json",
113+
"//:pnpm-lock.yaml",
114+
],
115+
)
116+
117+
sbom_artifact(
118+
name = "pnpm_workspace_sbom",
119+
target = ":pnpm_workspace_inputs",
120+
)
121+
```
122+
123+
Both modes produce CycloneDX documents tailored to pnpm monorepos without cross-service dependency bleed.
124+
51125
## Examples
52126

53127
- Python (basic): [`examples/python`](examples/python/BUILD.bazel)
@@ -56,32 +130,8 @@ The [`docs/`](docs/overview.md) directory contains more detailed usage and toolc
56130
- Go (cobra CLI with transitive deps): [`examples/go_complex`](examples/go_complex/BUILD.bazel)
57131
- Node.js (basic): [`examples/node`](examples/node/BUILD.bazel)
58132
- Node.js (express app with transitive deps): [`examples/node_complex`](examples/node_complex/BUILD.bazel)
59-
- JavaScript / pnpm monorepo scenarios:
60-
- Service/package SBOM: point `sbom_artifact` at the Bazel binary target (for example a `js_binary`). The Syft wrapper stages only that target's runfiles, synthesises a scoped `package.json`/`package-lock.json`, and disables GitHub Action catalogers, so the SBOM lists just the dependencies that ship with the service.
61-
- Whole-repo SBOM: collect the workspace-level pnpm state into a `filegroup` and wrap it with `sbom_artifact`:
62-
63-
```starlark
64-
load("@rules_sbom//sbom:defs.bzl", "sbom_artifact")
65-
66-
filegroup(
67-
name = "workspace_inputs",
68-
srcs = [
69-
"//:node_modules",
70-
"//:package.json",
71-
"//:pnpm-lock.yaml",
72-
],
73-
)
74-
75-
sbom_artifact(
76-
name = "workspace_sbom",
77-
target = ":workspace_inputs",
78-
)
79-
```
80-
81-
Building this target produces a CycloneDX SBOM that aggregates every dependency resolved across the pnpm workspace.
82-
- Go services:
83-
- Service-level SBOMs can include the compiled binary together with module metadata. One approach is to create a `filegroup` that contains the service binary plus `go.mod`/`go.sum`, then pass that group to `sbom_artifact` so Syft enumerates the transitive Go modules.
84-
- Workspace-level SBOMs can reuse the same `filegroup` pattern as the pnpm example above: add the repository `go.mod`/`go.sum` (and any additional module manifests) alongside the Node.js inputs before invoking `sbom_artifact`.
133+
134+
Each example maps directly onto the service-level recipe above; combine the manifests you need to produce a workspace-level SBOM.
85135

86136
## Release workflow
87137

0 commit comments

Comments
 (0)