Harness STO supports the following scan modes for the following Snyk products:
- Snyk Open Source
- Snyk Code
- Snyk Container
- Snyk infrastructure as Code (currently in beta)
Important notes for running Snyk scans in STO
The following use cases require a Docker-in-Docker background step in your pipeline:
- Container image scans on Kubernetes and Docker build infrastructures
- Required for Orchestration and Dataload scan modes
- 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:
- Harness Cloud AMD64 build infrastructures
- SAST/DAST/configuration scans that use scanner templates (not Security steps)
- Ingestion scans where the data file has already been generated
Set up a Docker-in-Docker background step
Go to the stage where you want to run the scan.
In Overview, add the shared path
In Execution, do the following:
Click Add Step and then choose Background.
Configure the Background step as follows:
Dependency Name =
Container Registry = The Docker connector to download the DinD image. If you don't have one defined, go to Docker connector settings reference.
Under Entry Point, add the following:
In most cases, using
dockerdis 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.
- Under Optional Configuration, select the Privileged checkbox.
- Visual setup
- YAML setup
Add a Background step to your pipeline and set it up as follows:
Root access requirements
You need to run the scan step with root access if either of the following apply:
You need to run a Docker-in-Docker background service.
You need to add trusted certificates to your scan images at runtime.
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:
Snyk step settings for STO
The recommended workflow is add a Snyk step to a Security Tests or CI Build stage and then configure it as described below. You can also configure scans programmatically by copying, pasting, and editing the YAML definition.
- Orchestration Configure the step to run a scan and then ingest, normalize, and deduplicate the results.
- Ingestion Configure the step to read scan results from a data file and then ingest, normalize, and deduplicate the data.
The predefined configuration to use for the scan. All scan steps have at least one configuration.
The target type to scan for vulnerabilities.
Repository Scan a codebase repo.
In most cases, you specify the codebase using a code repo connector that connects to the Git account or repository where your code is stored. For information, go to Configure codebase.
- Container Image Scan the layers, libraries, and packages in a container image.
The identifier for the target, such as
jsmith/myalphaservice. Descriptive target names make it much easier to navigate your scan data in the STO UI.
It is good practice to specify a baseline for every target.
The identifier for the specific variant to scan. This is usually the branch name, image tag, or product version. Harness maintains a historical trend for each variant.
The workspace path on the pod running the scan step. The workspace path is
/harness by default.
You can override this if you want to scan only a subset of the workspace. For example, suppose the pipeline publishes artifacts to a subfolder
/tmp/artifacts and you want to scan these artifacts only. In this case, you can specify the workspace path as
Access Token (Orchestration scans)
The access token to log in to the scanner. In most cases this is a password or an API key.
You should create a Harness text secret with your encrypted token and reference the secret using the format
<+secrets.getValue("project.my-access-token")>. For more information, go to Add and Reference Text Secrets.
The path to your scan results when running an Ingestion scan, for example
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:
Additional CLI flags
You can use this field to run the Snyk scanner with specific command-line arguments.
The minimum severity of the messages you want to include in your scan logs. You can specify one of the following:
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:
NONE— Do not fail on severity
The YAML definition looks like this:
fail_on_severity : critical # | high | medium | low | info | none
You can use this field to run the Snyk scan with additional options.
Show original CVSS scores overridden by Snyk security policies
You can configure a Snyk step to show the original score when a Snyk Enterprise security policy overrode the severity for an issue coming from the
snyk CLI. You can see this information in Issue Details.
This feature is supported for
snyk container and
snyk test JSON output that properly reflects an override.
To enable this behavior, add the setting
ingest_tool_severity and set it to
true in the Snyk ingestion step. With this setting enabled, the Snyk step processes the relevant data for issues with overridden severities.
In the Additional Configuration settings, you can use the following options:
In the Advanced settings, you can use the following options: