Skip to content

Commit 57871d3

Browse files
committed
Add Gitleaks secrets scanning starter workflow
Adds a code-scanning workflow template for Gitleaks, an open-source SAST tool that detects hardcoded secrets (API keys, passwords, tokens) in Git history. Fills the secrets-detection gap in the code-scanning category. - Pins gitleaks/gitleaks-action to SHA for v2.3.9 per contributing guidelines - Fetches full Git history (fetch-depth: 0) so all commits are scanned - Outputs SARIF and uploads results to the GitHub Security tab - Documents the optional GITLEAKS_LICENSE for private org repositories - Uses least-privilege permissions (contents: read, security-events: write) https://claude.ai/code/session_01WzSXen2DnNGjMfcavyMuVt
1 parent affda94 commit 57871d3

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

code-scanning/gitleaks.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
# Gitleaks is an open-source SAST tool for detecting secrets (API keys,
7+
# passwords, tokens) committed to a Git repository.
8+
# See https://github.com/gitleaks/gitleaks
9+
10+
name: Gitleaks
11+
12+
on:
13+
push:
14+
branches: [ $default-branch, $protected-branches ]
15+
pull_request:
16+
# The branches below must be a subset of the branches above
17+
branches: [ $default-branch ]
18+
schedule:
19+
- cron: $cron-daily
20+
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
gitleaks:
26+
permissions:
27+
contents: read # for actions/checkout to fetch code
28+
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
29+
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
with:
35+
# Fetch full history so Gitleaks can scan all commits, not just HEAD
36+
fetch-depth: 0
37+
38+
- name: Run Gitleaks
39+
uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2.3.9
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
# GITLEAKS_LICENSE is required for scanning private repositories in GitHub organizations.
43+
# Sign up at https://gitleaks.io to obtain a license key and add it as a repository secret.
44+
# GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }}
45+
with:
46+
args: --exit-code=0 --report-format=sarif --report-path=gitleaks.sarif
47+
48+
- name: Upload Gitleaks scan results to GitHub Security tab
49+
uses: github/codeql-action/upload-sarif@v3
50+
if: always()
51+
with:
52+
sarif_file: gitleaks.sarif
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "Gitleaks",
3+
"creator": "Gitleaks",
4+
"description": "Detect hardcoded secrets like passwords, API keys, and tokens in your Git repository using Gitleaks.",
5+
"iconName": "octicon key",
6+
"categories": ["Code Scanning", "Security"]
7+
}

0 commit comments

Comments
 (0)