gitlab sast example project

GitLab SAST Example Project

By Daniel Martinez
AD

GitLab Static Application Security Testing (SAST) is an essential tool for identifying security vulnerabilities in your application's source code. It's crucial to understand how to set up and use GitLab SAST effectively. Let's explore an example project to illustrate the process.

In this article, we'll guide you through setting up GitLab SAST,running it on a sample project, and interpreting the results. By the end, you'll be able to confidently integrate SAST into your CI/CD pipeline.

Setting Up GitLab SAST

Before diving into the example, let's quickly set up GitLab SAST. You'll need a GitLab instance with at least Premium Tier. Access your GitLab instance, navigate to " Admin Area" > "Security & Compliance", and enable SAST.

AD
GIT VS GITLAB
GIT VS GITLAB
the ultimate guide to creating an info board
the ultimate guide to creating an info board
a white paper with writing on it and an image of git's versus glittab
a white paper with writing on it and an image of git's versus glittab

Next, ensure your projects have the necessary permissions and the pipeline is configured to run SAST.

Project Configuration

In your project, create a ".gitlab-ci.yml" file with the following content to enable SAST:

the logo for gitlab is shown in red, orange and yellow colors on a beige background
the logo for gitlab is shown in red, orange and yellow colors on a beige background
the git diagram shows how to use it
the git diagram shows how to use it
DevOps leads and IT admins: if you run GitLab, here is your urgent fix checklist. -> 1. Verify if your instance is running version 15.2 through 19.0.1. -> 2. Immediately upgrade to 19.0.2 or higher to patch the critical Jupyter Notebook RCE vulnerability chain. -> 3. Audit all user permissions and external integrations immediately. Save this quick checklist and share with your team today.
DevOps leads and IT admins: if you run GitLab, here is your urgent fix checklist. -> 1. Verify if your instance is running version 15.2 through 19.0.1. -> 2. Immediately upgrade to 19.0.2 or higher to patch the critical Jupyter Notebook RCE vulnerability chain. -> 3. Audit all user permissions and external integrations immediately. Save this quick checklist and share with your team today.

stages: - test variables: SAST_REPORT exclusion_list: "/vendor/*,/node_modules/*,/dist/*,/test/*.js" sast: stage: test script: - echo "Running SAST on the current merge request" artifacts: reports: sast: gl-sast-report.json

Running SAST

Now, let's trigger a pipeline to run SAST. You can do this by creating a merge request or changing a file in your project.

AD

Once the pipeline starts, GitLab will process your source code, identify potential vulnerabilities, and generate a report.

GitHub rival GitLab ditches plans to delete inactive repositories
GitHub rival GitLab ditches plans to delete inactive repositories
Git for Beginners: Version Control Every Developer Needs
Git for Beginners: Version Control Every Developer Needs
Level Up Your Portfolio with These Beginner-Friendly GitHub Projects
Level Up Your Portfolio with These Beginner-Friendly GitHub Projects
Complete QA Automation Roadmap: From Job Search to Selenium & API Testing
Complete QA Automation Roadmap: From Job Search to Selenium & API Testing
7 GitHub Projects Every CSE Student Should Have
7 GitHub Projects Every CSE Student Should Have
How to Install Gitlab on an Ubuntu Server
How to Install Gitlab on an Ubuntu Server

Analyzing SAST Results

Now let's explore the results using a sample project. We'll use a simple Node.js project with known vulnerabilities.

After the pipeline completes, you'll find the SAST report under "CI/CD" > "Pipelines" > "{specific_pipeline}" > "Pipeline result" > "Artifacts" > "sast". Download "gl-sast-report.json" and open it in your preferred JSON viewer.

AD

Interpreting the Report

The report follows the OWASP dites (OWASP Defect Dojo Import/Export Tool Standard). It includes information like the severity, check ID, file path, and description of each vulnerability.

GitLab 8.5 Has Been Released
GitLab 8.5 Has Been Released
GITHUB PROJECTS THAT CAN GET YOU HIRED
GITHUB PROJECTS THAT CAN GET YOU HIRED
Migrating from GitLab SaaS to Self-Hosted | Towards Data Science
Migrating from GitLab SaaS to Self-Hosted | Towards Data Science
BEST GITHUB PROJECTS FOR RESUME BUILDING
BEST GITHUB PROJECTS FOR RESUME BUILDING
GitLab Will Remove Dormant Projects From Free Accounts
GitLab Will Remove Dormant Projects From Free Accounts
10 GitHub Projects Every Student Should Build | Resume & Portfolio Ideas (2026)
10 GitHub Projects Every Student Should Build | Resume & Portfolio Ideas (2026)
How to Build a GitHub Portfolio That Gets Noticed
How to Build a GitHub Portfolio That Gets Noticed
a screen shot of the git chatsheet
a screen shot of the git chatsheet
10 SAAS IDEAS STUDENTS CAN BUILD
10 SAAS IDEAS STUDENTS CAN BUILD
Top 5 github Projects for beginners
Top 5 github Projects for beginners
Github VS Gitlab
Github VS Gitlab
10 AI SAAS PROJECTS EVERY STUDENT CAN BUILD
10 AI SAAS PROJECTS EVERY STUDENT CAN BUILD
🚀 Git & GitHub Project Setup: A Complete Overview
🚀 Git & GitHub Project Setup: A Complete Overview
Bitbucket vs Github vs Gitlab
Bitbucket vs Github vs Gitlab

Severity is categorized into Critical, High, Medium, Low, and Info. Address critical and high severity findings as soon as possible.

Fixing Vulnerabilities

Once you've identified the issues, it's time to fix them. The description field in the report provides enough context to guide your fixes. After addressing the vulnerabilities, commit the changes and push them to GitLab.

AD

Monitor your pipelines for any new or recurring vulnerabilities. Consider setting up automatic SAST scans after pushing commits or merging merge requests to continuously monitor your project's security.

Embracing GitLab SAST in your CI/CD pipeline ensures your projects maintain high security standards. Regularly review and update your SAST configurations to stay ahead of emerging threats. Happy coding!

AD