Gitleaks step configuration
Scan code repositories with Gitleaks.
You can scan your code repositories using Gitleaks and ingest your results into Harness STO.
Important notes
This section describes recommended best practices and references to useful information.
Update your allowlist with inactive secrets
You can specify an allowlist of secrets that are inactive, rotated, deactivated, or false positives. Gitleaks ignores these secrets during a scan. Set up your allowlist in a .gitleaks.toml file and place it at the root of your repository.
The following steps outline the recommended workflow:
Run a Gitleaks scan and review the detected passwords, tokens, and other secrets.
Rotate or deactivate all secrets that are currently active.
Compile a list of all secrets that are now inactive, rotated, deactivated, or false positives.
Update the allowlist in
.gitleaks.tomlto include these secrets.
Harness recommends that you add your secrets as plain text to the regexes array, as shown in this example. This is the most reliable method to ensure that Gitleaks detects only active secrets when you run another scan.
Redact secrets
Harness recommends that you configure the Gitleaks step to redact secrets in the log output.
Speed up your scans
To speed up your scan times, you can configure the Gitleaks step to limit the number of commits to scan. By default, Gitleaks scans the entire commit history.
Write custom detection rules
You can also write your own custom detection rules.
For examples, go to the default Gitleaks config.
If you want to contribute to the default configuration, go to the Contributing guidelines.
For information about advanced configurations, go to Stop leaking secrets - configuration.
For more information
Gitleaks step settings for STO scans
The recommended workflow is to add a GitLeaks step to a Security or Build stage and then configure it as described below.
Scan Mode
Scan Configuration
Target
Type
Target and variant detection
Name
Variant
Workspace (repository)
Ingestion File
Log Level
Additional CLI flags
Use this field to run the gitleaks scanner with additional CLI flags such as:
--redact --log-opts="-n 1000"
--redactredacts secrets in the log output.--log-optsnarrows the range of commits that Gitleaks scans in a Pull Request. For example,-n 1000limits the scan to the last 1000 commits. You can also scan a range of commits using a command such as:tool_args : --log-opts=="--all commitA..commitF"
Fail on Severity
Settings
You can also use this field to speed up your Gitleaks scans.
Additional Configuration
Advanced settings
Configure GitLeaks as a Built-in Scanner
The GitLeaks 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:
Search for Secret Detection in the step palette or navigate to the Built-in Scanners section and select the Secret Detection step.
Expand the Additional CLI Flags section if you want to configure optional CLI flags.
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
Gitleaks step configuration example for STO
Here's an example of a configured Gitleaks step.
Gitleaks ingestion pipeline example for STO
The following pipeline shows an end-to-end ingestion workflow. The pipeline consists of a Build stage with two steps:
A Run step that sends a
gitleaks detectcommand to the local Gitleaks container to scan the codebase specified for the pipeline. This command specifies the output file for the scan results:/shared/scan_results/sarif_simple.sarif.A Gitleaks step that auto-detects the data file type (SARIF) and then ingests and normalizes the data from the output file.
Gitleaks orchestration pipeline example for STO
The following pipeline illustrates an orchestration workflow where the Gitleaks step scans the codebase and ingests the results in one step.
Last updated
Was this helpful?