Skip to content

Leaked Secrets Scan #248

Leaked Secrets Scan

Leaked Secrets Scan #248

name: Leaked Secrets Scan
on:
workflow_call:
secrets:
GITLEAKS_LICENSE:
required: false
schedule:
- cron: '0 3 * * *' # Daily at 3 AM UTC (3-4 AM UK time)
workflow_dispatch:
permissions:
contents: read
security-events: write
jobs:
gitleaks-licensed:
name: gitleaks (licensed)
runs-on: ubuntu-latest
steps:
- name: Check for license
id: license
run: |
if [ -n "$GITLEAKS_LICENSE" ]; then
echo "available=true" >> "$GITHUB_OUTPUT"
else
echo "available=false" >> "$GITHUB_OUTPUT"
echo "::notice::GITLEAKS_LICENSE not set — skipping licensed scan"
fi
env:
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
- uses: actions/checkout@v6
if: steps.license.outputs.available == 'true'
with:
fetch-depth: 0
- uses: gitleaks/gitleaks-action@v2
if: steps.license.outputs.available == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
gitleaks-cli:
name: gitleaks (CLI)
runs-on: ubuntu-latest
env:
GITLEAKS_VERSION: '8.30.0'
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install gitleaks
run: |
curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
| tar -xz -C /usr/local/bin gitleaks
gitleaks version
- name: Run gitleaks
run: gitleaks detect --source . --redact -c .gitleaks.toml -v --report-format sarif --report-path gitleaks-report.sarif
- name: Upload SARIF to code scanning
if: always()
uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: gitleaks-report.sarif
category: gitleaks
- name: Upload report
uses: actions/upload-artifact@v7
if: always()
with:
name: gitleaks-report
path: gitleaks-report.sarif
retention-days: 30