Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Trufflehog to pre-commit #80

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/pre_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
workflow_dispatch:

name: Pre-commit

jobs:
pre_commit:
name: Pre-commit
Expand All @@ -19,3 +18,5 @@ jobs:
with:
python-version: '3.9'
- uses: pre-commit/[email protected]
env:
SKIP: "trufflehog"
30 changes: 30 additions & 0 deletions .github/workflows/secret_scanning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Secret Scanning"
on:
push:
branches:
- main
pull_request:
workflow_call:

jobs:
check_commits:
runs-on: ubuntu-latest
steps:
- name: Set depth and branch variables
run: |
if [ "${{ github.event_name }}" == "push" ]; then
echo "depth=$(($(jq length <<< '${{ toJson(github.event.commits) }}') + 2))" >> $GITHUB_ENV
echo "branch=${{ github.ref_name }}" >> $GITHUB_ENV
fi
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "depth=$((${{ github.event.pull_request.commits }}+2))" >> $GITHUB_ENV
echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
fi
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{env.branch}}
fetch-depth: ${{env.depth}}
- uses: trufflesecurity/trufflehog@main
with:
extra_args: --results=verified,unknown
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
default_language_version:
python: python3.9
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v5.0.0"
hooks:
- id: no-commit-to-branch
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.8.0'
hooks:
- id: ruff
args: [ "--fix" ]
- id: ruff-format
- repo: https://github.com/trufflesecurity/trufflehog.git
rev: "v3.84.2"
hooks:
- id: trufflehog
name: TruffleHog
description: Detect secrets in your data.
entry: bash -c 'trufflehog git file://. --since-commit HEAD --only-verified --fail --no-update'
language: system
stages: ["pre-commit", "pre-push"]
Loading