--pr flag runs the scan for the current commit and records the results as PR Runs that do not affect main branch monitoring scans and reports. Endor Labs stores PR and MR scan findings in PR Runs for three weeks, after which they are removed to accommodate new PR scans.
Before you run PR scans, scan your baseline branch at least once so incremental PR scans have a baseline to compare against.
Scan PRs using endorctl
A PR scan command combines the following flags. The following sections explain how these flags work together. To go straight to the ready-to-run command, see Set up PR scans step by step.Perform incremental PR scan
An incremental PR scan scans only the parts of the codebase and dependencies that have changed since the last full baseline scan.- Endor Labs identifies packages and dependencies in the PR and scans only those that changed relative to the baseline.
- If no dependencies changed, the scan is skipped, and Endor Labs reports
No changes found. - Incremental PR scans report only findings that involve dependencies the pull request changed and that do not exist in the baseline.
- You can enable incremental PR scans using the
--pr-incrementalflag or the equivalent CI settings. This flag is also available for SAST incremental scans and Incremental secret scans.
--pr-baseline when you run the scan. See Set a default branch for how the default branch is chosen and used.
Baseline mismatch in PR scansIf a finding is fixed in the baseline by upgrading or downgrading a dependency and a PR still modifies that package, the finding can be reported as new. To mitigate this, rebase the PR with the latest baseline content and re-run the PR check.
Publish findings as PR comments
Endor Labs can post new findings as review comments on the pull request or merge request. Comments are posted according to your action policies. To publish comments:- Set
--enable-pr-commentsand--scm-pr-idso the scan posts comments to the right PR and infers the baseline from its merge target. - Authenticate with
--scm-tokenor theENDOR_SCAN_SCM_TOKENenvironment variable. - Configure an action policy with Branch Type Pull Request so violations generate comments.
Skip unaffected languages during incremental PR scans
When you combine--pr-incremental with --quick-scan, Endor Labs inspects the changed files in the pull request before resolving dependencies for each language. If the pull request contains no build file changes for a language, Endor Labs skips dependency resolution for that language entirely. This behavior is enabled by default for all supported languages and ecosystems in endorctl v1.7.1002 and later.
The scan log records each skipped language.
Skip unaffected packages during incremental PR scans
When a pull request does change build files, Endor Labs can prune further and resolve dependencies only for the packages those files affect. This reduces incremental PR scan times in large repositories and monorepos. Endor Labs classifies each changed build file by its scope of impact. The following examples come from JVM projects, and every supported language or ecosystem has an equivalent set of build files:- A single package, such as
gradle.lockfile. - A package and every package under it, such as a parent
pom.xml,settings.gradle, orgradle.properties. - The entire repository, such as
gradle-wrapper.properties, files underbuildSrcor.mvn, and version catalogs likegradle/libs.versions.toml.
ENDOR_SCAN_INCREMENTAL_DEP_RES=false before you run the scan.
Troubleshoot incremental PR scan performance
If an incremental PR scan takes longer than expected or does not skip dependency resolution, do the following checks:- Verify that endorctl is v1.7.1002 or later. Package-level skipping requires a later version, depending on your language or ecosystem. See Skip unaffected packages during incremental PR scans.
- Confirm that the scan sets both
--pr-incrementaland--quick-scan. - Confirm that the scan is a pull request scan. Scans tagged
merge-to-mainresolve all dependencies. - Check the scan log for
Detected N changed files. An unexpectedly large count means the pull request diff could not be computed correctly. - Look for skip confirmations in the scan log, such as
Skip dependency resolution for 3/12 maven modules: No relevant changes detected. - Check whether the pull request changes a root or parent build file. These changes affect every module in the repository, so Endor Labs resolves all of them even with package-level skipping turned on.
Maven dependency resolution on large projects
Maven dependency resolution can take a long time on projects with large or complex dependency trees, when a PR changes a root or parent build file. To reduce dependency resolution time in PR scans:-
Confirm that
--pr-incrementaland--quick-scanare both set. Endor Labs skips dependency resolution for languages and packages that a pull request does not affect. See Skip unaffected packages during incremental PR scans. -
For monorepos with 100 or more
pom.xmlfiles, setENDOR_SCAN_MAVEN_PREPOP_CACHE=truein GitHub App or other hosted scans to pre-populate the Maven local cache in parallel before Endor Labs scans each module. This setting has no effect in CI-triggered or localendorctl scanruns. See Environment variables that affect scan behavior.
Set up PR scans step by step
Add the following flags to your scan command in order, and verify each step in your CI pipeline before adding the next.1
Start with a PR scan
Run a PR scan on the current commit. Endor Labs records the results as a PR Run instead of a monitoring scan.
2
Scan only what changed
Add
--pr-incremental and point --pr-baseline at the branch the PR merges into. The scan reports only findings that are new relative to the baseline.3
Speed up the scan
Add
--quick-scan to skip call graph generation and skip dependency resolution for languages and packages the PR does not affect.4
Post findings as PR comments
Add
--enable-pr-comments with --scm-pr-id and an SCM token. Remove --pr-baseline because the scan now infers the baseline from the merge target of the PR. This is the recommended command.5
Block merges on findings
The scan reports findings and posts comments, but it does not block merges on its own. Pair the command with an action policy that breaks the build and a required status check on your target branch. See Block pull requests on findings.
6
Optional: Point to GitHub Enterprise Server
If your organization runs GitHub Enterprise Server, add
--github-api-url with the API URL of your server.Adjust the command for your setup
- Run without PR comments: Stop after step 3. Keep
--pr-baselineand do not set--enable-pr-commentsor--scm-pr-id. - Include reachability analysis: Drop
--quick-scanto resolve dependencies fully and generate call graphs. The scan takes longer, but findings include reachability information.