Skip to content

Commit 4c89e91

Browse files
authored
feat(security): add gitleaks for secret detection (#259)
* 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. * fix ignore
1 parent fb20944 commit 4c89e91

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ 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: Setup Nix
28+
uses: ./.github/actions/setup-nix
29+
30+
- name: Run Gitleaks
31+
run: nix develop --command gitleaks detect --source . --config .gitleaks.toml
32+
1933
typos:
2034
runs-on: ubuntu-latest
2135
steps:

.gitleaks.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
'''pnpm-lock\.yaml$''',
11+
]

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)