Skip to content

Commit

Permalink
Add secret scanning to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank-Howard committed Dec 13, 2024
1 parent aba2494 commit 3030623
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pre_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,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"]

0 comments on commit 3030623

Please sign in to comment.