ASoC and GitLab

Use AppScan on Cloud with GitLab to run static analysis security testing (SAST) against the files in your repository on every merge request, thus preventing vulnerabilities from reaching the main branch. Results are stored in AppScan on Cloud.

Register

If you don't have an account, register on HCL AppScan on Cloud (ASoC) to generate your API key and API secret.

Setup

  1. Generate your ASoC API key and API secret on the API page.

    The API key and API secret map to the ASOC_KEY and ASOC_SECRET parameters for this action. Make note of the key and secret.

  2. Create the application in ASoC.

    Applications act as a container to store all scans that are related to the same project.

  3. Copy the application name.

    The application name in ASoC maps to APP_NAME for this integration.

  4. Create variables in GitLab. Select Settings > CI/CD > Variables, and set the variables as follows:
    Table 1. Required inputs (SAST or DAST
    Variable Value
    APPSCAN_KEY Your API key from the API page.
    APPSCAN_SECRET Your API secret from the API page
    APP_NAME The name of the application in AppScan.
    APPSCAN_ASSET The ID of the asset group in AppScan.

  5. Copy .gitlab-ci.yaml and Dockerfile into your GitLab repository root.
  6. Set the CI/CD configuration file. Select Settings > CI/CD > General pipelines > CI/CD Configuration file.

  7. Build your own runner. Select Settings > CI/CD > Runners and follow the steps under Specific Runners.
  8. On the system on which you are setting up the GitLab runner, log in and clone your GitLab repository if one does not already exist. Ensure that a Docker engine is installed on that machine.
  9. Build a new Docker image called saclient from the Dockerfile. Change directory to the root of the repository and run the following command to build the Docker image:
     docker build -t saclient . 
    Important:
    The period at the end indicates the current directory.
  10. In GitLab, to prevent merges if the scan fails, enable Pipelines must succeed at Settings > Merge requests > Merge checks.
  11. Verify a new scan job is initiated when new merge requests are created at Settings > CI/CD > Pipelines.

Examples

Scan job

Scan artifacts ready for download

Scan job passed based on maxIssuesAllowed

Additional Information

The current yaml script contains a sample of a security policy check that fails the scan if the number of allowed security issues exceeds a certain threshold. The sample has maxIssuesAllowed set to 100.