Trufflehog:ignore - Buildkite - Gh Action
Introduction
TruffleHog is a powerful tool for detecting secrets in code repositories. However, when using the trufflehog:ignore
feature in conjunction with the Buildkite detector, unexpected behavior can occur. In this article, we will delve into the issue and explore the necessary steps to reproduce and resolve it.
TruffleHog Version
The current version of TruffleHog being used is 3.88.15
, as indicated by the gh action
output.
Status: Downloaded newer image for ghcr.io/trufflesecurity/trufflehog:latest
gh action: trufflehog 3.88.15
Trace Output
For a more detailed understanding of the issue, please refer to the trace output provided in the GitHub Gist.
https://gist.github.com/sean-simmons-progress/d62a2103910865f54fd3c1f399d32641
Expected Behavior
When using the trufflehog:ignore
feature, it is expected that the specified file or line will be skipped, and the TruffleHog scan will continue without errors.
Actual Behavior
However, in this case, the TruffleHog scan fails due to an "unverified secret" error, even when the trufflehog:ignore
feature is used. This is because the PLUGIN_TOOL
environment variable is being detected as a secret, despite being a Git commit SHA used to checkout a specific version of a plugin.
Example Code
- foo-bar:
valuebool: true
fileDefinitio: .pathtoFile.yml
env:
- PLUGIN_TOOL: e5637ca1ed34a227eba86ae30761010f308b2d1b
Steps to Reproduce
To reproduce this issue, follow these steps:
- Setup a TruffleHog: Create a new TruffleHog instance and configure it to use the
trufflehog:ignore
feature. - Configure the Buildkite detector: Set up the Buildkite detector to exclude the
PLUGIN_TOOL
environment variable. - Run the TruffleHog scan: Run the TruffleHog scan with the
--exclude-detectors="Buildkite"
argument.
Additional Context
To resolve this issue, it is necessary to pass the --exclude-detectors="Buildkite"
argument to the TruffleHog scan. This can be achieved by modifying the extra_args
field in the workflow configuration.
name: trufflehog secret scan
on:
workflow_dispatch:
pull_request:
branches: [ main ]
jobs:
TruffleHog:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: TruffleHog secret scan
uses: trufflesecurity/trufflehog@main
with:
path: ./
extra_args: --log-level=5 --exclude-detectors="Buildkite"
continue-on-error: false
References
- #0000 (GitHub issue)
Introduction
In our previous article, we explored the issue with the trufflehog:ignore
feature and the Buildkite detector in TruffleHog. In this Q&A article, we will answer some of the most frequently asked questions related to this issue.
Q: What is the trufflehog:ignore
feature?
A: The trufflehog:ignore
feature is a way to exclude specific files or lines from the TruffleHog scan. This can be useful for ignoring false positives or excluding sensitive information.
Q: Why is the Buildkite detector detecting the PLUGIN_TOOL
environment variable as a secret?
A: The Buildkite detector is detecting the PLUGIN_TOOL
environment variable as a secret because it is a Git commit SHA used to checkout a specific version of a plugin. However, the TruffleHog scan is treating it as a secret due to a misconfiguration.
Q: How can I resolve this issue?
A: To resolve this issue, you need to pass the --exclude-detectors="Buildkite"
argument to the TruffleHog scan. This can be achieved by modifying the extra_args
field in the workflow configuration.
Q: What is the extra_args
field in the workflow configuration?
A: The extra_args
field in the workflow configuration is used to pass additional arguments to the TruffleHog scan. In this case, we are using it to exclude the Buildkite detector.
Q: How do I modify the extra_args
field in the workflow configuration?
A: To modify the extra_args
field in the workflow configuration, you need to update the trufflehog
step in your workflow file. Here is an example of how to do it:
name: trufflehog secret scan
on:
workflow_dispatch:
pull_request:
branches: [ main ]
jobs:
TruffleHog:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: TruffleHog secret scan
uses: trufflesecurity/trufflehog@main
with:
path: ./
extra_args: --log-level=5 --exclude-detectors="Buildkite"
continue-on-error: false
Q: What is the continue-on-error
field in the workflow configuration?
A: The continue-on-error
field in the workflow configuration is used to determine whether the workflow should continue running even if an error occurs. In this case, we are setting it to false
to ensure that the workflow fails if the TruffleHog scan encounters an error.
Q: How do I troubleshoot this issue?
A: To troubleshoot this issue, you can try the following:
- Check the TruffleHog logs for any errors or warnings.
- Verify that the
trufflehog:ignore
feature is correctly configured. - Ensure that the Buildkite detector is properly configured.
- Try running the TruffleHog scan with the
--log-level=5
argument to enable debug logging.
By following these steps and troubleshooting tips, you should be able to resolve the issue with the trufflehog:ignore
feature and the Buildkite detector in TruffleHog.