Skip to content

Commit 4e62bd6

Browse files
committed
feat(security): add gitleaks for secret detection
Integrate gitleaks to detect and prevent secrets from being committed: - Add .gitleaks.toml configuration with default rules - Add gitleaks to pre-commit hook via lefthook (runs first in pipeline) - Add gitleaks job to CI workflow using gitleaks-action - Add gitleaks to nix flake for local development This replaces secretlint with a more widely adopted solution that provides comprehensive detection of API keys, tokens, and credentials.
1 parent a9bbed8 commit 4e62bd6

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ permissions:
1616
id-token: write
1717

1818
jobs:
19+
gitleaks:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Run Gitleaks
28+
uses: gitleaks/gitleaks-action@ff98106e4c7b2bc287b24eaf42907196329070c7 # v2.3.9
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
1932
typos:
2033
runs-on: ubuntu-latest
2134
steps:

.gitleaks.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Gitleaks configuration
2+
# https://github.com/gitleaks/gitleaks
3+
4+
[extend]
5+
useDefault = true
6+
7+
[allowlist]
8+
description = "Global allowlist"
9+
paths = [
10+
'''\.lock$''',
11+
'''\.snap$''',
12+
'''go\.sum$''',
13+
'''pnpm-lock\.yaml$''',
14+
]

flake.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
nixfmt-rfc-style
3030
typos
3131
typos-lsp
32+
33+
# security
34+
gitleaks
3235
];
3336

3437
shellHook = ''

lefthook.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
pre-commit:
22
piped: true
33
jobs:
4+
- name: gitleaks
5+
run: gitleaks protect --staged --config .gitleaks.toml
46
- name: oxlint
57
glob: '*.{ts,tsx,js,jsx,mts,cts}'
68
run: pnpm oxlint --max-warnings=0 --type-aware --type-check --fix {staged_files}

0 commit comments

Comments
 (0)