Skip to main content
EXPERIMENTAL: This feature is experimental and may introduce breaking changes.
vet uses the code analysis framework built on tree-sitter parsers. The framework supports multiple languages and source repositories (local and remote), and writes findings to a SQLite database that vet scan uses to enrich manifest analysis. Use it to see which dependencies your code actually uses. When you triage vulnerabilities, put the packages that the code imports first, and deprioritize the packages that are only declared.

Build a Code Analysis Database

Build a SQLite database from your source code. The database is a prerequisite for code analysis features in vet scan.
This command analyzes application code recursively in the specified directory and creates a SQLite database with the findings. Omit --lang to scan all supported languages.

Supported Languages

The code analysis framework supports these languages through tree-sitter parsers:
  • Python
  • JavaScript/TypeScript
  • Java
  • Go
  • And more…

Scan with Dependency Usage Analysis

Pass the database to vet scan via the --code flag. Dependency usage analysis is enabled by default when a code database is provided.
With a code database, vet scan adds:
  1. Manifest Analysis: scans package manifests in the specified directory
  2. Usage Enrichment: enriches packages with dependency usage data from the database
  3. Evidence-Based Results: shows a scan summary with usage evidence and used-in-code tags for packages confirmed as used in code
vet scan with code analysis database

Usage evidence

The code analysis records these types of evidence:
These direct imports are tracked as usage evidence.
Dependencies found in your source code get the used-in-code tag, so you can prioritize them over packages that are only declared in a manifest.

Demo

Practical Example

Full workflow for a Python project:
1

Analyze Code

Build the code analysis database for your Python project:
2

Enhanced Scan

Run vet scan with the code database:
3

Review Results

Check the scan results for:
  • Dependencies actually used in code vs. declared
  • Unused dependencies that could be removed
  • Usage patterns and import analysis

Advanced Usage

Multi-language Projects

For projects with multiple languages, omit the --lang flag:
To scan only JavaScript and TypeScript, use --lang javascript --lang typescript.

Custom Database Locations

Organize databases by project, environment or scope:

Integration with CI/CD

Limitations

This feature is experimental and may have breaking changes. Test before using in production.
Code analysis adds processing time to scans. Weigh the accuracy benefit against the speed cost for your use case.
Code analysis databases can grow large for extensive codebases. Monitor disk usage and remove old databases periodically.

Code Framework

Learn more about the underlying code analysis framework

Tree-sitter

Understand the parsing technology behind code analysis

Policy as Code

Create policies that use the usage information

Vet GitHub Repository

Access the main Vet documentation and examples