For the complete documentation index, see llms.txt. This page is also available as Markdown.

Semgrep step configuration

Scan code repositories with Semgrep.

You can scan your code repositories using Semgrep and ingest the results into STO.

For a quick introduction, go to the SAST code scans using Semgrep tutorial.

Important notes for running Semgrep scans in STO

Set-up workflows

Orchestration scans

To scan a code repository, you need Harness Code Repository or a Harness connector to your Git service.

Add the Semgrep scanner

Do the following:

  1. Add a Build or Security stage to your pipeline.

  2. Configure the stage to point to the codebase you want to scan.

  3. Add a Semgrep step to the stage.

Set up the Semgrep scanner

Required settings

  1. Scan mode = Orchestration

  2. Target and Variant Detection = Auto

Optional settings

  • Fail on Severity — Stop the pipeline if the scan detects any issues at a specified severity or higher

  • Log Level — Useful for debugging

Scan the repository

Save your pipeline and then select Run.

The pipeline scans your code repository and then shows the results in Vulnerabilities tab.

Ingestion scans

Add a shared path for your scan results

  1. Add a Build or Security stage to your pipeline.

  2. In the stage Overview, add a shared path such as /shared/scan_results.

Copy scan results to the shared path

There are two primary workflows to do this:

  • Add a Run step that runs a Semgrep scan from the command line and then copies the results to the shared path.

  • Copy results from a Semgrep scan that ran outside the pipeline.

For more information and examples, go to Ingestion scans.

Set up the Semgrep scanner

Add a Semgrep step to the stage and set it up as follows.

Required settings

  1. Scan mode = Ingestion

  2. Target name — Usually the repo name

  3. Target variant — Usually the scanned branch. You can also use a runtime input and specify the branch at runtime.

  4. Ingestion file — For example, /shared/scan_results/semgrep-scan.json

Optional settings

  • Fail on Severity — Stop the pipeline if the scan detects any issues at a specified severity or higher

  • Log Level — Useful for debugging

Scan the repository

Save your pipeline and then select Run.

The pipeline scans your code repository and then shows the results in Vulnerabilities tab.

Semgrep step configuration

The recommended workflow is to add a Semgrep step to a Security Tests or CI Build stage and then configure it as described below.

Scan

Scan Mode

Scan Configuration

You can use this setting to select the set of Semgrep rulesets to include in your scan:

Target

Type

Target and variant detection

Name

Variant

Workspace

Ingestion File

Access Token

Log Level

Additional CLI flags

Use this field to run the semgrep scanner with flags such as:

--severity=ERROR --use-git-ignore

With these flags, semgrep considers only ERROR severity rules and ignores files included in .gitignore.

Fail on Severity

Settings

Additional Configuration

Advanced settings

Configure Semgrep as a Built-in Scanner

The Semgrep scanner is available as a built-in scanner in STO. Configuring it as a built-in scanner enables the step to automatically perform scans using the free version without requiring any licenses. Follow these steps to set it up:

  1. Search for SAST in the step palette or navigate to the Built-in Scanners section and select the SAST step.

  2. Expand the Additional CLI Flags section if you want to configure optional CLI flags.

  3. Click Add Scanner to save the configuration.

The scanner will automatically use the free version, detect scan targets, and can be further configured by clicking on the step whenever needed.

Proxy settings

YAML pipeline example

The following pipeline example illustrates an orchestration workflow. It consists of a Semgrep step that scans a code repository and then ingests, normalizes, and deduplicates the results.

Last updated

Was this helpful?