SAST Scans and Integration into pipeline
By Oculus
•
October 14, 2025
What Are SAST Scans?
SAST stands for Static Application Security Testing. It is a technique that analyzes application source code, bytecode, or compiled binaries without executing them, to find security vulnerabilities such as SQL injection, cross-site scripting (XSS), buffer overflows, insecure API usage, hardcoded secrets, and so on.
Key characteristics:
- It is static — it does not require running the code or deploying the application.
- It inspects code paths, control flow, data flow, taint analysis, and patterns in the codebase.
- It can scan all branches, commits, or merges, and generate reports identifying potential vulnerabilities with line numbers, file names, and often severity / confidence levels.
- It may include analyzers for specific languages or frameworks (Java, Python, C#, JavaScript, etc.).
- It may use heuristics, rule sets, or taint tracking to find paths from untrusted input (sources) to sensitive operations (sinks) that lack sanitization.
Because SAST does not require a running environment, it is typically used early in the development lifecycle, ideally integrated into CI pipelines. However, it has limitations: false positives (flagging safe code as risky), incomplete coverage of runtime behavior, and inability to catch certain types of flaws that only appear under dynamic execution or configuration.
Why SAST Fits Into SecDevOps & How It Helps
In a SecDevOps (DevSecOps) context, SAST is one of the foundational security checks you embed into your DevOps pipeline. Here's how it contributes and why it's important:
- Early vulnerability detection ("shift-left")Because SAST can run before code is merged or deployed, it helps catch coding mistakes and insecure patterns early — when the cost to fix is lowest. It prevents issues from cascading downstream into more complex, intertwined modules or production.
- Automated feedback to developersIntegrating SAST into CI gives developers near-real time feedback. Instead of waiting for security review at the end, they know immediately when they introduce a vulnerability, enabling a "fail fast" model.
- Reduced security debtOver time, fewer vulnerabilities are allowed to accumulate because each commit is checked. This reduces technical debt and avoids the accumulation of "unknown risk" in later phases.
- Code-level insight & remediation guidanceSAST tools often include information about which line of code, which function, and the data flow path is vulnerable. This helps developers root cause and fix issues more efficiently, rather than just "flagging something is unsafe."
- Consistency and repeatabilityBecause the scans are automated and version controlled, you get consistent security checks across branches and releases. You can enforce security gates (e.g. fail the build if a high severity issue appears).
- Baseline and trendingThe history of SAST findings can be tracked over time. You can measure whether the total number of vulnerabilities is decreasing, whether the severity distribution is improving, and whether specific modules or teams have recurring patterns.
- Complementing other techniquesSAST does not replace DAST, IAST, or runtime monitoring, but it is complementary. It focuses on code logic; dynamic tests cover runtime issues; runtime monitoring catches configuration and emergent threats.
Why It's Called "Shift-Left"
The term "shift-left" comes from the idea of pushing security (and testing) earlier into the development process timeline. In traditional waterfall or classic models, security reviews, testing, and audits happen after development (on the "right" side of the timeline). By "shifting left," we move those assessments earlier:
- Rather than waiting until after the build or during QA, you run SAST as soon as developers push or in pull requests.
- This reduces costly rework, since it's cheaper to fix issues when code is fresh, dependencies are known, and context is fresh.
- It also introduces security awareness into the developer's workflow rather than as a downstream gatekeeper.
In effect, shift-left means reducing the distance (time, effort, surprise) between code change and security feedback.
Integrating SAST into GitLab CI/CD
GitLab has built-in support for SAST scanning (for free / paid tiers) and offers analyzers as Docker images. Here's a more technical walk-through of setting it up.
Basic Setup
- Enable SAST in your project / pipelineUse GitLab's provided CI/CD template for SAST by including:This will auto-generate a sast job in your pipeline, configured with analyzers appropriate to your project languages. The analyzers are containerized wrappers around scanners. (
include: - template: Jobs/SAST.gitlab-ci.ymlGitLab Docs) - Ensure you have appropriate runnersThe SAST job runs analyzers in Docker containers. You should have a runner with Docker or Kubernetes executor, and at least ~4 GB of memory for SAST analyzers. (GitLab Docs)
- Artifacts and reportingThe SAST job produces a JSON report (commonly gl-sast-report.json) in the project directory. In your CI .gitlab-ci.yml, you should map that file under artifacts: reports: to allow GitLab to parse and display it in the Merge Request / Security views. (GitLab Docs)
- Failure policy / thresholdsYou can configure whether certain severities cause the job to fail, or whether findings are merely warnings. Merge request policies can be set so that critical/high findings block merges.
- Advanced SAST (cross-file / taint analysis)In GitLab Ultimate, there is GitLab Advanced SAST, which performs cross-function and cross-file taint analysis for more sophisticated vulnerability detection. This must be explicitly enabled via the CI/CD variable GITLAB_ADVANCED_SAST_ENABLED: 'true'. (GitLab Docs)Example snippet:
include: - template: Jobs/SAST.gitlab-ci.yml variables: GITLAB_ADVANCED_SAST_ENABLED: 'true'
Example Pipeline Fragment
<pre>
</pre>
Viewing Results & MRs
Once the pipeline runs, GitLab can show the SAST findings in the Merge Request widget or in the security dashboard, with severity, file path, and remediation guidance. Teams can triage directly in GitLab's UI.
You can also enforce security gates, i.e. block merging unless no new high/critical vulnerabilities exist. Over time, you can suppress or baseline known issues so that only new findings are highlighted.
Integrating Checkmarx SAST into GitHub
Checkmarx (CxSAST) is a commercial static analysis product. It offers integrations with GitHub (via GitHub Actions and with CxFlow) so that each commit or pull request can trigger a scan. Here's how you can set it up:
GitHub Actions Integration
Checkmarx provides a GitHub Action (or wrapper) that invokes a scan and returns the results, often in SARIF format, and posts comments or summary into the Pull Request. (
Example of a GitHub workflow:
name: Checkmarx SAST Scan
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
cx-sast:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Checkmarx SAST
uses: checkmarx-ts/checkmarx-github-action@vX.Y
with:
cxServer: ${{ secrets.CX_SERVER_URL }}
cxToken: ${{ secrets.CX_TOKEN }}
cxProjectName: my-project
cxTeam: "MyTeam"
This action archives source, sends it to Checkmarx server, and triggers a scan. When done, it comments on the pull request and/or updates GitHub security alerts. (
Checkmarx also supports CxFlow, which orchestrates scans, can manage project creation, result parsing, issue linking (e.g. GitHub Issues, Jira), and build breaks. (
Checkmarx One GitHub Actions (Newer Approach)
Checkmarx One is the newer cloud-native platform, and the integration also supports SAST, SCA, IaC, API security, etc. via GitHub Actions. (
- You need to create an OAuth client in Checkmarx One, and store client_id and client_secret in GitHub Secrets. (Checkmarx.com)
- In your GitHub Action workflow, you invoke the Checkmarx One GitHub Action, configuring project name, branch, filters, scan thresholds, etc. (Checkmarx.com)
- Results can be published as pull request comments or integrated into GitHub's Code Scanning Alerts. (Checkmarx.com)
Example:
name: Checkmarx One Scan
on:
pull_request:
push:
branches:
- main
jobs:
scan:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Checkmarx One scan
uses: Checkmarx/ast-github-action@vX.Y
with:
cxClientId: ${{ secrets.CX_CLIENT_ID }}
cxClientSecret: ${{ secrets.CX_CLIENT_SECRET }}
projectName: "${{ github.repo }}"
branch: "${{ github.ref_name }}"
After completion, the scan results — including vulnerabilities found — are visible either in the PR interface or via linked dashboards.
Configuration & Best Practices
- Use secrets (never hardcode tokens or credentials)
- Limit scan scope (e.g. exclude generated files or test scaffolding)
- Control scan frequency (e.g. only scan pull requests or changes)
- Fail builds only on critical severity thresholds to prevent developer frustration
- Use issue linking, annotations, and dashboards for managing findings
- Retain historical data to track trends
Challenges, Tradeoffs & Mitigations
- False Positives / NoiseSAST tools often report potential vulnerabilities that are benign in your specific context. Mitigate by using baselines, suppressions, feedback loops, and tuning rules.
- Resource & Performance OverheadFull SAST scans can be time-consuming and memory-intensive. Use incremental scanning (only new or changed files) or limit full scans to scheduled times.
- Language / Framework LimitationsNot all languages or constructs may be fully supported. Some advanced patterns (reflection, dynamic code) may evade detection.
- Developer FrustrationIf results are too noisy, developers may disable or ignore findings. It's crucial to calibrate severity thresholds, provide good guidance, and iterate.
- Licensing & CostCommercial tools like Checkmarx require licensing, deployment, and maintenance. You'll need to manage server infrastructure, agent updates, and integration overhead.
- Scalability in Large ReposVery large repositories with many modules might overwhelm SAST analyzers. Consider modularizing, scanning modules separately, or using caching.
Conclusion
SAST (Static Application Security Testing) is a foundational technique in the SecDevOps toolbox. It empowers teams to detect code-level vulnerabilities early, automatically, and in a repeatable fashion. Because it can run before code is merged or deployed, it aligns perfectly with the "shift-left" philosophy.
By integrating SAST into GitLab pipelines via the built-in analyzers or Advanced SAST, developers receive immediate security feedback in merge requests. Meanwhile, integrating Checkmarx SAST into GitHub via GitHub Actions (or CxFlow) allows organizations to apply enterprise-grade scanning within developer workflows.
When combined with DAST, IAST, SCA, and runtime monitoring, SAST forms part of a defense-in-depth strategy that helps maintain both speed and security.
