GitHub PR gating using Local Scanner
The Aikido Local Scanner can be used to enforce security gates in your CI pipeline.
PR gating ensures that new code meets your security standards before it is merged into the default branch. It scans only the changes introduced in the pull request. If the scan detects new issues that meet or exceed your configured severity threshold, the CI pipeline fails.
This prevents new vulnerabilities from being introduced while allowing existing findings to be addressed separately.
To enable PR gating, add the --fail-on <severity> option to select your preferred severity level. Then, add the --gating-mode pr option to signify that you wish to perform PR gating. You must also specify the base (--base-commit-id <commit-id>) and head commit (--head-commit-id <commit-id>). If there a scan was previously performed on the base commit id, the scan results will be compared to those. If not, the results will be compared to the most recent scan on your default branch.
For general information about setting up the Local Scanner in a GitHub environment, check out this article.
Example .github/workflows/aikido-scan.yml for PR gating:
on:
pull_request:
branches:
- main
name: Aikido Scan
jobs:
aikido-local-scan-repo:
runs-on: ubuntu-latest
container:
image: aikidosecurity/local-scanner:latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: ${{ github.event.repository.name }}
fetch-depth: 0 # Makes sure base and head commit are accessible in workflow
- name: Run scan
run: aikido-local-scanner scan ${{ github.event.repository.name }} --apikey ${{ secrets.AIKIDO_API_KEY }} --repositoryname ${{ github.event.repository.name }} --branchname ${{ github.event.pull_request.head.ref }} --gating-mode pr --fail-on critical --base-commit-id ${{ github.event.pull_request.base.sha }} --head-commit-id ${{ github.event.pull_request.head.sha }}Last updated
Was this helpful?