Go CLI tool that scans a repository for Hugging Face model and dataset usage and emits a CycloneDX AI Bill of Materials (AIBOM).
This repository is part of the broader AIBoMGen ecosystem for generating, analyzing, and validating AI/ML Bills of Materials (AIBOMs).
Requires Go:
go install github.com/idlab-discover/aibomgen-cli@latestEnsure $HOME/go/bin is in your PATH, then verify:
aibomgen-cli --helpUninstall:
rm "$(go env GOPATH)/bin/aibomgen-cli"
hash -r # refresh shell command cacheVERSION=0.2.0 # replace with the desired version (without leading 'v')
OS=$(uname -s | tr '[:upper:]' '[:lower:]') # linux, darwin
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/') # amd64, arm64
curl -L -o aibomgen-cli_${VERSION}_${OS}_${ARCH}.tar.gz \
https://github.com/idlab-discover/aibomgen-cli/releases/download/v${VERSION}/aibomgen-cli_${VERSION}_${OS}_${ARCH}.tar.gz
tar -xzf aibomgen-cli_${VERSION}_${OS}_${ARCH}.tar.gz
chmod +x aibomgen-cli
sudo mv aibomgen-cli /usr/local/bin/aibomgen-cli
hash -r # refresh shell command cache without opening a new terminalUninstall:
sudo rm /usr/local/bin/aibomgen-cli
rm -f ~/.local/share/bash-completion/completions/aibomgen-cli
hash -r # refresh shell command cachego test ./...
go build -o aibomgen-cli .
aibomgen-cli --helpUninstall:
rm ./aibomgen-cliSettings can come from multiple sources. The priority order (lowest to highest) is:
- Built-in defaults: hardcoded in the code
- Config file: values from
~/.aibomgen-cli.yamlor./config/defaults.yaml(or a custom path set with--config) - Environment variables:
AIBOMGEN_*prefix (e.g.,AIBOMGEN_GENERATE_HF_TOKEN) - Command-line flags:
--flagarguments (highest priority)
Each level overrides the ones below it. For example:
# 1. Default value from code (if set)
# 2. Config file value (if present)
generate:
hf-token: "hf_config_value"
# 3. Environment variable (if set)
export AIBOMGEN_GENERATE_HF_TOKEN="hf_env_value"
aibomgen-cli generate gpt2
# Result: env_value is used
# 4. Explicit flag (always wins)
aibomgen-cli generate gpt2 --hf-token hf_flag_value
# Result: flag_value is used (env var and config are ignored)Config keys match the flag names. Dashes and dots become underscores in env var names:
generate.hf-token→AIBOMGEN_GENERATE_HF_TOKENvuln-scan.hf-timeout→AIBOMGEN_VULN_SCAN_HF_TIMEOUTverbose→AIBOMGEN_VERBOSE(top-level keys have no command prefix)
Hugging Face settings. generate, scan, enrich and vuln-scan share --hf-token, --hf-base-url and --hf-timeout (default 10 seconds). When no token or base URL is configured, the standard Hugging Face env vars HF_TOKEN and HF_ENDPOINT are used. Prefer HF_TOKEN over --hf-token: a token on the command line ends up in your shell history and the process list.
Commands that read a file or directory take it as an argument; --input, -i does the same and is useful in a config file. Passing both is an error.
Walks a directory for AI-related imports across Python, YAML, JSON, Markdown, shell, Dockerfile, and JavaScript/TypeScript files. Writes one AIBOM per detected model. Security scan data from the Hugging Face tree API is embedded in each BOM by default.
aibomgen-cli scan # current directory
aibomgen-cli scan targets/target-3 --format xml
aibomgen-cli scan targets/target-1 --no-security-scanBy default this writes one JSON file per model under dist/, e.g.:
dist/google-bert_bert-base-uncased.aibom.cdx.jsondist/templates_model-card-example.aibom.cdx.json
File names follow the CycloneDX *.cdx.json / *.cdx.xml convention: <model-ref>.aibom.cdx.<json|xml>, where <model-ref> is the requested model ID (plus _<revision> when one was requested) with every character outside [A-Za-z0-9._-] replaced by _. Names that collide get a _2, _3, … suffix. Existing files are overwritten.
Usage: aibomgen-cli scan [dir]
--input, -i <dir>: directory to scan, instead of the argument (default: current directory)--output, -o <dir>: output directory (default:dist)--format, -f json|xml(default:json)--spec <version>: CycloneDX spec version for output, e.g.1.6(default: latest,1.7)--no-security-scan: skip fetching the Hugging Face security scan tree--hf-token,--hf-base-url,--hf-timeout: see Hugging Face settings above
Generates an AIBOM from one or more Hugging Face model IDs, or from models picked in an interactive browser. Security scan data is embedded in the BOM by default. Use scan instead when you want to detect models from a source directory.
aibomgen-cli generate google-bert/bert-base-uncased
aibomgen-cli generate gpt2 meta-llama/Llama-3.1-8B@main
aibomgen-cli generate --interactiveUsage: aibomgen-cli generate [model-id...]
--model-id, -m <id>: model ID asorg/nameororg/name@revision; repeatable or comma-separated, combined with the arguments--interactive: pick models in an interactive selector (needs a terminal; cannot be combined with model IDs)--output, -o <dir>: output directory (default:dist)--format, -f json|xml(default:json)--spec <version>: CycloneDX spec version for output, e.g.1.6(default: latest,1.7)--no-security-scan: skip fetching the Hugging Face security scan tree--hf-token,--hf-base-url,--hf-timeout: see Hugging Face settings above
Validates an existing AIBOM file (JSON or XML).
- Schema: JSON BOMs are checked against the official CycloneDX JSON schema for their spec version (1.2–1.7, embedded, no network), including formats such as
date-timeandiri-reference. XML BOMs and spec 1.0/1.1 skip this check with a warning. - Integrity: bom-refs must be unique; references (model-card datasets, dependencies, vulnerability
affects) that don't resolve are reported as warnings. - Completeness:
--min-scoreis enforced in every mode. With--strict, missing required model and dataset fields are errors. - Vulnerabilities: reported as warnings; with
--strict, those rated at or above--fail-severityare errors.
aibomgen-cli validate dist/google-bert_bert-base-uncased.aibom.cdx.json
aibomgen-cli validate dist/google-bert_bert-base-uncased.aibom.cdx.json --strict --min-score 0.5Usage: aibomgen-cli validate [file]
--input, -i <file>: AIBOM file, instead of the argument--strict: fail on missing required fields and on vulnerabilities rated at or above--fail-severity--fail-severity critical|high|medium|low|info: lowest vulnerability severity that fails--strict(default:medium). Vulnerabilities below it, or without a rated severity, are reported as warnings. Hugging Face scanner findings are ratedcritical(unsafe),high(suspicious) ormedium(caution).--min-score 0.0-1.0: minimum acceptable completeness score--json: print the result as JSON
Exit codes: 0 valid, 1 error (unreadable file, invalid flag, …), 2 invalid BOM.
Computes and prints a completeness score for an existing AIBOM using the metadata field registry. Scores both the model component and any linked dataset components.
aibomgen-cli completeness dist/google-bert_bert-base-uncased.aibom.cdx.json
aibomgen-cli completeness dist/google-bert_bert-base-uncased.aibom.cdx.json --json | jq .scoreUsage: aibomgen-cli completeness [file]
--input, -i <file>: AIBOM file, instead of the argument--json: print the result as JSON
Enriches an existing AIBOM by filling missing metadata fields: interactively, or from a YAML file with --file (see config/enrichment.yaml for an example). By default the latest metadata is refetched from Hugging Face first.
aibomgen-cli enrich dist/google-bert_bert-base-uncased.aibom.cdx.json
aibomgen-cli enrich dist/google-bert_bert-base-uncased.aibom.cdx.json --file config/enrichment.yaml --yesUsage: aibomgen-cli enrich [file]
--input, -i <file>: AIBOM file, instead of the argument--output, -o <file>: output file (default: overwrite the input); a.xmlpath writes XML, anything else JSON--spec <version>: CycloneDX spec version for output (default: same as input)--file <path>: YAML file with the values to fill in, instead of prompting (required when not running in a terminal)--required-only: only fill required fields--min-weight <float>: only fill fields with at least this weight--refetch: refetch model metadata from Hugging Face first (default:true; disable with--refetch=false)-y, --yes: save without preview or confirmation (required when not running in a terminal)--hf-token,--hf-base-url,--hf-timeout: see Hugging Face settings above
Fetches per-file security scan results from the Hugging Face Hub for every model and dataset component referenced in an existing AIBOM and displays a vulnerability report. The scanners covered are Cisco Foundation AI (ClamAV), ProtectAI, HuggingFace Pickle Scanner, VirusTotal, and JFrog Research.
Optionally re-injects the findings back into the AIBOM as CycloneDX BOM.Vulnerabilities using --enrich.
aibomgen-cli vuln-scan dist/google-bert_bert-base-uncased.aibom.cdx.json
aibomgen-cli vuln-scan dist/google-bert_bert-base-uncased.aibom.cdx.json --enrich
aibomgen-cli vuln-scan dist/google-bert_bert-base-uncased.aibom.cdx.json --enrich --yesUsage: aibomgen-cli vuln-scan [file]
--input, -i <file>: AIBOM file, instead of the argument--output, -o <file>: output file with--enrich(default: overwrite the input); a.xmlpath writes XML, anything else JSON--spec <version>: CycloneDX spec version for output (default: same as input)--enrich: inject discovered vulnerabilities back into the AIBOM-y, --yes: apply without preview or confirmation (only with--enrich; required when not running in a terminal)--json: print the scan results as JSON--hf-token,--hf-base-url,--hf-timeout: see Hugging Face settings above
[BETA] Merges one or more AIBOMs with an existing SBOM from a different source (e.g., Syft, Trivy) into a single comprehensive BOM.
The SBOM's application metadata is preserved as the main component, while AI/ML model and dataset components from the AIBOM(s) are added to the components list.
# 1. Generate SBOM for software dependencies using Syft
syft scan . -o cyclonedx-json > sbom.json
# 2. Generate AIBOMs for AI/ML components using AIBoMGen
aibomgen-cli scan .
# 3. Merge them into a comprehensive BOM
aibomgen-cli merge dist/*.aibom.cdx.json --sbom sbom.json -o merged.cdx.jsonUsage: aibomgen-cli merge [aibom...] --sbom <file> -o <file>
--aibom <file>: AIBOM file; repeatable, combined with the arguments--sbom <file>: SBOM file to merge into (required)--output, -o <file>: output file for the merged BOM (required); a.xmlpath writes XML, anything else JSON--no-deduplicate: keep components with duplicate BOM-refs (by default duplicates are removed)
Prints the version: aibomgen-cli version.
--config <path>: config file to use (default:$HOME/.aibomgen-cli.yamlor./config/defaults.yaml)-q, --quiet: only print errors and results (no progress output)-v, --verbose: log to stderr;-vshows info (config file used, scan and vuln-scan summaries, missing optional fields invalidate),-vvadds debug detail (HF requests, scanner hits, metadata fields applied, completeness checks, merge dedup)--no-input: never prompt; commands that would need input fail with a hint instead
-q and -v are mutually exclusive. -q silences output, not prompts.
Output streams and interactive mode. Results go to stdout. Logs, prompts and TUIs (the generate --interactive model selector, enrich forms, and the confirmations of enrich and vuln-scan --enrich) go to stderr. While a prompt is open, log lines are held back and printed when it closes, so -v/-vv can be combined with interactive mode. Prompts only run when stdin and stderr are terminals; otherwise (CI, pipes, --no-input) the command fails up front with a hint, such as --file or --yes. Progress spinners are only animated on a terminal without -v.
Machine-readable output. validate, completeness and vuln-scan accept --json to print their result as JSON on stdout, with no styling or progress output. Exit codes are unchanged.
The config file is a YAML file that sets default values for any command flag, so you don't have to repeat them on the command line. Keys are namespaced by command:
verbose: 2 # same as -vv, for every command
scan:
output: "out"
no-security-scan: true
validate:
strict: true
min-score: 0.5Any flag not passed on the CLI falls back to the config file value. CLI flags always take precedence. See config/defaults.yaml for a full reference of all available keys.
- API reference: pkg.go.dev/github.com/idlab-discover/aibomgen-cli
targets/— small repositories used in integration tests and examplesdocs/mapping/— field mapping: where every AIBOM value comes fromdocs/draft/— examples and the demo recordingconfig/defaults.yaml— full reference of all config file keys
For inquiries, feel free to reach out
Maintained by:
Wiebe Vandendriessche
wiebe.vandendriessche@ugent.be
LinkedIn
DISCOVER: IDLab, Ghent University – imec.
This project is licensed under the terms described in the LICENSE file.
This work has been partially supported by the CRACY project, funded by the European Union’s Digital Europe Programme under grant agreement No 101190492.

