# Advanced Usage
## Evinse Mode / SaaSBOM
Evinse (Evinse Verification Is Nearly SBOM Evidence) is a command with cdxgen to generate component evidence and SaaSBOM for supported languages. The tool is powered by [atom](https://github.com/AppThreat/atom) for several source-analysis flows and by `golem` for Go semantic evidence when the optional `@cdxgen/cdxgen-plugins-bin` helper is available.
### Pre-requisites
- Java >= 21 installed
- Application source code
- Input SBOM in CycloneDX >1.5 format. Use cdxgen to generate one.
### Usage
```shell
evinse -h
Options:
-i, --input Input SBOM file. Default bom.json
[default: "bom.json"]
-o, --output Output file. Default bom.evinse.json
[default: "bom.evinse.json"]
-l, --language Application language
[choices: "java", "jar", "javascript", "python", "android", "cpp"] [default: "
java"]
--force Force creation of the database
[boolean] [default: false]
--skip-maven-collector Skip collecting jars from maven and gradle cach
es. Can speedup re-runs if the data was cached
previously. [boolean] [default: false]
--with-deep-jar-collector Enable collection of all jars from maven cache
directory. Useful to improve the recall for cal
lstack evidence. [boolean] [default: false]
--annotate Include contents of atom slices as annotations
[boolean] [default: true]
--with-data-flow Enable inter-procedural data-flow slicing.
[boolean] [default: false]
--exclude, --exclude-regex Additional glob pattern(s) to ignore during
Atom evidence generation. [array]
--usages-slices-file Use an existing usages slices file.
[default: "usages.slices.json"]
--data-flow-slices-file Use an existing data-flow slices file.
[default: "data-flow.slices.json"]
-p, --print Print the evidences as table [boolean]
--version Show version number [boolean]
-h Show help [boolean]
```
To generate an SBOM with evidence for a java project.
```shell
evinse -i bom.json -o bom.evinse.json
```
By default, only occurrence evidences are determined by creating usages slices. To generate callstack evidence, pass `--with-data-flow`
```shell
evinse -i bom.json -o bom.evinse.json --with-data-flow
```
To improve performance, you can cache the generated usages and data-flow slices file along with the bom file.
```shell
evinse -i bom.json -o bom.evinse.json --usages-slices-file usages.json --data-flow-slices-file data-flow.json --with-data-flow
```
For JavaScript or TypeScript projects, pass `-l javascript`.
```shell
evinse -i bom.json -o bom.evinse.json --usages-slices-file usages.json --data-flow-slices-file data-flow.json -l javascript --with-data-flow
```
For Go projects, generate a base Go SBOM and enrich it with Golem-backed semantic evidence.
```shell
cdxgen -t go -o bom.json
evinse -i bom.json -o bom.evinse.json -l go --golem-callgraph static
```
The Go Evinse integration emits occurrence and call-stack evidence plus `cdx:golem:*` properties for usage scopes, occurrence kinds, security signals, local replacements, vendoring, private module candidates, license-file evidence, build directives, generated files, native artifacts, and Go toolchain directives. Use `cdxi bom.evinse.json` with `.golemsummary`, `.golemhotspots`, `.golemcoverage`, `.occurrences`, and `.callstack` for review. Use `cdx-audit --bom bom.evinse.json --direct-bom-audit --categories golem` for focused policy checks.
See [Go Evinse with Golem](./docs/GO_EVINSE_GOLEM.md) for the complete workflow.
When cdxgen or evinse invokes atom for evidence generation, `--exclude` glob patterns are converted to Scala/Java-compatible regular expressions and applied to Atom evidence. Directory fragments are also forwarded through `CHEN_IGNORE_DIRS`, which Atom applies across supported frontends. For JavaScript and TypeScript, the same directory fragments are forwarded through `ASTGEN_IGNORE_DIRS` to improve astgen traversal performance.
```shell
cdxgen -t js --profile research --exclude "**/fixtures/**" --exclude "**/*.spec.js" -o bom.json
```
## Generate SBOM from maven or gradle cache
There could be Java applications with complex dependency requirements. Or you might be interested in cataloging your Maven or gradle cache.
A bonus of this mode is that the resulting SBOM would have a property called `internal:Namespaces` with a list of class names belonging to each jar.
### Generate evidence of usage
After generating an SBOM from a cache, we can now look for evidence of direct usage with evinse!
```shell
# compile or build your application
evinse -i -o bom.evinse.json
# Generate data-flow evidence (Takes a while)
# evinse -i -o bom.evinse.json --with-data-flow
```
Evinse would populate component.evidence object with occurrences (default) and callstack (in data-flow mode). Those without evidence are either transitive or unused dependencies.
## Interactive mode
`cdxi` is a new interactive REPL server to create, import, and search a BOM. All the exported functions from cdxgen and node.js could be used in this mode. In addition, several custom commands are defined.
[](https://asciinema.org/a/602361)
### Custom commands
| Command | Description |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| .create | Create an BOM from a path |
| .import | Import an existing BOM from a path. Any BOM in CycloneDX format is supported. |
| .search | Search the given string in the components name, group, purl and description |
| .sort | Sort the components based on the given attribute. Eg: .sort name to sort by name. Accepts full jsonata [order by](http://docs.jsonata.org/path-operators#order-by-) clause too. Eg: `.sort components^(>name)` |
| .query | Pass a raw query in [jsonata](http://docs.jsonata.org/) format |
| .print | Print the BOM as a table |
| .tree | Print the dependency tree if available |
| .validate | Validate the SBOM |
| .exit | To exit the shell |
| .save | To save the modified BOM to a new file |
| .update | Update components based on query expression. Use syntax `\| query \| new object \|`. See example. |
| .occurrences | View components with evidence.occurrences as a table. Use evinse command to generate such an SBOM |
| .callstack | View components with evidence.callstack.frames as a table. Use evinse command to generate such an SBOM |
| .services | View services as a table |
| .golemsummary | Summarize Go Evinse/Golem metadata and evidence coverage |
| .golemhotspots | View Go components with Golem security, replacement, private, or vendored signals |
| .golemcoverage | View Go components with Golem occurrence, scope, or call-stack evidence |
In addition, all the keys from [queries.json](./data/queries.json) are also valid commands. Example: `processes`, `apt_sources`, etc. Type `.help` to view the full list of commands.
### Sample REPL usage
Start the REPL server.
```shell
cdxi
```
Below are some example commands to create an SBOM for a spring application and perform searches and queries.
```
.create /mnt/work/vuln-spring
.print
.search spring
.query components[name ~> /spring/ and scope = "required"]
.query components[scope='required'].purl
// Supplier names
.query $distinct(components.supplier.name)
.sort name
.sort components^(>name)
.update | components[name ~> /spring/] | {'publisher': "foo"} |
```
### REPL History
Repl history will persist under the `$`HOME/.config/.cdxgen`directory. To override this location, use the environment variable`CDXGEN_REPL_HISTORY`.
## Mixed Java Projects
If a java project uses Maven and gradle, maven is selected for SBOM generation under default settings. To force cdxgen to use gradle, use the argument `-t gradle`. Similarly, use `-t scala` for scala SBT.
## Generating container SBOM on Windows
cdxgen supports generating container SBOM for Linux images on Windows. Follow the steps listed below.
- Ensure cdxgen-plugins-bin >= 2.2.0 is installed.
```shell
npm install -g @cdxgen/cdxgen-plugins-bin
```
- Run "Docker for Desktop" as an administrator with the 'Exposing daemon on TCP without TLS' setting turned on.
Run Powershell terminal as administrator. Without this, cdxgen would fail while extracting symlinks.
- Invoke cdxgen with `-t docker`
```shell
cdxgen -t docker -o bom.json
```
### Using WSL Containers (wslc)
Docker Desktop is optional on Windows hosts with WSL. cdxgen can pull and export images with [wslc](https://learn.microsoft.com/en-us/windows/wsl/wsl-container), the container CLI that ships with WSL ("WSL Containers", generally available with WSL 3.x).
When the docker CLI is not installed, cdxgen automatically uses wslc for image operations, so OCI scans work without Docker Desktop:
```shell
wsl --update
wsl --install --no-distribution
# Reboot if "Virtual Machine Platform" was just enabled
cdxgen -t oci -o bom.json alpine:latest
```
Requirements and notes:
- WSL 2.9.3 or higher (`wsl --version`). wslc pulls images for the host architecture only.
- The 'Virtual Machine Platform' optional component must be enabled, with virtualization enabled in the firmware. When Windows itself runs inside a VM (for example, a cloud instance or Parallels), nested virtualization must be available for the wslc container session to start.
- Set the environment variable `DOCKER_CMD=wslc` to force wslc even when a docker CLI is installed. cdxgen never switches from an installed docker CLI to wslc on its own, since wslc keeps a separate image store. When docker cannot provide the image, for example because Docker Desktop is not running or is switched to Windows containers, cdxgen suggests `DOCKER_CMD=wslc` if wslc is installed.
- Registry authentication configured with `wslc login` is used for private registries.
- When `CDXGEN_ALLOWED_COMMANDS` is set, add `wslc` to the list. The activity report records which container CLI was selected.
## Generate SBOM with evidence for the cdxgen repo
Why not?
```shell
cdxgen -t php -t js -t jar -t ruby --exclude "**/test/**" -o bom.json
evinse -i bom.json -o bom.evinse.json -l javascript
# Don't be surprised to see the service endpoint offered by cdxgen!
# Review the reachables.slices.json and file any vulnerabilities or bugs!
```
## Go Evinse data-flow and crypto-flow evidence
For Go projects, generate the base SBOM first and then enrich it with `evinse -l go`. The Go Evinse path uses the optional `golem` helper from `@cdxgen/cdxgen-plugins-bin` to attach occurrence evidence, call-stack frames, usage scopes, security signals, crypto components, and data-flow/crypto-flow properties.
```shell
cdxgen -t go -o bom.json /absolute/path/to/go/project
evinse -i bom.json -o bom.evinse.json -l go --golem-callgraph static /absolute/path/to/go/project
```
For bounded crypto-flow evidence, use:
```shell
evinse -i bom.json -o bom.evinse.json -l go \
--with-data-flow \
--golem-dataflow crypto \
--golem-dataflow-pattern-packs crypto \
/absolute/path/to/go/project
```
`--deep` enables the same Golem data-flow collection with performance safeguards. cdxgen caps worker count and `GOMAXPROCS`, applies slice and trace limits, skips generated files by default, and skips tests unless `--golem-tests` is supplied. The enriched BOM uses `cdx:golem:*` properties such as `cdx:golem:dataFlowMode`, `cdx:golem:cryptoDataFlow`, `cdx:golem:cryptoAlgorithms`, and `cdx:golem:usageScopes`. Rendered crypto components are `type: "cryptographic-asset"` and intentionally do not have purls.
## Use Atom in Java mode
For large projects (> 1 million lines of code), atom must be invoked separately for the slicing operation. Follow the instructions below.
- Download the latest [atom.zip release](https://github.com/AppThreat/atom/releases)
```shell
unzip atom.zip
cd atom-1.0.0/bin
./atom -J-Xmx16g usages -o app.atom --slice-outfile usages.json -l c
node bin/cdxgen.js -o bom.json -t c --usages-slices-file usages.json
```
Change 16g to 32g or above for very large projects. For the Linux kernel, a minimum of 128GB is required.