Skip to content

Commit 1a31baa

Browse files
authored
feat(security): add gitleaks for secret detection (#63)
Integrate gitleaks to detect and prevent secrets from being committed: - Add .gitleaks.toml configuration with default rules - Add gitleaks to pre-commit hook via git-hooks.nix - Add gitleaks job to CI workflow using nix - Add gitleaks command to justfile - Add gitleaks to nix flake for local development
1 parent 0ef05cf commit 1a31baa

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-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 just gitleaks
32+
1933
typos:
2034
runs-on: ubuntu-latest
2135
steps:

.gitleaks.toml

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

flake.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262
pre-commit = {
6363
check.enable = false; # Skip check in flake (mypy needs Python env)
6464
settings.hooks = {
65+
gitleaks = {
66+
enable = true;
67+
name = "gitleaks";
68+
entry = "${pkgs.gitleaks}/bin/gitleaks protect --staged --config .gitleaks.toml";
69+
language = "system";
70+
pass_filenames = false;
71+
};
6572
treefmt = {
6673
enable = true;
6774
package = config.treefmt.build.wrapper;
@@ -85,6 +92,9 @@
8592
typos
8693
typos-lsp
8794
basedpyright
95+
96+
# security
97+
gitleaks
8898
];
8999

90100
shellHook = ''

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ mypy:
3434
typos:
3535
typos --config typos.toml .
3636

37+
# Run gitleaks secret detection
38+
gitleaks:
39+
gitleaks detect --source . --config .gitleaks.toml
40+
3741
# Fix typos
3842
typos-fix:
3943
typos --config typos.toml --write-changes .

0 commit comments

Comments
 (0)