Integrate Application Security with GitLab

Scan for vulnerabilities and prevent potential exploits before publishing changes to your production environment by using the Application Security integration with GitLab.

Integrate your Application Security scans into your GitLab CI/CD pipeline by including the scanning steps, which will then automate a DAST scan as part of that build.

What you’ll need

To make your configuration easier, have the following pieces of information available:

Configure your CI/CD pipeline for Application Security scans

  1. Access the Rapid7 Application Security step from Dockerhub. The docker image is included in the pipeline through the image field in the pipeline YAML.

  2. In the GitLab CI/CD Editor, add the following stage, using your own details:

Copy
stages:
  - scan

scan:
  image: rapid7/insightappsec-gitlab-scan:latest
  stage: scan
  script:
    - python3 /insightappsec_scan/actions.py --TOKEN="${IAS_API_KEY}" --SCAN_CONFIG_ID="${SCAN_CONFIG_ID}" --REGION="${REGION}" --FAIL_ON_VULN_FINDINGS="${FAIL_ON_VULN_FINDINGS}" --WAIT_FOR_SCAN_COMPLETE="${WAIT_FOR_SCAN_COMPLETE}" --VULN_QUERY="${VULN_QUERY}" --LOG_LEVEL="${LOG_LEVEL}" --TIMEOUT="${TIMEOUT}"
  variables:
    REGION: us
    SCAN_CONFIG_ID: 187a1863-8f1a-4a85-92a6-14d41613deb3
    vuln-query: "vulnerability.severity = 'HIGH'"
    FAIL_ON_VULN_FINDINGS: "false"

You can add scan gating to prevent vulnerable code from being deployed to production.

Scan gating

You can set gating criteria with this integration to prevent risky code from entering your production environment. One way to use scan gating is to set build pass/fail criteria for vulnerabilities. When the scan finds vulnerabilities that meet or exceed your gating criteria, you can set a step to follow, such as failing the workflow so that code is not deployed to production.

If you set the FAIL_ON_VULN_FINDINGS option to true and results in (VULN_QUERY) match this criteria, then the integration will optionally fail the build.

The scan gating query can be anything the search vulnerability endpoint can accept, not just limited to severity. For more information, see the Application Security API documentation.

View results

During the scan, you can view scan progress in both GitLab and Application Security on the Scanning Activity page. When the scan completes and the results are automatically sent back to GitLab, you can view your results in the build results and in Application Security .