Skip to main content

A tool to generate an AI BOM from source code.

Project description

AI BOM

The AI BOM tool scans codebases and container images to inventory AI framework components (models, agents, tools, prompts, and more). It currently parses Python source code, resolves fully qualified symbols, and matches them against a DuckDB catalog to produce an AI bill of materials (AI BOM). Optional LLM enrichment extracts model names, and a workflow pass annotates components with call-path context.

Table of Contents

Features

  • Static Python analysis: Uses libcst to capture assignments, decorators, type annotations, and context managers.
  • Container image scanning: Extracts /app from Docker images when available, otherwise scans site-packages.
  • DuckDB catalog matching: Maps fully qualified symbols to curated component categories.
  • Workflow context: Builds a lightweight call graph to show which workflows reach each component.
  • Derived relationships: Infers USES_TOOL and USES_LLM links from agent arguments.
  • Optional LLM enrichment: Uses litellm to extract model/embedding names from code snippets.
  • Multiple outputs: Plaintext, JSON, or a FastAPI UI server.
  • Report submission: Optional POST of the JSON report with retries.

Repository Layout

aibom/   # Python analyzer package + CLI
ui/      # React UI for exploring results
docs/    # UI/API documentation

Installation

Prerequisites

  • Python 3.11+
  • uv (Python package manager, recommended)
  • Docker (optional, for container image analysis)
  • Node.js 22+ (optional, for the React UI)
  • LLM provider API key (optional, for model extraction)

Installing as a CLI tool

# Install UV
curl -LsSf https://astral.sh/uv/install.sh | sh
# or: brew install uv

uv tool install --python 3.13 cisco-aibom

# Verify installation
cisco-aibom --help

Alternatively, install from source:

uv tool install --python 3.13 --from git+https://github.com/cisco-ai-defense/aibom cisco-aibom

# Verify installation
cisco-aibom --help

Installing for local development

git clone https://github.com/cisco-ai-defense/aibom.git
cd aibom/aibom

# Install UV (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# or: brew install uv

uv sync

# Activate virtual environment
source .venv/bin/activate  # Linux/macOS
# .venv\Scripts\activate   # Windows

# Verify installation
cisco-aibom --help

When working from source, you can also run the CLI with uv run cisco-aibom ... or uv run python -m aibom ....

Knowledge Base Configuration

The analyzer uses a local DuckDB catalog described by manifest.json. Download the catalog from a release artifact and point the analyzer at it with AIBOM_DB_PATH. When running from source, execute from the aibom/ directory or set AIBOM_MANIFEST_PATH to point at aibom/src/aibom/manifest.json. The DuckDB file is a prebuilt, versioned knowledge-catalog artifact of AI frameworks. It is used as a read-only lookup dataset, with checksum verification for compatibility and integrity. For installed users, the packaged manifest provides a default checksum and default catalog location (~/.aibom/catalogs/aibom_catalog-<version>.duckdb). You can still override with AIBOM_DB_PATH and AIBOM_DB_SHA256.

Override settings with environment variables:

  • AIBOM_DB_PATH: local DuckDB file path
  • AIBOM_DB_SHA256: SHA-256 checksum for the DuckDB file

AIBOM_DB_PATH may be absolute or relative. Relative env-var values are resolved from the current working directory; relative duckdb_file values in manifest.json are resolved from the manifest directory.

Usage

Analyze sources

# Local directory (JSON output)
cisco-aibom analyze /path/to/project --output-format json --output-file report.json

# Container image (JSON output)
cisco-aibom analyze langchain-app:latest --output-format json --output-file report.json

# Multiple images from a JSON list
cisco-aibom analyze --images-file images.json --output-format plaintext --output-file report.txt

--output-file is required for plaintext and json output formats.

Render a JSON report

cisco-aibom report report.json --raw-json

Optional LLM enrichment

cisco-aibom analyze /path/to/project \
  --output-format json \
  --output-file report.json \
  --llm-model gpt-3.5-turbo \
  --llm-api-base https://api.openai.com/v1 \
  --llm-api-key $OPENAI_API_KEY

Local LLM example:

cisco-aibom analyze /path/to/project \
  --output-format json \
  --output-file report.json \
  --llm-model ollama_chat/gemma3:12b \
  --llm-api-base http://localhost:11434

Optional report submission

cisco-aibom analyze /path/to/project \
  --output-format json \
  --output-file report.json \
  --post-url https://api.security.cisco.com/api/ai-defense/v1/aibom/analysis \
  --ai-defense-api-key $AI_DEFENSE_API_KEY

You can also set AIBOM_POST_URL instead of --post-url and AI_DEFENSE_API_KEY instead of --ai-defense-api-key.

The API key is sent as the x-cisco-ai-defense-tenant-api-key header. Use the same path in every region: /api/ai-defense/v1/aibom/analysis.

Choose the base domain for your Cisco AI Defense Organization region:

  • US: https://api.security.cisco.com/api/ai-defense/v1/aibom/analysis
  • APJ: https://api.apj.security.cisco.com/api/ai-defense/v1/aibom/analysis
  • EU: https://api.eu.security.cisco.com/api/ai-defense/v1/aibom/analysis
  • UAE: https://api.uae.security.cisco.com/api/ai-defense/v1/aibom/analysis

Testing

cd aibom
uv run pytest tests -v

Output Formats

Plaintext output

--- AI BOM Analysis Report ---

--- Results for source: langchain-app:latest ---

[+] Found 4 MODEL:
  - Name: langchain_community.llms.openai.OpenAI
    Model: gpt-3.5-turbo-instruct
    Source: /app/comprehensive_langchain_app.py:32
...
--- End of Report: Found 42 total components across all sources. ---

JSON output

{
  "aibom_analysis": {
    "metadata": {
      "run_id": "...",
      "analyzer_version": "0.1.0",
      "started_at": "2025-01-01T00:00:00Z",
      "completed_at": "2025-01-01T00:00:10Z"
    },
    "sources": {
      "langchain-app:latest": {
        "components": {
          "model": [
            {
              "name": "langchain_community.llms.openai.OpenAI",
              "file_path": "/app/app.py",
              "line_number": 32,
              "category": "model",
              "model_name": "gpt-3.5-turbo",
              "workflows": []
            }
          ]
        },
        "relationships": [
          {
            "source_instance_id": "...",
            "target_instance_id": "...",
            "label": "USES_LLM",
            "source_name": "...",
            "target_name": "...",
            "source_category": "agent",
            "target_category": "model"
          }
        ],
        "workflows": [
          {
            "id": "...",
            "function": "module.flow",
            "file_path": "/app/app.py",
            "line": 10,
            "distance": 0
          }
        ],
        "total_components": 42,
        "total_workflows": 7,
        "summary": {
          "status": "completed",
          "source_kind": "container"
        }
      }
    },
    "summary": {
      "total_sources": 1,
      "total_components": 42,
      "total_relationships": 3,
      "total_workflows": 7,
      "categories": {
        "model": 4,
        "tool": 8
      }
    },
    "errors": []
  }
}

UI Mode

--output-format ui starts a FastAPI server that serves the analyzed components:

cisco-aibom analyze /path/to/project --output-format ui

Endpoints:

  • GET /api/components
  • GET /api/components/types
  • GET /api/components/{id}
  • GET /health

The React UI in ui/ can connect to this server. See docs/UI_README.md and docs/API_SERVER_README.md for details.

Technical Details

  • Parsing: libcst extracts fully qualified names for calls, decorators, type annotations, and context managers.
  • Catalog matching: Symbols are matched against the DuckDB component_catalog table using their fully qualified IDs.
  • Workflow analysis: The AST-based workflow analyzer associates components with the functions that call into them.
  • Relationships: Agent arguments are inspected for tool/LLM references to derive USES_TOOL and USES_LLM links.
  • LLM enrichment: litellm is used only when --llm-model is supplied.

Troubleshooting

  • DuckDB catalog errors: Ensure the catalog file exists at AIBOM_DB_PATH (or duckdb_file in manifest) and that AIBOM_DB_SHA256 (or duckdb_sha256 in manifest) matches the file checksum. When running from source, execute from aibom/ or set AIBOM_MANIFEST_PATH.
  • Docker issues: Container analysis requires a working Docker CLI and daemon.
  • LLM configuration errors: --llm-api-base is required whenever --llm-model is set.
  • UI server does not start: If no components are found, the UI server exits early. Verify the target includes AI framework usage.
  • Missing output files: --output-file is mandatory for plaintext and json formats.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cisco_aibom-0.2.1.tar.gz (50.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cisco_aibom-0.2.1-py3-none-any.whl (46.4 kB view details)

Uploaded Python 3

File details

Details for the file cisco_aibom-0.2.1.tar.gz.

File metadata

  • Download URL: cisco_aibom-0.2.1.tar.gz
  • Upload date:
  • Size: 50.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cisco_aibom-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2a8f4449784f5c36206e009d86207d7b5ef1bb79fc3eb2c70237160df7657d70
MD5 3203ed6bc1fc6f01a5598c70c1448b5c
BLAKE2b-256 06891163fc40b6399815a9b42fa2a6d3da22f44425077b522726c7ba919fbc86

See more details on using hashes here.

Provenance

The following attestation bundles were made for cisco_aibom-0.2.1.tar.gz:

Publisher: publish-to-pypi.yml on cisco-ai-defense/aibom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cisco_aibom-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cisco_aibom-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 46.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cisco_aibom-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac17123767f402e5ca923d882a98667be993f873a0feab76c69dcb7e7e58e3be
MD5 a0dfaa3602a07c78d49a56c837746996
BLAKE2b-256 208c24ab49fc3dd72361e4b765fb1b90870b2ef640dbe4b24b012a0ff39889db

See more details on using hashes here.

Provenance

The following attestation bundles were made for cisco_aibom-0.2.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on cisco-ai-defense/aibom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page