> ## Documentation Index
> Fetch the complete documentation index at: https://docs.endorlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bazel

> Learn how to implement Endor Labs in monorepos using Bazel

Bazel is an open-source build and test tool commonly used in monorepos to quickly build software across multiple languages.

You can use Endor Labs and Bazel to scan software for potential security issues and policy violations, prioritize vulnerabilities in the context of your applications, and understand relationships between software components.

Endor Labs also supports Bazel aspects to augment the build dependency graphs with additional information and actions. If you use custom rules to build your software, you can create your own custom Bazel aspects and integrate them with Endor Labs. See [Bazel Aspects](https://docs.endorlabs.com/scan/bazel/bazel-aspects.md) for more information.

Endor Labs supports [Bzlmod](https://bazel.build/external/migration) (Bazel's external dependency system). Bzlmod support requires Bazel aspects. Use the `--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:

* `WORKSPACE` file exists in your repository
* `bazel` command installed and available
* Bazel version `5.x.x`, `6.x.x`, `7.x.x`, `8.x.x`, or `9.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 the `bazel 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.




&#x20; \- Language: \[Java]\(https\://github.com/bazelbuild/rules\_jvm\_external)
&#x20; Supported\_Rules: \[java\_library]\(https\://bazel.build/reference/be/java#java\_library), \[java\_binary]\(https\://bazel.build/reference/be/java#java\_binary)\<br>\<br>While dependency scanning is supported for \`java\_binary\` targets, call graph generation requires an uber jar containing all dependencies. The \`java\_binary\` rule itself does not produce an uber jar, but its \`deploy.jar\` output provides the necessary consolidated dependencies for call graph analysis.\<br>\<br>-note- Bzlmod is supported with Bazel aspects. Requires \`rules\_java\` >= 5.0.0.
&#x20; Version\_Requirements: 4.1+
&#x20; \- Language: \[Python]\(https\://github.com/bazelbuild/rules\_python)
&#x20; Supported\_Rules: \[py\_binary]\(https\://bazel.build/reference/be/python#py\_binary), \[py\_library]\(https\://bazel.build/reference/be/python#py\_library), \[py\_image]\(https\://github.com/bazelbuild/rules\_docker/blob/master/README.md#py3\_image)\<br>\<br>-warning- \`py\_image\` only supports PY3 toolchain (\`py3\_image\`)\<br>\<br>For \`rules\_python\` below 0.30.0, only the WORKSPACE model is supported (no Bzlmod). Bzlmod requires \`rules\_python\` 0.30.0 or higher with Bazel aspects. Software composition analysis includes reachability analysis.
&#x20; Version\_Requirements: 0.9.0+
&#x20; \- Language: \[Go]\(https\://github.com/bazelbuild/rules\_go)
&#x20; Supported\_Rules: \[go\_binary]\(https\://github.com/bazelbuild/rules\_go/blob/master/docs/go/core/rules.md#go\_binary), \[go\_library]\(https\://github.com/bazelbuild/rules\_go/blob/master/docs/go/core/rules.md#go\_library), \[go\_image]\(https\://github.com/bazelbuild/rules\_docker/blob/master/README.md#go\_image)
&#x20; Version\_Requirements: 0.40.1+ (Bazel 5.x-6.x), 0.42.0+ (Bazel 7.x)\<br>\<br>For \[Bazel with Gazelle in vendored mode]\(https\://github.com/bazelbuild/bazel-gazelle?tab=readme-ov-file#bazel-rule), see \[Go with Gazelle]\(#scan-bazel-projects-with-go-with-gazelle-vendored-mode).\<br>\<br>Supports both WORKSPACE model and Bzlmod. Bzlmod requires Bazel Aspects.
&#x20; \- Language: \[Scala]\(https\://github.com/bazelbuild/rules\_scala)
&#x20; Supported\_Rules: \[scala\_binary]\(https\://github.com/bazelbuild/rules\_scala/blob/master/docs/scala\_binary.md), \[scala\_library]\(https\://github.com/bazelbuild/rules\_scala/blob/master/docs/scala\_library.md)\<br>\<br>Requires \`rules\_scala\` >= 5.0.0. Supports both WORKSPACE model and Bzlmod.
&#x20; Version\_Requirements: 5.0.0 - 6.6.0
&#x20; \- Language: \[Kotlin]\(https\://github.com/bazel-contrib/rules\_kotlin)
&#x20; Supported\_Rules: \[kt\_jvm\_library]\(https\://github.com/bazel-contrib/rules\_kotlin/blob/master/docs/kotlin.md#kt\_jvm\_library), \[kt\_jvm\_binary]\(https\://github.com/bazel-contrib/rules\_kotlin/blob/master/docs/kotlin.md#kt\_jvm\_binary), \[kt\_jvm\_test]\(https\://github.com/bazel-contrib/rules\_kotlin/blob/master/docs/kotlin.md#kt\_jvm\_test)\<br>\<br>Kotlin dependencies are resolved as Maven packages. Software composition analysis includes reachability analysis.\<br>\<br>Requires \`rules\_kotlin\` >= 2.0.0. Requires Bazel Aspects. Supports both WORKSPACE model and Bzlmod.
&#x20; Version\_Requirements: 2.0.0+
&#x20; \- Language: \[Rust]\(https\://github.com/bazelbuild/rules\_rust)
&#x20; Supported\_Rules: \[rust\_binary]\(https\://bazelbuild.github.io/rules\_rust/rust.html#rust\_binary), \[rust\_library]\(https\://bazelbuild.github.io/rules\_rust/rust.html#rust\_library)\<br>\<br>Requires \`rules\_rust\` >= 0.40.0. Requires Bazel Aspects. Supports both WORKSPACE model and Bzlmod.
&#x20; Version\_Requirements: 0.40.0+
&#x20; \- Language: \[Swift]\(https\://github.com/bazelbuild/rules\_swift)
&#x20; Supported\_Rules: \[swift\_binary]\(https\://github.com/bazelbuild/rules\_swift/blob/main/doc/rules.md#swift\_binary), \[swift\_library]\(https\://github.com/bazelbuild/rules\_swift/blob/main/doc/rules.md#swift\_library), \[swift\_test]\(https\://github.com/bazelbuild/rules\_swift/blob/main/doc/rules.md#swift\_test)\<br>\<br>Requires \`rules\_swift\` >= 2.0.0. Requires Bazel Aspects. Supports both WORKSPACE model and Bzlmod.
&#x20; Version\_Requirements: 2.0.0+
&#x20; \- Language: \[Swift (Apple app bundles)]\(https\://github.com/bazelbuild/rules\_apple)
&#x20; Supported\_Rules: iOS: \[ios\_application]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-ios.md#ios\_application), \[ios\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-ios.md#ios\_framework), \[ios\_dynamic\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-ios.md#ios\_dynamic\_framework), \[ios\_static\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-ios.md#ios\_static\_framework), \[ios\_extension]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-ios.md#ios\_extension), \[ios\_app\_clip]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-ios.md#ios\_app\_clip), \[ios\_imessage\_application]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-ios.md#ios\_imessage\_application), \[ios\_imessage\_extension]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-ios.md#ios\_imessage\_extension), \[ios\_sticker\_pack\_extension]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-ios.md#ios\_sticker\_pack\_extension), \`ios\_unit\_test\`, \`ios\_ui\_test\`\<br>\<br>macOS: \[macos\_application]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_application), \[macos\_bundle]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_bundle), \[macos\_extension]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_extension), \[macos\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_framework), \[macos\_dynamic\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_dynamic\_framework), \[macos\_static\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_static\_framework), \[macos\_xpc\_service]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_xpc\_service), \[macos\_command\_line\_application]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_command\_line\_application), \[macos\_dylib]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_dylib), \[macos\_kernel\_extension]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_kernel\_extension), \[macos\_quick\_look\_plugin]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_quick\_look\_plugin), \[macos\_spotlight\_importer]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-macos.md#macos\_spotlight\_importer), \`macos\_unit\_test\`, \`macos\_ui\_test\`\<br>\<br>watchOS: \[watchos\_application]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-watchos.md#watchos\_application), \[watchos\_extension]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-watchos.md#watchos\_extension), \[watchos\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-watchos.md#watchos\_framework), \[watchos\_dynamic\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-watchos.md#watchos\_dynamic\_framework), \[watchos\_static\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-watchos.md#watchos\_static\_framework), \`watchos\_unit\_test\`, \`watchos\_ui\_test\`\<br>\<br>tvOS: \[tvos\_application]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-tvos.md#tvos\_application), \[tvos\_extension]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-tvos.md#tvos\_extension), \[tvos\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-tvos.md#tvos\_framework), \[tvos\_dynamic\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-tvos.md#tvos\_dynamic\_framework), \[tvos\_static\_framework]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-tvos.md#tvos\_static\_framework), \`tvos\_unit\_test\`, \`tvos\_ui\_test\`\<br>\<br>visionOS: \[visionos\_application]\(https\://github.com/bazelbuild/rules\_apple/blob/master/doc/rules-visionos.md#visionos\_application)\<br>\<br>Resolves dependencies for iOS, macOS, watchOS, tvOS, and visionOS application bundles built with \`rules\_apple\`, including their Swift, Objective-C, and prebuilt framework/XCFramework dependencies. watchOS apps are resolved both as standalone scan targets and when embedded in an iOS app through \`watch\_application\`. Requires Bazel Aspects. Supports both WORKSPACE model and Bzlmod.\<br>\<br>-note- Scans must run on a macOS host because the Apple toolchain requires macOS. Does not include reachability analysis.
&#x20; Version\_Requirements: 4.0.0+
&#x20; \- Language: \[JavaScript]\(https\://github.com/aspect-build/rules\_js)
&#x20; Supported\_Rules: \[js\_binary]\(https\://docs.aspect.build/rulesets/aspect\_rules\_js/docs/js\_binary), \[js\_library]\(https\://docs.aspect.build/rulesets/aspect\_rules\_js/docs/js\_library)\<br>\<br>Requires \`rules\_js\` >= 2.0.0. Requires Bazel Aspects. Supports Bzlmod.
&#x20; Version\_Requirements: 2.0.0+
&#x20; \- Language: \[TypeScript]\(https\://github.com/aspect-build/rules\_ts)
&#x20; Supported\_Rules: \[ts\_project]\(https\://docs.aspect.build/rulesets/aspect\_rules\_ts/docs/rules#ts\_project), ts\_project\_rule\<br>\<br>Requires \`rules\_ts\` >= 1.0.0. Requires Bazel Aspects. Supports both WORKSPACE model and Bzlmod.
&#x20; Version\_Requirements: 1.0.0+

&#x20;&#x20;

## Bazel aspects support

Endor Labs supports Bazel aspects for enhanced dependency resolution. Use the `--use-bazel-aspects` flag to enable aspects. See [Bazel Aspects](https://docs.endorlabs.com/scan/bazel/bazel-aspects.md) for more information.

The following table lists the languages and rulesets that support Bazel aspects.




&#x20; \- Language: Go
&#x20; Ruleset: \[rules\_go]\(https\://github.com/bazelbuild/rules\_go)
&#x20; Minimum\_Version: 0.42.0
&#x20; \- Language: Java
&#x20; Ruleset: \[rules\_java]\(https\://github.com/bazelbuild/rules\_java)
&#x20; Minimum\_Version: 5.0.0
&#x20; \- Language: Python
&#x20; Ruleset: \[rules\_python]\(https\://github.com/bazelbuild/rules\_python)
&#x20; Minimum\_Version: 0.9.0
&#x20; \- Language: Scala
&#x20; Ruleset: \[rules\_scala]\(https\://github.com/bazelbuild/rules\_scala)
&#x20; Minimum\_Version: 5.0.0
&#x20; \- Language: Kotlin
&#x20; Ruleset: \[rules\_kotlin]\(https\://github.com/bazel-contrib/rules\_kotlin)
&#x20; Minimum\_Version: 2.0.0
&#x20; \- Language: Rust
&#x20; Ruleset: \[rules\_rust]\(https\://github.com/bazelbuild/rules\_rust)
&#x20; Minimum\_Version: 0.40.0
&#x20; \- Language: JavaScript
&#x20; Ruleset: \[rules\_js]\(https\://github.com/aspect-build/rules\_js)
&#x20; Minimum\_Version: 2.0.0
&#x20; \- Language: TypeScript
&#x20; Ruleset: \[rules\_ts]\(https\://github.com/aspect-build/rules\_ts)
&#x20; Minimum\_Version: 1.0.0
&#x20; \- Language: Swift
&#x20; Ruleset: \[rules\_swift]\(https\://github.com/bazelbuild/rules\_swift)
&#x20; Minimum\_Version: 2.0.0
&#x20; \- Language: Swift (Apple app bundles)
&#x20; Ruleset: \[rules\_apple]\(https\://github.com/bazelbuild/rules\_apple)
&#x20; Minimum\_Version: 4.0.0

&#x20;&#x20;

## Bzlmod support

Endor Labs supports [Bzlmod](https://bazel.build/external/migration), Bazel's external dependency system. Bzlmod requires Bazel aspects. Use the `--use-bazel-aspects` flag when scanning Bzlmod-based projects.

The following table lists the languages and rulesets that support Bzlmod.




&#x20; \- Language: Go
&#x20; Ruleset: \[rules\_go]\(https\://github.com/bazelbuild/rules\_go)
&#x20; Minimum\_Version: 0.42.0
&#x20; \- Language: Java
&#x20; Ruleset: \[rules\_java]\(https\://github.com/bazelbuild/rules\_java)
&#x20; Minimum\_Version: 5.0.0
&#x20; \- Language: Python
&#x20; Ruleset: \[rules\_python]\(https\://github.com/bazelbuild/rules\_python)
&#x20; Minimum\_Version: 0.30.0
&#x20; \- Language: Scala
&#x20; Ruleset: \[rules\_scala]\(https\://github.com/bazelbuild/rules\_scala)
&#x20; Minimum\_Version: 5.0.0
&#x20; \- Language: Kotlin
&#x20; Ruleset: \[rules\_kotlin]\(https\://github.com/bazel-contrib/rules\_kotlin)
&#x20; Minimum\_Version: 2.0.0
&#x20; \- Language: Rust
&#x20; Ruleset: \[rules\_rust]\(https\://github.com/bazelbuild/rules\_rust)
&#x20; Minimum\_Version: 0.40.0
&#x20; \- Language: Swift
&#x20; Ruleset: \[rules\_swift]\(https\://github.com/bazelbuild/rules\_swift)
&#x20; Minimum\_Version: 2.0.0
&#x20; \- Language: Swift (Apple app bundles)
&#x20; Ruleset: \[rules\_apple]\(https\://github.com/bazelbuild/rules\_apple)
&#x20; Minimum\_Version: 4.0.0
&#x20; \- Language: JavaScript
&#x20; Ruleset: \[rules\_js]\(https\://github.com/aspect-build/rules\_js)
&#x20; Minimum\_Version: 2.0.0
&#x20; \- Language: TypeScript
&#x20; Ruleset: \[rules\_ts]\(https\://github.com/aspect-build/rules\_ts)
&#x20; Minimum\_Version: 1.0.0

&#x20;&#x20;

> [!NOTE]
>
> **Python and rules\_python**
>
> For Python, the minimum version in this table applies to Bzlmod. With `rules_python` 0.9.0 up to (but not including) 0.30.0, Endor Labs supports only the WORKSPACE model (no Bzlmod).

## Quick target discovery for Bazel projects

Use the following commands to find scannable targets in your repository.

> [tab] Java
>
> ```bash theme={null}
> bazel query 'kind(java_binary, //...)'
> ```

> [tab] Python
>
> ```bash theme={null}
> bazel query 'kind(py_binary, //...)'
> ```

> [tab] Go
>
> ```bash theme={null}
> bazel query 'kind(go_binary, //...)'
> ```

> [tab] Scala
>
> ```bash theme={null}
> bazel query 'kind(scala_binary, //...)'
> ```

> [tab] Kotlin
>
> ```bash theme={null}
> bazel query 'kind("kt_jvm_(library|binary)", //...)'
> ```

> [tab] Rust
>
> ```bash theme={null}
> bazel query 'kind(rust_binary, //...)'
> ```

> [tab] Swift
>
> ```bash theme={null}
> bazel query 'kind(swift_binary, //...)'
> ```

> [tab] Apple app bundles
>
> ```bash theme={null}
> bazel query 'kind(ios_application, //...)'
> ```

> [tab] JavaScript
>
> ```bash theme={null}
> bazel query 'kind(js_binary, //...)'
> ```

> [tab] TypeScript
>
> ```bash theme={null}
> bazel query 'kind(ts_project, //...)'
> ```

> [tab] All binary targets
>
> ```bash theme={null}
> bazel query 'kind(".*_binary", //...)'
> ```

### 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.

```bash theme={null}
bazel query '//your-package:*'
```

Run the following command to find all binary targets across languages.

```bash theme={null}
bazel query 'kind(".*_binary", //...)'
```

Run the following command to find targets with specific attributes.

```bash theme={null}
bazel query 'attr(visibility, "//visibility:public", //...)'
```

Run the following command to find dependencies of a target.

```bash theme={null}
bazel query 'deps(//your-target:name)'
```

Run the following command to find reverse dependencies of a target.

```bash theme={null}
bazel query 'rdeps(//..., //your-target:name)'
```

## Scan commands for Bazel projects

The following table lists the common flags and options to scan Bazel projects.




&#x20; \- Flag: \`--bazel-include-targets\`
&#x20; Purpose: Specify exact target labels to scan
&#x20; Example: \`--bazel-include-targets=//app:main\`
&#x20; \- Flag: \`--bazel-exclude-targets\`
&#x20; Purpose: Exclude exact target labels
&#x20; Example: \`--bazel-exclude-targets=//test:unit\`
&#x20; \- Flag: \`--bazel-targets-query\`
&#x20; Purpose: Use Bazel query to select targets
&#x20; Example: \`--bazel-targets-query='kind(java\_binary, //...)'\`
&#x20; \- Flag: \`--bazel-workspace-path\`
&#x20; Purpose: Non-root workspace location
&#x20; Example: \`--bazel-workspace-path=./src/java\`
&#x20; \- Flag: \`--bazel-vendor-manifest-path\`
&#x20; Purpose: Go vendored mode \`go.mod\` path
&#x20; Example: \`--bazel-vendor-manifest-path=./go.mod\`
&#x20; \- Flag: \`--disable-private-package-analysis\`
&#x20; Purpose: Skip private package analysis
&#x20; Example: \`--disable-private-package-analysis\`
&#x20; \- Flag: \`--quick-scan\`
&#x20; Purpose: Fast scan mode
&#x20; Example: \`--quick-scan\`
&#x20; \- Flag: \`--bazel-rc-path\`
&#x20; Purpose: Specify custom paths for Bazel configuration files
&#x20; Example: \`--bazel-rc-path=.custom.bazelrc.user\`
&#x20; \- Flag: \`--bazel-flags\`
&#x20; Purpose: Specify additional command-line flags that should be passed to Bazel when running a scan
&#x20; Example: \`--bazel-flags="config=ci, config=dev, remote\_retries=5"\`
&#x20; \- Flag: \`--use-bazel-aspects\`
&#x20; Purpose: Enable Bazel aspect framework for dependency resolution
&#x20; Example: \`--use-bazel-aspects\`
&#x20; \- Flag: \`--bazel-aspect-package\`
&#x20; Purpose: Override base aspect package (defaults to @//.endorctl/aspects)
&#x20; Example: \`--bazel-aspect-package=@//endor\_aspects\`
&#x20; \- Flag: \`-o json\`
&#x20; Purpose: Output format
&#x20; Example: \`-o json \\| tee results.json\`

&#x20;&#x20;

### 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 target labels using `--bazel-include-targets`. You can exclude exact labels with `--bazel-exclude-targets`. These flags do not accept Bazel target patterns such as `//...`, `:all`, or `:*`.
* **Query-based selection**: Use the Bazel query language to select targets matching your criteria with `--bazel-targets-query`. Use this flag when you need pattern-based selection.

### Quick scan for Bazel projects

Run a fast scan for software composition visibility without reachability analysis.

```bash theme={null}
endorctl scan --use-bazel --bazel-include-targets=//your-target-name --quick-scan
```

### Deep scan for Bazel projects

Perform a full analysis with dependency resolution, reachability analysis, and call graphs.

```bash theme={null}
endorctl scan --use-bazel --bazel-include-targets=//your-target-name
```

> [!NOTE]
>
> **Private Package Analysis**
>
> When you perform a deep scan, Endor Labs analyzes all private software dependencies in full 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.

```bash theme={null}
endorctl scan --use-bazel --bazel-include-targets=//your-target-name
```

To scan multiple targets, provide a comma-separated list.

```bash theme={null}
endorctl scan --use-bazel --bazel-include-targets=//target1,//target2,//target3
```

### Scan using queries for Bazel projects

Use these commands to scan targets based on queries.

> [tab] Java
>
> ```bash theme={null}
> endorctl scan --use-bazel --bazel-targets-query='kind(java_binary, //...)'
> ```

> [tab] Python
>
> ```bash theme={null}
> endorctl scan --use-bazel --bazel-targets-query='kind(py_binary, //...)'
> ```

> [tab] Go
>
> ```bash theme={null}
> endorctl scan --use-bazel --bazel-targets-query='kind(go_binary, //...)'
> ```

> [tab] Scala
>
> ```bash theme={null}
> endorctl scan --use-bazel --bazel-targets-query='kind(scala_binary, //...)'
> ```

> [tab] Kotlin
>
> ```bash theme={null}
> endorctl scan --use-bazel --use-bazel-aspects --bazel-targets-query='kind("kt_jvm_(library|binary)", //...)'
> ```

> [tab] Rust
>
> ```bash theme={null}
> endorctl scan --use-bazel --use-bazel-aspects --bazel-targets-query='kind(rust_binary, //...)'
> ```

> [tab] Swift
>
> ```bash theme={null}
> endorctl scan --use-bazel --use-bazel-aspects --bazel-targets-query='kind(swift_binary, //...)'
> ```

> [tab] Apple app bundles
>
> ```bash theme={null}
> endorctl scan --use-bazel --use-bazel-aspects --bazel-targets-query='kind(ios_application, //...)'
> ```

> [tab] JavaScript
>
> ```bash theme={null}
> endorctl scan --use-bazel --use-bazel-aspects --bazel-targets-query='kind(js_binary, //...)'
> ```

> [tab] TypeScript
>
> ```bash theme={null}
> endorctl scan --use-bazel --use-bazel-aspects --bazel-targets-query='kind(ts_project, //...)'
> ```

> [tab] All binary targets
>
> ```bash theme={null}
> endorctl scan --use-bazel --bazel-targets-query='attr(visibility, "//visibility:public", //...)'
> ```

### Scan Bazel projects with non-root workspace

If your `WORKSPACE` file isn't at the repository root.

```bash theme={null}
endorctl scan --use-bazel \
  --bazel-targets-query='kind(java_binary, //...)' \
  --bazel-workspace-path=./src/java
```

### Scan Bazel projects with Go with Gazelle (Vendored Mode)

For Go projects using Bazel with Gazelle in vendored mode.

```bash theme={null}
endorctl scan --use-bazel \
  --bazel-include-targets=//your-go-target \
  --bazel-vendor-manifest-path=./go.mod
```

### Scan Bazel projects with performance optimization

For large codebases, disable private package analysis.

```bash theme={null}
endorctl scan --use-bazel \
  --bazel-include-targets=//your-target-name \
  --disable-private-package-analysis
```

### Language-specific information for Endor Labs scans

For detailed information about scanning specific languages:

* [Java](https://docs.endorlabs.com/scan/sca/java.md)
* [Python](https://docs.endorlabs.com/scan/sca/python.md)
* [Go](https://docs.endorlabs.com/scan/sca/golang.md)
* [Scala](https://docs.endorlabs.com/scan/sca/scala.md)
* [Kotlin](https://docs.endorlabs.com/scan/sca/kotlin.md)
* [Rust](https://docs.endorlabs.com/scan/sca/rust.md)
* [JavaScript](https://docs.endorlabs.com/scan/sca/javascript.md)
* [Swift/Objective-C](https://docs.endorlabs.com/scan/sca/swift-objective-c.md)

## 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.

```bash theme={null}
endorctl scan --use-bazel --bazel-include-targets=//your-target-name --quick-scan -o json | tee results.json
```

Run the following command to save the results of a deep scan to a local file.

```bash theme={null}
endorctl scan --use-bazel --bazel-include-targets=//your-target-name -o json | tee results.json
```

### View findings in the Endor Labs user interface

To view your scan results in the Endor Labs user interface:

1. Select **Projects** from the left sidebar.
2. Select the project you want to view and select **Findings** to view your scan results.

For more information, see [Viewing findings in the Endor Labs user interface](https://docs.endorlabs.com/inventory-insights/findings.md).

## Troubleshooting Bazel projects scans

Check the following common issues and solutions for Bazel projects scans.

> [accordion] No targets found
>
> Check your query syntax and target types.

> [accordion] Workspace not found
>
> Use `--bazel-workspace-path` flag.

> [accordion] Build failures
>
> Pre-build targets with `bazel build`.

> [accordion] Slow scans
>
> Use `--disable-private-package-analysis`

> [accordion] Go vendored issues
>
> Specify `--bazel-vendor-manifest-path`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.