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")>.

Root access requirements

If you want to add trusted certificates to your scan images at runtime, you need to run the scan step with root access.

You can set up your STO scan images and pipelines to run scans as non-root and establish trust for your own proxies using custom 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.

    https://analysiscenter.veracode.com/auth/index.jsp#HomeAppProfile:88881:1973759

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:
    spec:
    sharedPaths:
    - /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:

  • CRITICAL
  • HIGH
  • MEDIUM
  • 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.


pipeline:
allowStageExecutions: false
projectIdentifier: YOUR_PROJECT_ID
orgIdentifier: YOUR_HARNESS_ORG_ID
tags: {}
stages:
- stage:
name: scan1
identifier: build
type: SecurityTests
spec:
cloneCodebase: false
infrastructure:
type: KubernetesDirect
spec:
connectorRef: YOUR_KUBERNETES_CLUSTER_CONNECTOR_ID
namespace: YOUR_NAMESPACE
automountServiceAccountToken: true
nodeSelector: {}
os: Linux
sharedPaths:
- /var/run
execution:
steps:
- step:
type: Background
name: dind-bg-step
identifier: dindbgstep
spec:
connectorRef: YOUR_CONTAINER_IMAGE_REGISTRY_CONNECTOR_ID
image: docker:dind
shell: Sh
entrypoint:
- dockerd
- step:
type: Security
name: Veracode
identifier: bandit
spec:
privileged: true
settings:
policy_type: dataLoad
scan_type: repository
repository_project: YOUR_VERACODE_REPOSITORY_PROJECT
repository_branch: YOUR_VERACODE_REPOSITORY_BRANCH
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_app_id: YOUR_VERACODE_PRODUCT_APP_ID
product_auth_type: apiKey
imagePullPolicy: Always
variables: []
identifier: Veracodedataloadexample
name: Veracode-dataload-example