Skip to content

Commit 5841c51

Browse files
authored
Merge pull request #923 from rackerlabs/truffles
feat: scan commits for accidentally leaked secrets
2 parents f8e107c + eccef9b commit 5841c51

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

.github/workflows/trufflehog.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Secrets scanning
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
workflow_dispatch:
8+
merge_group:
9+
types: [checks_requested]
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- shell: bash
16+
run: |
17+
if [ "${{ github.event_name }}" == "push" ]; then
18+
echo "depth=$(($(jq length <<< '${{ toJson(github.event.commits) }}') + 2))" >> $GITHUB_ENV
19+
echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV
20+
fi
21+
if [ "${{ github.event_name }}" == "pull_request" ]; then
22+
echo "depth=$((${{ github.event.pull_request.commits }}+2))" >> $GITHUB_ENV
23+
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
24+
fi
25+
- uses: actions/checkout@v4
26+
with:
27+
ref: ${{env.branch}}
28+
fetch-depth: ${{env.depth}}
29+
- name: Secret Scanning
30+
uses: trufflesecurity/trufflehog@main
31+
with:
32+
extra_args: --results=verified,unknown

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,13 @@ repos:
9494
- "requests"
9595
- "sushy"
9696
- "types-requests"
97+
- repo: local
98+
hooks:
99+
- id: trufflehog
100+
name: TruffleHog
101+
description: Detect secrets in your data.
102+
# uncomment this if you don't want to use docker version
103+
# entry: bash -c 'trufflehog --no-update git file://. --since-commit HEAD --results=verified,unknown --fail'
104+
entry: bash -c 'docker run --rm -v "$(pwd):/workdir" -i --rm trufflesecurity/trufflehog:latest git file:///workdir --since-commit HEAD --results=verified,unknown --fail'
105+
language: system
106+
stages: ["pre-commit", "pre-push"]

0 commit comments

Comments
 (0)