- Scan only the code changed by the pull request, with results in a few minutes.
- Surface only net new, auto-triaged findings, and filter out false positives.
- Review findings inline on the pull request through PR comments and in PR Runs.
- Block risky merges or fail CI through action policies on the resulting findings.
- From the CLI using endorctl to run a PR scan against a baseline branch from your terminal.
- From a CI pipeline to invoke
endorctl scanas part of a pull request job. - Through SCM apps to trigger PR scans automatically when a pull request is opened or updated.
How AI SAST PR scans work
An AI SAST PR scan runs in three stages.Build the baseline
AI SAST processes the full repository on the target branch and stores all detection-agent findings as the baseline. See Establish a baseline scan.
Scan the PR diff
A pull request triggers a PR scan that analyzes only the code changed by the pull request, using the full-repository context that the baseline established.
Establish a baseline scan
The baseline is the reference point every AI SAST PR scan compares against. It defines the known security state of the target branch. Therefore, the PR scan can isolate net new findings from issues that already exist. The baseline gives the AI SAST agents the full-repository context they need to reason about the changed code. Without a baseline, every AI SAST finding on the pull request would surface as new, including pre-existing issues, and the PR result would not be reviewable. We recommend that you run the first baseline scan from the command line so the baseline is in place before the first PR scan is requested. Replace/path/to/code with the path to your repository and <namespace> with your Endor Labs namespace.
Run AI SAST PR scans from the CLI
You can run AI SAST PR scans using endorctl for GitHub and GitLab. The--ai-sast --pr --pr-baseline=<target-branch> combination runs the AI SAST detection agent on the changed code, deduplicates findings against the baseline, and records the results as a PR Run that does 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.
Run the following command after you commit to a pull request or merge request. Ensure that you install and configure endorctl before running scans from the command line.
<target-branch> with the pull request’s target branch, such as main. For the full list of pull request flags, see Pull request (CI) flags to learn more.
Run AI SAST PR scans from CI
AI SAST PR scans can be run from a continuous integration pipeline by invokingendorctl scan with the --ai-sast, --pr, and --pr-baseline flags in jobs triggered by pull request or merge request events. This approach provides control over when scans run, supports posting findings as PR or MR comments, and allows policies to be enforced, such as failing builds or blocking merges. The scan profile assigned to the project determines the toolchains and environment used for the scan.
For platform-specific YAML and command syntax, see:
A baseline AI SAST scan must exist on the target branch before any PR scan can produce findings. See Establish a baseline scan.
Run AI SAST PR scans through SCM apps
The Endor Labs GitHub and GitLab apps can run AI SAST PR scans automatically on every pull request, without CI pipeline configuration. PR comments post the net new findings introduced by a pull request as a PR comment in GitHub and as an MR comment in GitLab, so developers see results in the SCM UI without leaving their review flow. Configure Action policies to post PR comments. See Pull request comments to learn more. To configure AI SAST PR scans:- Install the Endor Labs GitHub app, Endor Labs GitLab app, Bitbucket Cloud app, or Bitbucket Data Center app.
- Enable PR scans and PR comments during installation: GitHub App Pro, GitLab App, Bitbucket Cloud app, or Bitbucket Data Center app.
- Create a scan profile and add
ENDOR_SCAN_AI_SAST=trueto the Environment Variables. - Associate the scan profile with the project.
- Open or update a pull request on the configured repository to trigger an AI SAST PR scan.