TruffleHog CI/CD integration with Snapsec VM
Use TruffleHog in your CI pipeline to scan your repositories for secrets (API keys, tokens, passwords, etc.) and then push the findings into Snapsec VM using a simple webhook. This guide shows you, step by step, how to:- Run
trufflehogin your GitHub Actions or GitLab CI pipeline. - Generate a JSON report.
- Send that JSON report directly to Snapsec VM using a webhook.
1. Prerequisites
- A Git repository you want to scan for secrets.
- TruffleHog installed in your CI environment (we’ll show how below).
- Snapsec:
- An Assessment in Snapsec VM where TruffleHog findings will be stored.
- Assessment ID (
<assessment-id>) - API key (
<your-api-key>)
- CI environment with
curlavailable.
2. Create an assessment in Snapsec VM
Before you send any results, create a dedicated assessment in Snapsec VM that will hold the TruffleHog findings:- Log in to the Snapsec UI.
- Go to the VM / Assessments section.
- Click New Assessment and give it a clear name, for example:
TruffleHog - Secrets Scan
- Save the assessment and copy its Assessment ID value.
3. Generate TruffleHog JSON report (locally or in CI)
To scan the current repository and output JSON:- Scans the local Git repository in the current directory.
- Writes findings as JSON lines to
trufflehog.json.
4. Push TruffleHog JSON directly to Snapsec VM via webhook
Snapsec already knows how to parse TruffleHog JSON output, so you can send the file directly to an import endpoint.Important: ReplaceBelow are ready-to-use examples for GitHub Actions and GitLab CI.<assessment-id>with your actual Assessment ID and<your-api-key>with your API key. Note on the-kflag: This flag tellscurlto perform an “insecure” SSL transfer, which bypasses certificate validation. You may need this for local or development environments. Remove it if your endpoint has a valid SSL certificate.
5. GitHub Actions example
- Create
.github/workflows/trufflehog-to-snapsec.ymlin your repository. - Copy the YAML above into that file.
- In your GitHub repository settings, create secrets:
SNAPSEC_ASSESSMENT_IDSNAPSEC_API_KEY
- Adjust any TruffleHog options (rules, allowlists, etc.) as needed.
- Push your changes. GitHub Actions will run the workflow on each push or pull request.
6. GitLab CI example
If you use GitLab, add a job like this to your.gitlab-ci.yml:
- Create or edit
.gitlab-ci.ymlin the root of your repository. - Add the
trufflehog_to_snapsecjob shown above. - In your GitLab project, go to Settings → CI/CD → Variables and add:
SNAPSEC_ASSESSMENT_IDSNAPSEC_API_KEY
- Commit and push your changes. GitLab will run the job on merge requests and on the
mainbranch.
- Run TruffleHog automatically in your pipeline.
- Upload the
trufflehog.jsonreport directly to Snapsec VM using the provided webhook.