Skip to main content

Veracode scanner reference for STO

Veracode is a popular tool for scanning code repositories for security issues and vulnerabilities. Veracode performs dynamic (automated penetration test) and static (automated code review) code analysis and finds security vulnerabilities that include malicious code as well as the absence of functionality that can lead to security breaches.

Important notes for running Veracode scans in STO

  • Before you can ingest scan results, you must perform all the Veracode prerequisites for the repo that you're scanning. If you're scanning a Java repo, for example, the Veracode documentation outlines the specific packaging and compilation requirements for scanning your Java applications.
    For specific requirements, got to the Veracode docs and search for Veracode Packaging Requirements.
  • You also need access credentials so that STO can communicate with your Veracode instance. Harness recommends using API keys, not usernames and passwords, for your Veracode integrations
    For instructions, go to the Veracode docs and search for Generate Veracode API Credentials.
    Harness recommends you create text secrets for your authentication credentials — password, API key, API secret key, etc. — and access your secrets using <+secrets.getValue("my-secret")>.
  • The Veracode - Automated Data Load and Veracode - Activate Scenario blog posts include useful information about how to ingest Veracode scan results into Harness.

Docker-in-Docker requirements

The following use cases require a Docker-in-Docker background step in your pipeline:

  • Container image scans on Kubernetes and Docker build infrastructures
  • Security steps (not step palettes) on Kubernetes and Docker build infrastructures
    • Required for all target types and Orchestration/DataLoad modes

The following use cases do not require Docker-in-Docker:

Set up a Docker-in-Docker background step
  1. Go to the stage where you want to run the scan.

  2. In Overview, add the shared path /var/run.

  3. In Execution, do the following:

    1. Click Add Step and then choose Background.

    2. Configure the Background step as follows:

      1. Dependency Name = dind

      2. Container Registry = The Docker connector to download the DinD image. If you don't have one defined, go to Docker connector settings reference.

      3. Image = docker:dind

      4. Under Entry Point, add the following: dockerd

        In most cases, using dockerd is a faster and more secure way to set up the background step. For more information, go to the TLS section in the Docker quick reference.

      If the DinD service doesn't start with dockerd, clear the Entry Point field and then run the pipeline again. This starts the service with the default entry point.

      1. Under Optional Configuration, select the Privileged checkbox.
Configure the background step

Root access requirements

You need to run the scan step with root access if either of the following apply:


You can set up your STO scan images and pipelines to run scans as non-root and establish trust for your own proxies using self-signed certificates. For more information, go to Configure STO to Download Images from a Private Registry.

For more information

The following topics contain useful information for setting up scanner integrations in STO:

Required Settings for Veracode scans in STO

To set up a Veracode scan, add a Security step to your pipeline and add the following settings:

  • product_name = veracode

  • scan_typerepository

  • policy_type — STO supports the following scan policy types for Veracode:

    • orchestratedScan  — A Security step in the pipeline runs the scan and ingests the results. This is the easiest to set up and supports scans with default or predefined settings. See Run an Orchestration Scan in an STO Pipeline.
    • ingestionOnly — Run the scan in a Run step, or outside the pipeline, and then ingest the results. This is useful for advanced workflows that address specific security needs. See Ingest scan results into an STO pipeline.
    • dataLoad — A Security step downloads and ingests results from an external scanner.
  • product_config_name = default

  • repository_project — The name of the repo that gets scanned as shown in the Veracode UI. You use the Codebase Config object in the Harness pipeline to determine the URL of the repo to scan.
    In most cases, this should match the repo name used in your Git provider.

  • repository_branch — The branch that gets reported in STO for the ingested results. You can specify a hardcoded string or use the runtime variable <+codebase.branch>. This sets the branch based on the user input or trigger payload at runtime.
    In most cases, this field should match the name of Git branch that is getting scanned.

  • fail_on_severity - See Fail on Severity.

  • product_auth_type

    • apiKey — Recommended.
      Go to the Veracode docs and search for Generate Veracode API Credentials.
    • usernamePassword— Not recommended.
  • product_access_id

    • For usernamePassword authentication, this is your username.
    • For apiKey authorization, this is your API key.
  • product_access_token

    • For usernamePassword authentication, this is your password.
    • For apiKey authorization, this is your API Secret key.
  • product_app_id  — The Veracode GUID, separated with hyphens, for the target application.

    To determine the App ID, go to the home page for the Veracode app with the results you want to scan. The App ID is the string immediately after the port number in the URL. Thus, for the following app, you would specify 1973759.

    The Veracode - Automated Data Load blog post describes in more detail how you can find your application IDs and project names.

Ingestion settings

If the policy_type is ingestionOnly:

  • ingestion_file = The path to your scan results when running an Ingestion scan, for example /shared/scan_results/myscan.latest.sarif.
  • The data file must be in a supported format for the scanner.

  • The data file must be accessible to the scan step. It's good practice to save your results files to a shared path in your stage. In the visual editor, go to the stage where you're running the scan. Then go to Overview > Shared Paths. You can also add the path to the YAML stage definition like this:

        - stage:
    - /shared/scan_results

Fail on Severity

Every Security step has a Fail on Severity setting. If the scan finds any vulnerability with the specified severity level or higher, the pipeline fails automatically. You can specify one of the following:

  • HIGH
  • LOW
  • INFO
  • NONE — Do not fail on severity

The YAML definition looks like this: fail_on_severity : critical # | high | medium | low | info | none

Veracode pipeline example (dataLoad)

The following pipeline example illustrates a dataLoad workflow to ingest data from Veracode. It consists of two steps:

  1. A Background step that runs a Docker-in-Docker service (required if you're using a Security step to configure your integration).

  2. A Security step that specifies the information needed to ingest the scan results from the Veracode server.

allowStageExecutions: false
projectIdentifier: YOUR_PROJECT_ID
orgIdentifier: YOUR_HARNESS_ORG_ID
tags: {}
- stage:
name: scan1
identifier: build
type: SecurityTests
cloneCodebase: false
type: KubernetesDirect
automountServiceAccountToken: true
nodeSelector: {}
os: Linux
- /var/run
- step:
type: Background
name: dind-bg-step
identifier: dindbgstep
image: docker:dind
shell: Sh
- dockerd
- step:
type: Security
name: Veracode
identifier: bandit
privileged: true
policy_type: dataLoad
scan_type: repository
product_name: veracode
product_config_name: veracode-agent
product_access_token: <+secrets.getValue("YOUR_VERACODE_TOKEN_SECRET")>
product_access_id: <+secrets.getValue("YOUR_VERACODE_ID")>
product_auth_type: apiKey
imagePullPolicy: Always
variables: []
identifier: Veracodedataloadexample
name: Veracode-dataload-example