Is a collection of individual security tools available together as a unit?

The whitepaper “A Seismic Shift in Application Security” explains how 4 of the top 6 attacks were application based. Download it to learn how to protect your organization.

Show

If you’re using GitLab CI/CD, you can use Static Application Security Testing (SAST) to check your source code for known vulnerabilities. You can run SAST analyzers in any GitLab tier. The analyzers output JSON-formatted reports as job artifacts.

With GitLab Ultimate, SAST results are also processed so you can:

  • See them in merge requests.
  • Use them in approval workflows.
  • Review them in the security dashboard.

For more details, see the Summary of features per tier.

Is a collection of individual security tools available together as a unit?

The results are sorted by the priority of the vulnerability:

  1. Critical
  2. High
  3. Medium
  4. Low
  5. Info
  6. Unknown

A pipeline consists of multiple jobs, including SAST and DAST scanning. If any job fails to finish for any reason, the security dashboard does not show SAST scanner output. For example, if the SAST job finishes but the DAST job fails, the security dashboard does not show SAST results. On failure, the analyzer outputs an exit code.

Use cases

  • Your code has a potentially dangerous attribute in a class, or unsafe code that can lead to unintended code execution.
  • Your application is vulnerable to cross-site scripting (XSS) attacks that can be leveraged to unauthorized access to session data.

Requirements

SAST runs in the

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
4 stage, which is available by default. If you redefine the stages in the
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
5 file, the
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
4 stage is required.

To run SAST jobs, by default, you need GitLab Runner with the

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
7 or
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
8 executor. If you’re using the shared runners on GitLab.com, this is enabled by default.

caution

Our SAST jobs require a Linux/amd64 container type. Windows containers are not yet supported.

caution

If you use your own runners, make sure the Docker version installed is not

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
9. See troubleshooting information for details.

Supported languages and frameworks

GitLab SAST supports scanning a variety of programming languages and frameworks. Once you enable SAST, the right set of analyzers runs automatically even if your project uses more than one language.

Check the SAST direction page to learn more about our plans for language support in SAST.

Language / frameworkAnalyzer used for scanningMinimum supported GitLab version.NET CoreSecurity Code Scan11.0.NET Framework1Security Code Scan13.0.NET (all versions, C# only)Semgrep with GitLab-managed rules15.4Apex (Salesforce)PMD12.1CSemgrep with GitLab-managed rules14.2C/C++Flawfinder10.7Elixir (Phoenix)Sobelow11.1Go3Gosec10.7GoSemgrep with GitLab-managed rules14.4Groovy2SpotBugs with the find-sec-bugs plugin11.3 (Gradle) & 11.9 (Maven, SBT)Helm ChartsKubesec13.1Java (any build system)Semgrep with GitLab-managed rules14.10Java2, 3SpotBugs with the find-sec-bugs plugin10.6 (Maven), 10.8 (Gradle) & 11.9 (SBT)Java (Android)MobSF (beta)13.5JavaScript3ESLint security plugin11.8JavaScriptSemgrep with GitLab-managed rules13.10Kotlin (Android)MobSF (beta)13.5Kotlin (General)2SpotBugs with the find-sec-bugs plugin13.11Kubernetes manifestsKubesec12.6Node.jsNodeJsScan11.1Objective-C (iOS)MobSF (beta)13.5PHPphpcs-security-audit10.8Python3bandit10.3PythonSemgrep with GitLab-managed rules13.9React3ESLint react plugin12.5ReactSemgrep with GitLab-managed rules13.10Rubybrakeman13.9Ruby on Railsbrakeman10.3Scala2SpotBugs with the find-sec-bugs plugin11.0 (SBT) & 11.9 (Gradle, Maven)Swift (iOS)MobSF (beta)13.5TypeScript3ESLint security plugin11.9, merged with ESLint in 13.2TypeScriptSemgrep with GitLab-managed rules13.10
  1. .NET 4 support is limited. The analyzer runs in a Linux container and does not have access to Windows-specific libraries or features. Use the Semgrep-based scanner if you need .NET 4 support.
  2. The SpotBugs-based analyzer supports Gradle, Maven, and SBT. It can also be used with variants like the Gradle wrapper, Grails, and the Maven wrapper. However, SpotBugs has limitations when used against Ant-based projects. We recommend using the Semgrep-based analyzer for Ant-based Java projects.
  3. These analyzers reached End of Support status in GitLab 15.4.

Multi-project support

Introduced in GitLab 13.7.

GitLab SAST can scan repositories that contain multiple projects.

The following analyzers have multi-project support:

  • Bandit
  • ESLint
  • Gosec
  • Kubesec
  • NodeJsScan
  • MobSF
  • PMD
  • Security Code Scan
  • Semgrep
  • SpotBugs
  • Sobelow

Enable multi-project support for Security Code Scan

Multi-project support in the Security Code Scan requires a Solution (

include:
  - template: Security/SAST.gitlab-ci.yml

semgrep-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.7"

brakeman-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.1.1"
0) file in the root of the repository. For details on the Solution format, see the Microsoft reference Solution (
include:
  - template: Security/SAST.gitlab-ci.yml

semgrep-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.7"

brakeman-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.1.1"
0) file.

False positive detection

Introduced in GitLab 14.2.

Vulnerabilities that have been detected and are false positives will be flagged as false positives in the security dashboard.

False positive detection is available in a subset of the supported languages and analyzers:

  • Ruby, in the Brakeman-based analyzer

Is a collection of individual security tools available together as a unit?

Advanced vulnerability tracking

Introduced in GitLab 14.2.

Source code is volatile; as developers make changes, source code may move within files or between files. Security analyzers may have already reported vulnerabilities that are being tracked in the Vulnerability Report. These vulnerabilities are linked to specific problematic code fragments so that they can be found and fixed. If the code fragments are not tracked reliably as they move, vulnerability management is harder because the same vulnerability could be reported again.

GitLab SAST uses an advanced vulnerability tracking algorithm to more accurately identify when the same vulnerability has moved within a file due to refactoring or unrelated changes.

Advanced vulnerability tracking is available in a subset of the supported languages and analyzers:

  • C, in the Semgrep-based analyzer only
  • Go, in the Gosec- and Semgrep-based analyzers
  • Java, in the Semgrep-based analyzer only
  • JavaScript, in the Semgrep-based analyzer only
  • Python, in the Semgrep-based analyzer only
  • Ruby, in the Brakeman-based analyzer

Support for more languages and analyzers is tracked in this epic.

For more information, see the confidential project

include:
  - template: Security/SAST.gitlab-ci.yml

semgrep-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.7"

brakeman-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.1.1"
2. The content of this project is available only to GitLab team members.

Supported distributions

The default scanner images are build off a base Alpine image for size and maintainability.

FIPS-enabled images

Introduced in GitLab 14.10.

GitLab offers an image version, based on the Red Hat UBI base image, that uses a FIPS 140-validated cryptographic module. To use the FIPS-enabled image, you can either:

  • Set the
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    semgrep-sast:
      variables:
        SAST_ANALYZER_IMAGE_TAG: "3.7"
    
    brakeman-sast:
      variables:
        SAST_ANALYZER_IMAGE_TAG: "3.1.1"
    
    3 to
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    semgrep-sast:
      variables:
        SAST_ANALYZER_IMAGE_TAG: "3.7"
    
    brakeman-sast:
      variables:
        SAST_ANALYZER_IMAGE_TAG: "3.1.1"
    
    4.
  • Add the
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    semgrep-sast:
      variables:
        SAST_ANALYZER_IMAGE_TAG: "3.7"
    
    brakeman-sast:
      variables:
        SAST_ANALYZER_IMAGE_TAG: "3.1.1"
    
    4 extension to the default image name.

For example:

variables:
  SAST_IMAGE_SUFFIX: '-fips'

include:
  - template: Security/SAST.gitlab-ci.yml

A FIPS-compliant image is only available for the Semgrep-based analyzer.

To use SAST in a FIPS-compliant manner, you must exclude other analyzers from running.

Summary of features per tier

Different features are available in different GitLab tiers, as shown in the following table:

CapabilityIn Free & PremiumIn UltimateAutomatically scan code with appropriate analyzersConfigure SAST scannersCustomize SAST settingsDownload JSON ReportSee new findings in merge request widgetManage vulnerabilitiesAccess the Security DashboardConfigure SAST in the UICustomize SAST rulesetsDetect False PositivesTrack moved vulnerabilities

Contribute your scanner

The Security Scanner Integration documentation explains how to integrate other security scanners into GitLab.

Configuration

To configure SAST for a project you can:

  • Use Auto SAST, provided by Auto DevOps.
  • Configure SAST manually.
  • Configure SAST using the UI (introduced in GitLab 13.3).

Configure SAST manually

To enable SAST you must include the

include:
  - template: Security/SAST.gitlab-ci.yml

semgrep-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.7"

brakeman-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.1.1"
6 template provided as a part of your GitLab installation.

Add the following to your

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
5 file:

include:
  - template: Jobs/SAST.gitlab-ci.yml

The included template creates SAST jobs in your CI/CD pipeline and scans your project’s source code for possible vulnerabilities.

The results are saved as a SAST report artifact that you can later download and analyze. Due to implementation limitations, we always take the latest SAST artifact available.

Configure SAST in the UI

You can enable and configure SAST in the UI, either with default settings, or with customizations. The method you can use depends on your GitLab license tier.

  • Configure SAST in the UI with default settings.
  • Configure SAST in the UI with customizations.

Configure SAST in the UI with default settings

Introduced in GitLab 13.9

note

The configuration tool works best with no existing

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
5 file, or with a minimal configuration file. If you have a complex GitLab configuration file it may not be parsed successfully, and an error may occur.

To enable and configure SAST with default settings:

  1. On the top bar, select Main menu > Projects and find your project.
  2. On the left sidebar, select Security & Compliance > Configuration.
  3. In the SAST section, select Configure with a merge request.
  4. Review and merge the merge request to enable SAST.

Pipelines now include a SAST job.

Configure SAST in the UI with customizations

Version history

  • Introduced in GitLab 13.3.
  • Improved in GitLab 13.4.
  • Improved in GitLab 13.5.

note

The configuration tool works best with no existing

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
5 file, or with a minimal configuration file. If you have a complex GitLab configuration file it may not be parsed successfully, and an error may occur.

To enable and configure SAST with customizations:

  1. On the top bar, select Main menu > Projects and find your project.
  2. On the left sidebar, select Security & Compliance > Configuration.
  3. If the project does not have a
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    spotbugs-sast:
      variables:
        FAIL_NEVER: 1
    
    5 file, select Enable SAST in the Static Application Security Testing (SAST) row, otherwise select Configure SAST.
  4. Enter the custom SAST values.

    Custom values are stored in the

    include:
      - template: Security/SAST.gitlab-ci.yml
    
    spotbugs-sast:
      variables:
        FAIL_NEVER: 1
    
    5 file. For CI/CD variables not in the SAST Configuration page, their values are inherited from the GitLab SAST template.

  5. Optionally, expand the SAST analyzers section, select individual SAST analyzers and enter custom analyzer values.
  6. Select Create Merge Request.
  7. Review and merge the merge request.

Pipelines now include a SAST job.

Overriding SAST jobs

caution

Beginning in GitLab 13.0, the use of

gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
2 and
gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
3 is no longer supported. When overriding the template, you must use
gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
4 instead.

To override a job definition, (for example, change properties like

gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
5 or
gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
6), declare a job with the same name as the SAST job to override. Place this new job after the template inclusion and specify any additional keys under it. For example, this enables
gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
7 for the
gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
8 analyzer:

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1

Pinning to minor image version

The GitLab-managed CI/CD template specifies a major version and automatically pulls the latest analyzer release within that major version.

In some cases, you may need to use a specific version. For example, you might need to avoid a regression in a later release.

To override the automatic update behavior, set the

gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
9 CI/CD variable in your CI/CD configuration file after you include the
include:
  - template: Security/SAST.gitlab-ci.yml

semgrep-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.7"

brakeman-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.1.1"
6 template.

Only set this variable within a specific job. If you set it at the top level, the version you set will be used for other SAST analyzers.

You can set the tag to:

  • A major version, like
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    variables:
      SCAN_KUBERNETES_MANIFESTS: "true"
    
    1. Your pipelines will use any minor or patch updates that are released within this major version.
  • A minor version, like
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    variables:
      SCAN_KUBERNETES_MANIFESTS: "true"
    
    2. Your pipelines will use any patch updates that are released within this minor version.
  • A patch version, like
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    variables:
      SCAN_KUBERNETES_MANIFESTS: "true"
    
    3. Your pipelines won’t receive any updates.

This example uses a specific minor version of the

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
4 analyzer and a specific patch version of the
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
5 analyzer:

include:
  - template: Security/SAST.gitlab-ci.yml

semgrep-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.7"

brakeman-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.1.1"

Using CI/CD variables to pass credentials for private repositories

Some analyzers require downloading the project’s dependencies to perform the analysis. In turn, such dependencies may live in private Git repositories and thus require credentials like username and password to download them. Depending on the analyzer, such credentials can be provided to it via custom CI/CD variables.

Using a CI/CD variable to pass username and password to a private Go repository

If your Go project depends on private modules, see Fetch modules from private projects for how to provide authentication over HTTPS.

To specify credentials via

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
6 provide a
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
7 containing the following:

gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF

Using a CI/CD variable to pass username and password to a private Maven repository

If your private Maven repository requires login credentials, you can use the

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
8 CI/CD variable.

Read more on how to use private Maven repositories.

Enabling Kubesec analyzer

Introduced in GitLab 12.6.

You need to set

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
9 to
stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
0 to enable the Kubesec analyzer. In
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
5, define:

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"

Pre-compilation

Most GitLab SAST analyzers directly scan your source code without compiling it first. However, for technical reasons, some analyzers can only scan compiled code.

By default, these analyzers automatically attempt to fetch dependencies and compile your code so it can be scanned. Automatic compilation can fail if:

  • your project requires custom build configurations.
  • you use language versions that aren’t built into the analyzer.

To resolve these issues, you can skip the analyzer’s compilation step and directly provide artifacts from an earlier stage in your pipeline instead. This strategy is called pre-compilation.

Pre-compilation is available for the analyzers that support the

stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
2 CI/CD variable. See Analyzer settings for the current list.

To use pre-compilation:

  1. Output your project’s dependencies to a directory in the project’s working directory, then save that directory as an artifact by setting the
    stages:
      - build
      - test
    
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    build:
      image: maven:3.6-jdk-8-slim
      stage: build
      script:
        - mvn package -Dmaven.repo.local=./.m2/repository
      artifacts:
        paths:
          - .m2/
          - target/
    
    spotbugs-sast:
      dependencies:
        - build
      variables:
        MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
        COMPILE: "false"
      artifacts:
        reports:
          sast: gl-sast-report.json
    
    3 configuration.
  2. Provide the
    stages:
      - build
      - test
    
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    build:
      image: maven:3.6-jdk-8-slim
      stage: build
      script:
        - mvn package -Dmaven.repo.local=./.m2/repository
      artifacts:
        paths:
          - .m2/
          - target/
    
    spotbugs-sast:
      dependencies:
        - build
      variables:
        MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
        COMPILE: "false"
      artifacts:
        reports:
          sast: gl-sast-report.json
    
    4 CI/CD variable to the analyzer to disable automatic compilation.
  3. Add your compilation stage as a dependency for the analyzer job.

To allow the analyzer to recognize the compiled artifacts, you must explicitly specify the path to the vendored directory. This configuration can vary per analyzer. For Maven projects, you can use

stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
5. See Analyzer settings for the complete list of available options.

The following example pre-compiles a Maven project and provides it to the SpotBugs SAST analyzer:

stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json

Available CI/CD variables

SAST can be configured using the

gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
5 parameter in
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
5.

caution

All customization of GitLab security scanning tools should be tested in a merge request before merging these changes to the default branch. Failure to do so can give unexpected results, including a large number of false positives.

The following example includes the SAST template to override the

stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
8 variable to
stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
9. The template is evaluated before the pipeline configuration, so the last mention of the variable takes precedence.

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SEARCH_MAX_DEPTH: 10

Logging level

Introduced in GitLab 13.1.

To control the verbosity of logs, set the

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SEARCH_MAX_DEPTH: 10
0 environment variable. Messages of this logging level or higher are output.

From highest to lowest severity, the logging levels are:

  • include:
      - template: Security/SAST.gitlab-ci.yml
    
    variables:
      SEARCH_MAX_DEPTH: 10
    
    1
  • include:
      - template: Security/SAST.gitlab-ci.yml
    
    variables:
      SEARCH_MAX_DEPTH: 10
    
    2
  • include:
      - template: Security/SAST.gitlab-ci.yml
    
    variables:
      SEARCH_MAX_DEPTH: 10
    
    3
  • include:
      - template: Security/SAST.gitlab-ci.yml
    
    variables:
      SEARCH_MAX_DEPTH: 10
    
    4 (default)
  • include:
      - template: Security/SAST.gitlab-ci.yml
    
    variables:
      SEARCH_MAX_DEPTH: 10
    
    5

Custom Certificate Authority

To trust a custom Certificate Authority, set the

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SEARCH_MAX_DEPTH: 10
6 variable to the bundle of CA certs that you want to trust in the SAST environment. The
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SEARCH_MAX_DEPTH: 10
6 value should contain the text representation of the X.509 PEM public-key certificate. For example, to configure this value in the
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
5 file, use the following:

variables:
  ADDITIONAL_CA_CERT_BUNDLE: |
      -----BEGIN CERTIFICATE-----
      MIIGqTCCBJGgAwIBAgIQI7AVxxVwg2kch4d56XNdDjANBgkqhkiG9w0BAQsFADCB
      ...
      jWgmPqF3vUbZE0EyScetPJquRFRKIesyJuBFMAs=
      -----END CERTIFICATE-----

The

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SEARCH_MAX_DEPTH: 10
6 value can also be configured as a custom variable in the UI, either as a
variables:
  ADDITIONAL_CA_CERT_BUNDLE: |
      -----BEGIN CERTIFICATE-----
      MIIGqTCCBJGgAwIBAgIQI7AVxxVwg2kch4d56XNdDjANBgkqhkiG9w0BAQsFADCB
      ...
      jWgmPqF3vUbZE0EyScetPJquRFRKIesyJuBFMAs=
      -----END CERTIFICATE-----
0, which requires the path to the certificate, or as a variable, which requires the text representation of the certificate.

Docker images

The following are Docker image-related CI/CD variables.

CI/CD variableDescription
variables:
  ADDITIONAL_CA_CERT_BUNDLE: |
      -----BEGIN CERTIFICATE-----
      MIIGqTCCBJGgAwIBAgIQI7AVxxVwg2kch4d56XNdDjANBgkqhkiG9w0BAQsFADCB
      ...
      jWgmPqF3vUbZE0EyScetPJquRFRKIesyJuBFMAs=
      -----END CERTIFICATE-----
1Override the name of the Docker registry providing the default images (proxy). Read more about customizing analyzers.
variables:
  ADDITIONAL_CA_CERT_BUNDLE: |
      -----BEGIN CERTIFICATE-----
      MIIGqTCCBJGgAwIBAgIQI7AVxxVwg2kch4d56XNdDjANBgkqhkiG9w0BAQsFADCB
      ...
      jWgmPqF3vUbZE0EyScetPJquRFRKIesyJuBFMAs=
      -----END CERTIFICATE-----
2Names of default images that should never run. Read more about customizing analyzers.
gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
9Override the default version of analyzer image. Read more about pinning the analyzer image version.
include:
  - template: Security/SAST.gitlab-ci.yml

semgrep-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.7"

brakeman-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.1.1"
3Suffix added to the image name. If set to
include:
  - template: Security/SAST.gitlab-ci.yml

semgrep-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.7"

brakeman-sast:
  variables:
    SAST_ANALYZER_IMAGE_TAG: "3.1.1"
4,
variables:
  ADDITIONAL_CA_CERT_BUNDLE: |
      -----BEGIN CERTIFICATE-----
      MIIGqTCCBJGgAwIBAgIQI7AVxxVwg2kch4d56XNdDjANBgkqhkiG9w0BAQsFADCB
      ...
      jWgmPqF3vUbZE0EyScetPJquRFRKIesyJuBFMAs=
      -----END CERTIFICATE-----
6 images are used for scan. See FIPS-enabled images for more details. Introduced in GitLab 14.10.

Vulnerability filters

Some analyzers make it possible to filter out vulnerabilities under a given threshold.

CI/CD variableDefault valueDescription
variables:
  ADDITIONAL_CA_CERT_BUNDLE: |
      -----BEGIN CERTIFICATE-----
      MIIGqTCCBJGgAwIBAgIQI7AVxxVwg2kch4d56XNdDjANBgkqhkiG9w0BAQsFADCB
      ...
      jWgmPqF3vUbZE0EyScetPJquRFRKIesyJuBFMAs=
      -----END CERTIFICATE-----
7
variables:
  ADDITIONAL_CA_CERT_BUNDLE: |
      -----BEGIN CERTIFICATE-----
      MIIGqTCCBJGgAwIBAgIQI7AVxxVwg2kch4d56XNdDjANBgkqhkiG9w0BAQsFADCB
      ...
      jWgmPqF3vUbZE0EyScetPJquRFRKIesyJuBFMAs=
      -----END CERTIFICATE-----
8Exclude vulnerabilities from output based on the paths. This is a comma-separated list of patterns. Patterns can be globs (see
variables:
  ADDITIONAL_CA_CERT_BUNDLE: |
      -----BEGIN CERTIFICATE-----
      MIIGqTCCBJGgAwIBAgIQI7AVxxVwg2kch4d56XNdDjANBgkqhkiG9w0BAQsFADCB
      ...
      jWgmPqF3vUbZE0EyScetPJquRFRKIesyJuBFMAs=
      -----END CERTIFICATE-----
9 for supported patterns), or file or folder paths (for example,
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SAST_EXPERIMENTAL_FEATURES: "true"
0). Parent directories also match patterns. You might need to exclude temporary directories used by your build tool as these can generate false positives. To exclude paths, copy and paste the default excluded paths, then add your own paths to be excluded. If you don’t specify the default excluded paths, you will override the defaults and only paths you specify will be excluded from the SAST scans.
stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
84SAST searches the repository to detect the programming languages used, and selects the matching analyzers. Set the value of
stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
8 to specify how many directory levels the search phase should span. After the analyzers have been selected, the entire repository is analyzed.
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SAST_EXPERIMENTAL_FEATURES: "true"
3 Comma-separated list of paths to exclude from scan. Uses Python’s
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SAST_EXPERIMENTAL_FEATURES: "true"
4 syntax; For example:
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SAST_EXPERIMENTAL_FEATURES: "true"
5. Removed in GitLab 15.4.
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SAST_EXPERIMENTAL_FEATURES: "true"
61Ignore Brakeman vulnerabilities under given confidence level. Integer, 1=Low 3=High.
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SAST_EXPERIMENTAL_FEATURES: "true"
71Ignore Flawfinder vulnerabilities under given risk level. Integer, 0=No risk, 5=High risk.
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SAST_EXPERIMENTAL_FEATURES: "true"
80Ignore Gosec vulnerabilities under given confidence level. Integer, 0=Undefined, 1=Low, 2=Medium, 3=High. Removed in GitLab 15.4.

Analyzer settings

Some analyzers can be customized with CI/CD variables.

CI/CD variableAnalyzerDescription
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
9KubesecSet to
stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
0 to scan Kubernetes manifests.
include:
  - template: Jobs/SAST.gitlab-ci.yml
01KubesecOptional path to Helm charts that
include:
  - template: Jobs/SAST.gitlab-ci.yml
02 uses to generate a Kubernetes manifest that
include:
  - template: Jobs/SAST.gitlab-ci.yml
03 scans. If dependencies are defined,
include:
  - template: Jobs/SAST.gitlab-ci.yml
04 should be ran in a
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
7 to fetch the necessary dependencies.
include:
  - template: Jobs/SAST.gitlab-ci.yml
06KubesecAdditional arguments for the
include:
  - template: Jobs/SAST.gitlab-ci.yml
02 executable.
stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
2Gosec, SpotBugsSet to
include:
  - template: Jobs/SAST.gitlab-ci.yml
09 to disable project compilation and dependency fetching. Introduced for
include:
  - template: Jobs/SAST.gitlab-ci.yml
10 analyzer in GitLab 13.1 and
include:
  - template: Jobs/SAST.gitlab-ci.yml
11 analyzer in GitLab 14.0.
include:
  - template: Jobs/SAST.gitlab-ci.yml
12SpotBugsThe
include:
  - template: Jobs/SAST.gitlab-ci.yml
12 variable.
include:
  - template: Jobs/SAST.gitlab-ci.yml
14SpotBugsPath to the
include:
  - template: Jobs/SAST.gitlab-ci.yml
15 executable.
include:
  - template: Jobs/SAST.gitlab-ci.yml
16SpotBugsPath to the
include:
  - template: Jobs/SAST.gitlab-ci.yml
17 executable.
include:
  - template: Jobs/SAST.gitlab-ci.yml
18SpotBugsAdditional arguments for the
include:
  - template: Jobs/SAST.gitlab-ci.yml
19 executable.
include:
  - template: Jobs/SAST.gitlab-ci.yml
20SpotBugsPath to the
include:
  - template: Jobs/SAST.gitlab-ci.yml
19 executable.
include:
  - template: Jobs/SAST.gitlab-ci.yml
22SpotBugsWhich Java version to use. Starting in GitLab 15.0, supported versions are
include:
  - template: Jobs/SAST.gitlab-ci.yml
23 and
include:
  - template: Jobs/SAST.gitlab-ci.yml
24 (default). Before GitLab 15.0, supported versions are
include:
  - template: Jobs/SAST.gitlab-ci.yml
25 (default) and
include:
  - template: Jobs/SAST.gitlab-ci.yml
23.
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
8SpotBugsAdditional arguments for the
include:
  - template: Jobs/SAST.gitlab-ci.yml
28 or
include:
  - template: Jobs/SAST.gitlab-ci.yml
29 executable.
include:
  - template: Jobs/SAST.gitlab-ci.yml
30SpotBugsPath to the
include:
  - template: Jobs/SAST.gitlab-ci.yml
28 executable.
stages:
  - build
  - test

include:
  - template: Security/SAST.gitlab-ci.yml

build:
  image: maven:3.6-jdk-8-slim
  stage: build
  script:
    - mvn package -Dmaven.repo.local=./.m2/repository
  artifacts:
    paths:
      - .m2/
      - target/

spotbugs-sast:
  dependencies:
    - build
  variables:
    MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
    COMPILE: "false"
  artifacts:
    reports:
      sast: gl-sast-report.json
5SpotBugsPath to the Maven local repository (shortcut for the
include:
  - template: Jobs/SAST.gitlab-ci.yml
33 property).
include:
  - template: Jobs/SAST.gitlab-ci.yml
34SpotBugsPath to the
include:
  - template: Jobs/SAST.gitlab-ci.yml
35 executable.
gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
7SpotBugsSet to
include:
  - template: Jobs/SAST.gitlab-ci.yml
37 to ignore compilation failure.
include:
  - template: Jobs/SAST.gitlab-ci.yml
38Goseccaution Removed in GitLab 14.0 - use custom rulesets instead. Path to configuration for Gosec (optional).
include:
  - template: Jobs/SAST.gitlab-ci.yml
39phpcs-security-auditComma separated list of additional PHP Extensions.
include:
  - template: Jobs/SAST.gitlab-ci.yml
40NodeJsScancaution Removed in GitLab 13.5
include:
  - template: Jobs/SAST.gitlab-ci.yml
41SemgrepSet to
include:
  - template: Jobs/SAST.gitlab-ci.yml
42 to disable sending anonymized scan metrics to r2c. Default:
include:
  - template: Jobs/SAST.gitlab-ci.yml
43. Introduced in GitLab 14.0 from the confidential issue
include:
  - template: Jobs/SAST.gitlab-ci.yml
44.
include:
  - template: Jobs/SAST.gitlab-ci.yml
45SemgrepCLI options (arguments with value, or flags) that are passed to the underlying security scanner when running scan operation. Only a limited set of options are accepted. Separate a CLI option and its value using either a blank space or equals (
include:
  - template: Jobs/SAST.gitlab-ci.yml
46) character. For example:
include:
  - template: Jobs/SAST.gitlab-ci.yml
47 or
include:
  - template: Jobs/SAST.gitlab-ci.yml
48. Multiple options must be separated by blank spaces. For example:
include:
  - template: Jobs/SAST.gitlab-ci.yml
49. Introduced in GitLab 15.3.

Security scanner configuration

SAST analyzers internally use OSS security scanners to perform the analysis. We set the recommended configuration for the security scanner so that you need not to worry about tuning them. However, there can be some rare cases where our default scanner configuration does not suit your requirements.

To allow some customization of scanner behavior, you can add a limited set of flags to the underlying scanner. Specify the flags in the

include:
  - template: Jobs/SAST.gitlab-ci.yml
45 CI/CD variable. These flags are added to the scanner’s CLI options.

AnalyzerCLI optionDescriptionSemgrep
include:
  - template: Jobs/SAST.gitlab-ci.yml
51Sets the maximum system memory to use when running a rule on a single file. Measured in MB.

Custom CI/CD variables

Introduced in GitLab 12.5.

In addition to the aforementioned SAST configuration CI/CD variables, all custom variables are propagated to the underlying SAST analyzer images if the SAST vendored template is used.

note

In GitLab 13.3 and earlier, variables whose names started with the following prefixes are not propagated to either the analyzer containers or SAST Docker container:

include:
  - template: Jobs/SAST.gitlab-ci.yml
52,
include:
  - template: Jobs/SAST.gitlab-ci.yml
53,
include:
  - template: Jobs/SAST.gitlab-ci.yml
54,
include:
  - template: Jobs/SAST.gitlab-ci.yml
55,
include:
  - template: Jobs/SAST.gitlab-ci.yml
56,
include:
  - template: Jobs/SAST.gitlab-ci.yml
57,
include:
  - template: Jobs/SAST.gitlab-ci.yml
58,
include:
  - template: Jobs/SAST.gitlab-ci.yml
59,
include:
  - template: Jobs/SAST.gitlab-ci.yml
60,
include:
  - template: Jobs/SAST.gitlab-ci.yml
61.

Experimental features

You can receive early access to experimental features. Experimental features might be added, removed, or promoted to regular features at any time.

Experimental features available are:

  • Enable scanning of iOS and Android apps using the MobSF analyzer.
  • Disable the following rules in the Semgrep analyzer that are known to cause a high rate of false positives:
    • include:
        - template: Jobs/SAST.gitlab-ci.yml
      
      62

Enable experimental features

To enable experimental features, add the following to your

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
5 file:

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SAST_EXPERIMENTAL_FEATURES: "true"

Reports JSON format

SAST outputs a report file in JSON format. The report file contains details of all found vulnerabilities. To download the report file, you can either:

  • Download the file from the CI/CD pipelines page.
  • In the pipelines tab on merge requests, set
    stages:
      - build
      - test
    
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    build:
      image: maven:3.6-jdk-8-slim
      stage: build
      script:
        - mvn package -Dmaven.repo.local=./.m2/repository
      artifacts:
        paths:
          - .m2/
          - target/
    
    spotbugs-sast:
      dependencies:
        - build
      variables:
        MAVEN_REPO_PATH: $CI_PROJECT_DIR/.m2/repository
        COMPILE: "false"
      artifacts:
        reports:
          sast: gl-sast-report.json
    
    3 to
    include:
      - template: Jobs/SAST.gitlab-ci.yml
    
    65.

For information, see Download job artifacts.

For details of the report file’s schema, see SAST report file schema.

For an example SAST report file, see

include:
  - template: Jobs/SAST.gitlab-ci.yml
66 example.

Running SAST in an offline environment

For self-managed GitLab instances in an environment with limited, restricted, or intermittent access to external resources through the internet, some adjustments are required for the SAST job to run successfully. For more information, see Offline environments.

Requirements for offline SAST

To use SAST in an offline environment, you need:

  • GitLab Runner with the
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    spotbugs-sast:
      variables:
        FAIL_NEVER: 1
    
    7 or
    include:
      - template: Security/SAST.gitlab-ci.yml
    
    spotbugs-sast:
      variables:
        FAIL_NEVER: 1
    
    8 executor.
  • A Docker Container Registry with locally available copies of SAST analyzer images.
  • Configure certificate checking of packages (optional).

GitLab Runner has a default

include:
  - template: Jobs/SAST.gitlab-ci.yml
69 of
include:
  - template: Jobs/SAST.gitlab-ci.yml
70, meaning the runner tries to pull Docker images from the GitLab container registry even if a local copy is available. The GitLab Runner
include:
  - template: Jobs/SAST.gitlab-ci.yml
69 can be set to
include:
  - template: Jobs/SAST.gitlab-ci.yml
72 in an offline environment if you prefer using only locally available Docker images. However, we recommend keeping the pull policy setting to
include:
  - template: Jobs/SAST.gitlab-ci.yml
70 if not in an offline environment, as this enables the use of updated scanners in your CI/CD pipelines.

Make GitLab SAST analyzer images available inside your Docker registry

For SAST with all supported languages and frameworks, import the following default SAST analyzer images from

include:
  - template: Jobs/SAST.gitlab-ci.yml
74 into your local Docker container registry:

include:
  - template: Jobs/SAST.gitlab-ci.yml
0

The process for importing Docker images into a local offline Docker registry depends on your network security policy. Consult your IT staff to find an accepted and approved process by which external resources can be imported or temporarily accessed. These scanners are periodically updated with new definitions, and you may be able to make occasional updates on your own.

For details on saving and transporting Docker images as a file, see the Docker documentation on

include:
  - template: Jobs/SAST.gitlab-ci.yml
75,
include:
  - template: Jobs/SAST.gitlab-ci.yml
76,
include:
  - template: Jobs/SAST.gitlab-ci.yml
77, and
include:
  - template: Jobs/SAST.gitlab-ci.yml
78.

If support for Custom Certificate Authorities are needed

Support for custom certificate authorities was introduced in the following versions.

AnalyzerVersion
include:
  - template: Jobs/SAST.gitlab-ci.yml
791v2.3.0
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
5v2.1.0
include:
  - template: Jobs/SAST.gitlab-ci.yml
811v2.9.2
include:
  - template: Jobs/SAST.gitlab-ci.yml
82v2.3.0
include:
  - template: Jobs/SAST.gitlab-ci.yml
831v2.5.0
include:
  - template: Jobs/SAST.gitlab-ci.yml
03v2.1.0
include:
  - template: Jobs/SAST.gitlab-ci.yml
85v2.9.5
include:
  - template: Jobs/SAST.gitlab-ci.yml
86v2.8.2
include:
  - template: Jobs/SAST.gitlab-ci.yml
87v2.1.0
include:
  - template: Jobs/SAST.gitlab-ci.yml
88v2.7.3
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
4v0.0.1
include:
  - template: Jobs/SAST.gitlab-ci.yml
90v2.2.0
gosec-sast:
  before_script:
    - |
      cat <<EOF > ~/.netrc
      machine gitlab.com
      login $CI_DEPLOY_USER
      password $CI_DEPLOY_PASSWORD
      EOF
8v2.7.1
  1. These analyzers were deprecated in GitLab 14.8 and reached End of Support in GitLab 15.4.

Set SAST CI/CD variables to use local SAST analyzers

Add the following configuration to your

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
5 file. You must replace
variables:
  ADDITIONAL_CA_CERT_BUNDLE: |
      -----BEGIN CERTIFICATE-----
      MIIGqTCCBJGgAwIBAgIQI7AVxxVwg2kch4d56XNdDjANBgkqhkiG9w0BAQsFADCB
      ...
      jWgmPqF3vUbZE0EyScetPJquRFRKIesyJuBFMAs=
      -----END CERTIFICATE-----
1 to refer to your local Docker container registry:

include:
  - template: Jobs/SAST.gitlab-ci.yml
1

The SAST job should now use local copies of the SAST analyzers to scan your code and generate security reports without requiring internet access.

Configure certificate checking of packages

If a SAST job invokes a package manager, you must configure its certificate verification. In an offline environment, certificate verification with an external source is not possible. Either use a self-signed certificate or disable certificate verification. Refer to the package manager’s documentation for instructions.

Running SAST in SELinux

By default SAST analyzers are supported in GitLab instances hosted on SELinux. Adding a

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
7 in an overridden SAST job may not work as runners hosted on SELinux have restricted permissions.

Troubleshooting

SAST debug logging

Increase the Secure scanner log verbosity to

include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SEARCH_MAX_DEPTH: 10
5 in a global CI variable to help troubleshoot SAST jobs.

include:
  - template: Jobs/SAST.gitlab-ci.yml
2

The GitLab-managed SAST CI/CD template controls which analyzer jobs run and how they’re configured. While using the template, you might experience a job failure or other pipeline error. For example, you might:

  • See an error message like
    include:
      - template: Jobs/SAST.gitlab-ci.yml
    
    96 when you view an affected pipeline.
  • Experience another type of unexpected issue with your CI/CD pipeline configuration.

If you’re experiencing a job failure or seeing a SAST-related

include:
  - template: Jobs/SAST.gitlab-ci.yml
97 pipeline status, you can temporarily revert to an older version of the template so your pipelines keep working while you investigate the issue. To use an older version of the template, change the existing
include:
  - template: Jobs/SAST.gitlab-ci.yml
98 statement in your CI/CD YAML file to refer to a specific template version, such as
include:
  - template: Jobs/SAST.gitlab-ci.yml
99:

include:
  - template: Jobs/SAST.gitlab-ci.yml
3

If your GitLab instance has limited network connectivity, you can also download the file and host it elsewhere.

We recommend that you only use this solution temporarily and that you return to the standard template as soon as possible.

Errors in a specific analyzer job

GitLab SAST analyzers are released as container images. If you’re seeing a new error that doesn’t appear to be related to the GitLab-managed SAST CI/CD template or changes in your own project, you can try pinning the affected analyzer to a specific older version.

Each analyzer project has a

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
00 file listing the changes made in each available version.

include: - template: Jobs/SAST.gitlab-ci.yml 9

This error occurs when the Docker version that runs the SAST job is

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
9. Consider updating to Docker
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
03 or greater. Older versions are not affected. Read more in this issue.

Getting warning message include: - template: Security/SAST.gitlab-ci.yml spotbugs-sast: variables: FAIL_NEVER: 1 0

For information on this, see the general Application Security troubleshooting section.

Error: include: - template: Security/SAST.gitlab-ci.yml spotbugs-sast: variables: FAIL_NEVER: 1 1

For information on this, see the GitLab Secure troubleshooting section.

Limitation when using rules:exists

The SAST CI template uses the

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
06 parameter. For performance reasons, a maximum number of matches are made against the given glob pattern. If the number of matches exceeds the maximum, the
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
06 parameter returns
include:
  - template: Jobs/SAST.gitlab-ci.yml
43. Depending on the number of files in your repository, a SAST job might be triggered even if the scanner doesn’t support your project. For more details about this issue, see the
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
06 documentation.

SpotBugs UTF-8 unmappable character errors

These errors occur when UTF-8 encoding isn’t enabled on a SpotBugs build and there are UTF-8 characters in the source code. To fix this error, enable UTF-8 for your project’s build tool.

For Gradle builds, add the following to your

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
10 file:

include:
  - template: Jobs/SAST.gitlab-ci.yml
4

For Maven builds, add the following to your

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
11 file:

include:
  - template: Jobs/SAST.gitlab-ci.yml
5

SpotBugs Error: include: - template: Security/SAST.gitlab-ci.yml spotbugs-sast: variables: FAIL_NEVER: 1 2

If your job is failing at the build step with the message “Project couldn’t be built”, it’s most likely because your job is asking SpotBugs to build with a tool that isn’t part of its default tools. For a list of the SpotBugs default tools, see SpotBugs’ asdf dependencies.

The solution is to use pre-compilation. Pre-compilation ensures the images required by SpotBugs are available in the job’s container.

Flawfinder encoding error

This occurs when Flawfinder encounters an invalid UTF-8 character. To fix this, convert all source code in your project to UTF-8 character encoding. This can be done with

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
13 or
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
14 either over the entire project or per job using the
include:
  - template: Security/SAST.gitlab-ci.yml

variables:
  SCAN_KUBERNETES_MANIFESTS: "true"
7 feature.

Semgrep slowness, unexpected results, or other errors

If Semgrep is slow, reports too many false positives or false negatives, crashes, fails, or is otherwise broken, see the Semgrep docs for troubleshooting GitLab SAST.

SAST job fails with message include: - template: Security/SAST.gitlab-ci.yml spotbugs-sast: variables: FAIL_NEVER: 1 3

Invoking Docker-in-Docker is the likely cause of this error. Docker-in-Docker is:

  • Disabled by default in GitLab 13.0 and later.
  • Unsupported from GitLab 13.4 and later.

Several workarounds are available. From GitLab version 13.0 and later, you must not use Docker-in-Docker.

Workaround 1: Pin analyzer versions (GitLab 12.1 and earlier)

Set the following variables for the SAST job. This pins the analyzer versions to the last known working version, allowing SAST with Docker-in-Docker to complete as it did previously:

include:
  - template: Jobs/SAST.gitlab-ci.yml
6

Remove any analyzers you don’t need from the

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
17 list. Keep
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
18 set to an empty string
include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
19.

Workaround 2: Disable Docker-in-Docker for SAST and Dependency Scanning (GitLab 12.3 and later)

Disable Docker-in-Docker for SAST. Individual

include:
  - template: Security/SAST.gitlab-ci.yml

spotbugs-sast:
  variables:
    FAIL_NEVER: 1
20 jobs are created for each analyzer that runs in your CI/CD pipeline.

include:
  - template: Jobs/SAST.gitlab-ci.yml
7

Workaround 3: Upgrade to GitLab 13.x and use the defaults

From GitLab 13.0, SAST defaults to not using Docker-in-Docker. In GitLab 13.4 and later, SAST using Docker-in-Docker is no longer supported. If you have this problem on GitLab 13.x and later, you have customized your SAST job to use Docker-in-Docker. To resolve this, comment out any customizations you’ve made to your SAST CI job definition and follow the documentation to reconfigure, using the new and improved job definition default values.

Is a security tool that detects and protects a personal computer and its data from unauthorized intrusions?

In a single home network, a firewall can filter traffic and alert the user to intrusions.

What kind of software consists of programs designed?

1. Application software consists of programs designed to make users more productive? 2.

What kind of software consists of programs designed to make users more productive and or assist the with personal tasks?

Application software consists of programs designed to make users more productive and/or assist them with personal tasks.

Which of the following tools searches for and removes unnecessary files?

Disk cleanup is a tool that searches for and removes unnecessary files.