Static Application Security Testing (SAST)

Updated at:
Copy as MD

Detecting security vulnerabilities before code is released is a critical step in securing your applications. SAST (Static Application Security Testing) performs static analysis on source code to identify code defects and security vulnerabilities without running the program, helping development teams find and fix issues early in the development cycle to reduce remediation costs.

Overview

SAST performs static analysis on uploaded or submitted source code to scan for security vulnerabilities and coding defects. Unlike SCA (Software Composition Analysis), which focuses on third-party dependencies, SAST focuses on your own code logic and detects the following types of security issues:

  • Injection vulnerabilities such as SQL injection and command injection

  • Cross-site scripting (XSS) attacks

  • Hardcoded sensitive information (such as keys and plaintext passwords)

  • Use of insecure cryptographic algorithms

  • Access control defects

  • Other OWASP Top 10 security risks

SAST does not require running the code or deploying an application environment. It analyzes source code text directly, making it well-suited for discovering and fixing security issues as early as possible during the development phase.

Use cases

Use case

Description

Pre-commit code review

Run SAST scans before merging code into the main branch to identify security vulnerabilities and prevent problematic code from reaching production.

Periodic security audits

Run regular SAST scans on existing code projects to continuously monitor code security status.

Compliance auditing

Meet security compliance requirements by providing code security scan reports as audit evidence.

Trigger a SAST scan

SAST supports the following two trigger methods. Choose based on your project's CI/CD environment:

  • Manually create a project: For projects not connected to GitLab CI. When creating a project, select SAST under Scan Type, then upload your code and trigger the scan manually. For detailed steps, see Manual Upload Scan.

  • Auto-register a project (GitLab CI): For projects connected to GitLab CI. SAST scans are automatically triggered via GitLab CI Pipeline when code is committed or a Merge Request is created. For detailed steps, see GitLab CI Integration.

For both methods, select Scan Type to include SAST when creating the project to enable static security analysis.

View SAST scan results

After the scan is complete, follow these steps to view the SAST detection results:

  1. Log on to the Code Security console.

  2. On the Project List page, locate the target project and click View in the Actions column.

  3. In the Task List of the project, click View in the Actions column of the target scan task to go to the scan results page.

  4. Click the SAST tab to view the detailed SAST results.

Interpret results

The SAST tab displays a list of code security issues found in the current scan, with the following main fields:

Field

Description

Defect name

The type and description of the security issue, for example, "OS command injection via file path parameter" or "Remote code execution via SpEL expression injection".

Severity

The severity of the vulnerability (Critical, High, Medium, or Low), helping developers prioritize high-risk issues first.

CWE ID

The Common Weakness Enumeration (CWE) number associated with the vulnerability, for easy cross-reference with standard defect classifications.

File path / Line number

The source code file path and line number where the security issue exists, helping developers quickly locate the problematic code.

Status

The handling status of the defect, for tracking remediation progress.

Click a specific defect entry to view remediation suggestions and secure coding guidelines that help developers correctly fix the issue. We recommend prioritizing Critical and High severity vulnerabilities to eliminate key security risks before code is released.

FAQ

What is the difference between SAST and SCA?

SAST analyzes the project's own source code to find security vulnerabilities in the code logic (such as injection and XSS). SCA analyzes third-party open-source components referenced by the project to find known CVE vulnerabilities. The two complement each other, and we recommend enabling both for comprehensive security detection coverage. For a detailed comparison, see Software Composition Analysis (SCA).

How long does a SAST scan take?

Scan time depends on the code volume and complexity. The system automatically completes the analysis and updates the scan status in the Task List.