--use-bazel-aspects flag when scanning Bzlmod-based projects.
Prerequisites for scanning Bazel projects
Ensure that the following prerequisites are in place for a successful scan:WORKSPACEfile exists in your repositorybazelcommand installed and available- Bazel version
5.x.x,6.x.x, or7.x.x - Supported target types in your project
System specifications for deep scans of Bazel projects
Before you proceed to run a deep scan, ensure that your system meets the following specification.| Project Size | Processor | Memory |
|---|---|---|
| Small projects | 4-core processor | 16 GB |
| Mid-size projects | 8-core processor | 32 GB |
| Large projects | 16-core processor | 64 GB |
Build process for Bazel projects
You can choose to build the targets before running the scan. Use thebazel build commands to do this by passing a comma-separated list of targets. For example, for targets //:test and //:test2, run bazel build //:test,//:test2.
endorctl will automatically build targets if they are not already built. endorctl uses bazel build //:target and bazel query 'deps(//:target)' --output graph to build each target and analyze its dependency tree.
Supported Bazel rules and features
The following table lists the supported Bazel rules and Endor Labs features for each language.Quick target discovery for Bazel projects
Use the following commands to find scannable targets in your repository.- Java
- Python
- Go
- Scala
- Rust
- All binary targets
Common query patterns for Bazel projects
Use these common query patterns to find targets. Run the following command to find all targets in a specific package.Scan commands for Bazel projects
The following table lists the common flags and options to scan Bazel projects.Target selection for Bazel scans
To scan with Endor Labs, you need to specify which targets to analyze using one of two approaches:- Specific target list: Provide a comma-separated list of exact targets using
--bazel-include-targets. - Query-based selection: Use the Bazel query language to select all targets matching your criteria with
--bazel-targets-query.
Quick scan for Bazel projects
Run a fast scan for software composition visibility without reachability analysis.Deep scan for Bazel projects
Perform a full analysis with dependency resolution, reachability analysis, and call graphs.Private Package Analysis
When a deep scan is performed, all private software dependencies are completely analyzed by default if they have not been previously scanned. This is a one-time operation and will slow down initial scans, but won’t impact subsequent scans.
When a deep scan is performed, all private software dependencies are completely analyzed by default if they have not been previously scanned. This is a one-time operation and will slow down initial scans, but won’t impact subsequent scans.
Scan specific targets for Bazel projects
You can scan specific targets in your Bazel project using the--bazel-include-targets flag.
Run the following command to scan a single target.
Scan using queries for Bazel projects
Use these commands to scan targets based on queries.- Java
- Python
- Go
- Scala
- Rust
- All binary targets
Scan Bazel projects with non-root workspace
If yourWORKSPACE file isn’t at the repository root.
Scan Bazel projects with Go with Gazelle (Vendored Mode)
For Go projects using Bazel with Gazelle in vendored mode.Scan Bazel projects with performance optimization
For large codebases, disable private package analysis.Language-specific information for Endor Labs scans
For detailed information about scanning specific languages:Results of Bazel projects scans
You can save the findings of your scans to a local file or view the findings in the Endor Labs user interface.Save findings locally
Run the following command to save the results of a quick scan to a local file.View findings in the Endor Labs user interface
To view your scan results in the Endor Labs user interface:- Sign in to Endor Labs user interface and select Projects from the left sidebar.
- Select the project you want to view and click Findings to view your scan results.
Troubleshooting Bazel projects scans
Check the following common issues and solutions for Bazel projects scans.No targets found
No targets found
Check your query syntax and target types.
Workspace not found
Workspace not found
Use
--bazel-workspace-path flag.Build failures
Build failures
Pre-build targets with
bazel build.Slow scans
Slow scans
Use
--disable-private-package-analysisGo vendored issues
Go vendored issues
Specify
--bazel-vendor-manifest-path.