How to Move SAST From a Legacy Scanner Into Your CI/CD Pipeline
Static analysis that runs on a schedule and reports to a separate portal doesn't fit a pull request workflow. This is how to move it into the pipeline: what changes, which tools fit, and the order to cut over in.
Published November 28, 2026 · HostingX Solutions LLC
Short answer
Scan every pull request, but report only the findings that change introduces. Keep full scans for the default branch, on push and on a schedule.
Show results where developers already work: as annotations on the changed lines, not in a separate scanner portal.
Block merges only on new findings above a severity you choose. Treat existing findings as a backlog with an owner, not as a gate.
Use SARIF 2.1.0, the OASIS standard output format for static analysis, as the layer between scanners and dashboards. GitHub code scanning accepts SARIF from any tool.
Cut over in stages: inventory the legacy rules and suppressions, run old and new scanners in parallel, map severities, re-baseline, turn on the gate, then decommission.
Why Does Legacy SAST Break Down in a CI/CD Pipeline?
Many static analysis programs were built around a release cycle. A central security team runs a full scan of each application every week or before a release, reviews the results in the scanner's own console, and files tickets for the issues it confirms. That works when releases are rare. It stops working when every team merges many pull requests a day:
Full scans don't fit in a pull request. A tool that scans the whole codebase every time adds that whole scan to every pull request, so teams either skip it or move it back to a nightly job.
Findings arrive after the merge. By the time a scheduled scan reports an issue, the author has moved on, and the fix becomes a new ticket instead of a change to the open pull request.
Triage becomes a queue. One team reviews every result for every repository. Developers wait on that queue, and the queue grows with each scan.
Nobody can tell new from old. A report of every finding in the codebase doesn't say which ones the last change introduced, so it can't be used to block that change.
Moving SAST into the pipeline changes who sees results and when. It is usually part of a wider move off a legacy CI system; our CI/CD migration playbook covers the pipelines themselves.
What Does SAST in the Pipeline Look Like?
| Legacy scheduled SAST | SAST in the pipeline | |
|---|---|---|
| When scans run | On a schedule or before a release, often run by a separate security team | On every pull request, plus full scans of the default branch on push and on a schedule |
| What a scan covers | The whole codebase, every time | Pull requests report only findings the change introduces; the default branch keeps the full picture |
| Where developers see results | A separate scanner portal, a PDF report or a ticket | Annotations on the changed lines of the pull request |
| What blocks a merge | Nothing, or a manual sign-off before release | A gate on new findings above a severity you choose |
| Who triages | A central team, after the code has merged | The author during review, with the security team setting rules and reviewing dismissals |
The key change is the split between the pull request and the default branch. The pull request scan answers one question: did this change add a problem? The default branch scan keeps the full inventory that security and compliance teams report on. Every tool below supports that split, though each names it differently.
Why Does SARIF Matter for the Migration?
The Static Analysis Results Interchange Format is an OASIS Standard that “defines a standard format for the output of static analysis tools.” The current text is SARIF 2.1.0 with Errata 01, approved in August 2023. If both your old and new tools can write SARIF, you can compare their results, send both to one dashboard during the parallel run, and swap tools later without rebuilding reports.
GitHub code scanning is the most common destination. What its documentation says about SARIF uploads:
Only SARIF version 2.1.0 is supported, and code scanning reads a subset of its properties.
Each gzip-compressed SARIF file can be up to 10 MB, with up to 20 runs per file and up to 25,000 results and 25,000 rules per run. Only the top 5,000 results are included, prioritized by severity.
GitHub matches results across runs with fingerprints, using the SARIF
partialFingerprintsproperty. If a file has none, theupload-sarifaction tries to compute them from the source files.Keep the
ruleIdand file paths stable between analyses. Changing either can close old alerts and open new ones for the same problem.If you upload more than one SARIF file for the same commit, give each a different
category; a second upload with the same tool and category replaces the first.On private and internal repositories, uploading third-party results needs GitHub Code Security enabled.
Which Tools Fit SAST in CI/CD?
Most migrations land on the scanner built into the source control platform, a standalone scanner that runs in any CI system, or both. Here are four common options, with details from each vendor's documentation and pricing pages as of November 2026:
| Tool | How it runs | How pull requests see results | Tiers and license |
|---|---|---|---|
| GitHub code scanning (CodeQL) | Default setup, configured in repository settings, or advanced setup, a CodeQL workflow file you commit. Third-party tools upload SARIF. | New alerts on changed lines appear as annotations in a “Code scanning results” check. By default the check fails on error, critical or high results. | Public repositories are eligible. Private repositories need GitHub Code Security, $30 per active committer per month on a Team or Enterprise plan. |
| GitLab SAST | CI/CD template or component in .gitlab-ci.yml. Standard analyzers use Semgrep with GitLab-managed rules. | New findings in the merge request report and changes view are Ultimate features. Runs in branch pipelines by default; merge request pipelines need extra configuration. | Basic scanning with open-source analyzers and a downloadable JSON report in Free, Premium and Ultimate. GitLab Advanced SAST, vulnerability management and ruleset customization are Ultimate. |
| Semgrep | The semgrep/semgrep container in any CI system. semgrep ci with the AppSec Platform, or semgrep scan with Community Edition. | Diff-aware scans report only findings introduced after a baseline commit. --sarif writes SARIF for GitHub or other dashboards. | Community Edition is LGPL-2.1 and analyzes within a single function or file. Cross-file and cross-function analysis and proprietary rules need the AppSec Platform. |
| SonarQube | A scanner step in CI that reports to SonarQube Server or SonarQube Cloud. | Pull request analysis reports only issues the pull request introduced, and the quality gate uses only new-code conditions. | Community Build is free and open source. SonarSource lists branch and pull request analysis and quality gate status in pull request comments under Developer Edition. SonarQube Cloud has a free tier for private projects up to 50k lines of code. |
GitHub code scanning with CodeQL
GitHub offers two ways to run CodeQL. Default setup is configured from the repository's security settings; it needs GitHub Actions enabled and can cover all CodeQL-supported languages. Advanced setup is a CodeQL workflow file you commit and change yourself, for custom query suites, build steps or triggers. Turning on default setup disables an existing CodeQL workflow, so pick one per repository.
On pull requests, any new alert on a changed line shows as an annotation in the “Code scanning results” check and in the pull request review. The check fails for results of severity error, critical or high; lower severities are reported as warnings or notes. You can change those thresholds in repository settings, and a branch ruleset with Require code scanning results blocks merges per tool, with security alert thresholds of None, Critical, High or higher, Medium or higher, or All.
Pricing: GitHub lists CodeQL for public repositories on its Free plan. For private repositories, code scanning is part of GitHub Code Security, priced at $30 per active committer per month and available on Team and Enterprise plans. GitHub counts a committer as active when one of their commits was pushed to the repository in the last 90 days. Code Security also covers SARIF uploads from third-party tools, Copilot Autofix for CodeQL alerts and dependency review.
GitLab SAST
GitLab SAST is enabled by including a CI/CD template (or the equivalent CI/CD component) in .gitlab-ci.yml:
include:
- template: Jobs/SAST.gitlab-ci.ymlBasic scanning with open-source analyzers and a downloadable SAST JSON report are in every tier: Free, Premium and Ultimate. Most standard analyzers use Semgrep with GitLab-managed rules. Ultimate adds GitLab Advanced SAST (cross-file, cross-function scanning), new findings in the merge request report and changes view, vulnerability management and ruleset customization. GitLab Advanced SAST has a diff-scanning mode, turned on with ADVANCED_SAST_PARTIAL_SCAN: differential.
Two details matter for a migration. By default, SAST runs only in branch pipelines, so you need extra configuration to run it in merge request pipelines. And the merge gate, a merge request approval policy, is also an Ultimate feature: it can require approval when a scan finds vulnerabilities of chosen severities, and its vulnerability_states setting can limit the rule to findings that are new on the merge request branch.
Semgrep
Semgrep runs from the semgrep/semgrep container image in any CI system. The open-source engine, Semgrep Community Edition, is licensed LGPL-2.1 and, in its project's own words, “can only analyze code within the boundaries of a single function or file.” Cross-file and cross-function analysis, Semgrep's proprietary rules and its triage features need the Semgrep AppSec Platform; Semgrep's sample CI configurations connect to it by running semgrep ci with a SEMGREP_APP_TOKEN.
A diff-aware scan reports only findings introduced after a baseline commit. With semgrep ci, Semgrep's docs use the pull_request trigger in GitHub Actions and merge request pipelines in GitLab; for other CI providers you set SEMGREP_BASELINE_COMMIT, ideally to the merge base of the branch and its target. With Community Edition, semgrep scan takes --baseline-commit directly:
# Pull request or merge request: only findings introduced since the merge base.
# Needs enough Git history for merge-base (with actions/checkout, set fetch-depth: 0).
BASE=$(git merge-base origin/main HEAD)
semgrep scan --config auto --baseline-commit "$BASE" --error
# Default branch and nightly: full scan, written as SARIF for the dashboard
semgrep scan --config auto --sarif --output semgrep.sarif--error makes Semgrep exit with status 1 when it reports findings, which is what fails the job. Combined with the baseline, the job fails only on new findings.
SonarQube
SonarQube's pull request analysis “only include[s] issues that have been introduced by the pull request itself,” with new code defined as the code changed in the pull request branch compared to the target branch, and only the quality gate's new-code conditions apply. That is the gate-on-new-findings model built in. Check the edition first: SonarSource's pricing page lists analysis of feature branches and pull requests, and quality gate status in pull request comments, under Developer Edition, while Community Build is the free, open-source edition. SonarQube Server editions are priced per instance per year by lines of code, and SonarQube Cloud has a free tier for private projects up to 50,000 lines of code.
Example: CodeQL Advanced Setup in GitHub Actions
This is GitHub's CodeQL starter workflow with the placeholders filled in for a JavaScript/TypeScript and Python repository. It scans pull requests and pushes to main, runs a weekly full scan, and uses the security-extended query suite, which adds lower-severity and lower-precision queries to the default suite.
name: "CodeQL Advanced"
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '20 14 * * 1'
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
permissions:
security-events: write
packages: read
actions: read
contents: read
strategy:
fail-fast: false
matrix:
include:
- language: javascript-typescript
build-mode: none
- language: python
build-mode: none
steps:
- name: Checkout repository
uses: actions/checkout@v7
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
queries: security-extended
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"To send another scanner's results to the same place, add an upload step after the tool writes its SARIF file. The job needs security-events: write, and the category keeps those results separate from CodeQL's:
- name: Upload Semgrep results
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: semgrep.sarif
category: semgrepA Seven-Step Migration Plan
Inventory the legacy setup. List the repositories it scans, the languages, the rule sets or policies turned on, any custom rules, and every suppression or false-positive marking. Note which audit or compliance reports read from the legacy tool, because they will need a new source.
Choose the target per repository. Usually the scanner built into your source control platform, plus a standalone scanner where you need rules or languages it doesn't cover. Check language support for each repository before you commit.
Run old and new in parallel. Add the new scanner to pull requests and the default branch in report-only mode, with no merge gate. Keep the legacy scans running for a few release cycles and compare findings on the same commits, so you know what the new tool catches and what it misses.
Map severities. Decide how legacy severities translate to the new tool's levels (for SARIF tools,
error,warningandnote, plus security severities such ascriticalandhigh), and which level blocks a merge.Re-baseline existing findings. Treat the first full scan of each default branch as the baseline. Triage it as a backlog with owners and due dates, and carry legacy suppressions over as dismissals with a recorded reason. In GitHub, a dismissal applies to all branches, and the same code won't raise a new alert on later runs.
Turn on the gate for new findings only. In GitHub, use the code scanning check thresholds or a ruleset with Require code scanning results. In GitLab Ultimate, use a merge request approval policy limited to newly detected findings. In SonarQube, use the quality gate's new-code conditions. With Semgrep in other CI systems, fail the job on a diff-aware scan.
Decommission. Stop the scheduled legacy scans, export and archive their last reports for audit history, point compliance evidence at the new dashboards, and end the license.
What Usually Goes Wrong?
Gating on the whole backlog. If the first gate counts existing findings, every pull request fails and teams turn the gate off. Gate on new findings, and burn down the backlog separately.
Duplicate alerts after changes. Renaming rules, moving the checkout path or changing the SARIF category between runs makes old and new results look like different problems.
Assuming the scan scope follows the trigger. In GitHub,
pathsandpaths-ignoreonpull_requestdecide whether the workflow runs, not which files CodeQL analyzes once it does.Expecting the same depth everywhere. A single-file engine such as Semgrep Community Edition won't report issues that need cross-file data flow. The parallel run shows whether your legacy tool found issues the new setup misses.
Missing merge request pipelines. GitLab SAST runs in branch pipelines by default. If your merge requests use merge request pipelines, configure SAST to run there too.
Large SARIF files. GitHub keeps only the top 5,000 results per run, so a noisy first scan can hide part of the baseline. Tune the rule set before you upload a full backlog.
Where Does SAST Fit With the Rest of Pipeline Security?
SAST covers your own source code. A full pipeline also scans infrastructure code, dependencies and container images, and signs what it ships. Our guide to Terraform scanning with Checkov and Trivy covers infrastructure code, SBOMs and image signing with Cosign covers artifacts, and security-by-default DevOps covers how the gates fit together. For the pipeline structure these scans run in, see our CI/CD pipeline automation guide.
Frequently Asked Questions
What is the difference between legacy SAST and SAST in CI/CD?
Legacy SAST usually scans the whole codebase on a schedule and reports to a security team after code has merged. SAST in CI/CD scans each pull request, reports only the findings that change introduces as annotations on the changed lines, and can block the merge. Full scans still run on the default branch.
Can I send results from another SAST tool to GitHub?
Yes. GitHub code scanning accepts SARIF 2.1.0 files from any tool through the upload-sarif action or the REST API. On private and internal repositories this needs GitHub Code Security.
Is GitHub code scanning free?
For public repositories, yes. For private repositories it is part of GitHub Code Security, which costs $30 per active committer per month and can be bought on GitHub Team and Enterprise plans.
Does GitLab SAST work on the Free tier?
Yes. Basic scanning with open-source analyzers and the downloadable JSON report are in Free, Premium and Ultimate. New findings in the merge request view, GitLab Advanced SAST, vulnerability management and merge request approval policies need Ultimate.
How do I block only new vulnerabilities, not existing ones?
Use the tool's new-findings mode: GitHub's code scanning check and rulesets, which act on alerts on changed lines; a GitLab merge request approval policy limited to newly detected findings; SonarQube's new-code quality gate conditions; or a Semgrep diff-aware scan against the merge base.
Should the old and new scanners run at the same time?
Yes, for a few release cycles, with the new scanner in report-only mode. Comparing both on the same commits shows what the new setup misses before you rely on it and switch off the old one.
Moving security scanning into your pipelines?
We set up code scanning, merge gates and SARIF reporting in GitHub Actions and GitLab CI, and plan the cutover from legacy scanners, for US businesses. The first 30-minute consultation is free.
Sources
Related Articles
CI/CD Migration Playbook
Moving pipelines off Jenkins, CircleCI or custom scripts.
Security-by-Default DevOps
SAST, DAST, policy as code and security gates in CI/CD.
Terraform DevSecOps with Checkov and Trivy
Scanning infrastructure code before it is applied.
SBOMs and Image Signing with Cosign
Signing and verifying what the pipeline ships.
See also: Security services · CI/CD pipeline automation guide · Kubernetes CIS hardening
Services
Subscribe to our newsletter
Get monthly email updates about improvements.
© 2026 HostingX Solutions LLC. All Rights Reserved.
LLC No. 0008072296 | Est. 2026 | New Mexico, USA
Terms of Service
Privacy Policy
Acceptable Use Policy