Skip to content

Commit 3030623

Browse files
committed
Add secret scanning to repo
1 parent aba2494 commit 3030623

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

.github/workflows/pre_commit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ jobs:
1919
with:
2020
python-version: '3.9'
2121
- uses: pre-commit/[email protected]
22+
env:
23+
SKIP: "trufflehog"

.github/workflows/secret_scanning.yml

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

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
default_language_version:
22
python: python3.9
33
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: "v5.0.0"
6+
hooks:
7+
- id: no-commit-to-branch
48
- repo: https://github.com/astral-sh/ruff-pre-commit
59
rev: 'v0.8.0'
610
hooks:
711
- id: ruff
812
args: [ "--fix" ]
913
- id: ruff-format
14+
- repo: https://github.com/trufflesecurity/trufflehog.git
15+
rev: "v3.84.2"
16+
hooks:
17+
- id: trufflehog
18+
name: TruffleHog
19+
description: Detect secrets in your data.
20+
entry: bash -c 'trufflehog git file://. --since-commit HEAD --only-verified --fail --no-update'
21+
language: system
22+
stages: ["pre-commit", "pre-push"]

0 commit comments

Comments
 (0)