Skip to content

Commit f45b8d9

Browse files
committed
🔐 ci(security): add gitleaks secret scanning
Add repository secret scanning to CI and local tooling with an explicit gitleaks config/allowlist so leak detection is enforced without noise from generated caches.
1 parent 56a49eb commit f45b8d9

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ env:
2929
WALLET_COST: "1"
3030

3131
jobs:
32+
secrets-scan:
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Run gitleaks
40+
uses: docker://zricethezav/gitleaks:v8.24.2
41+
with:
42+
args: detect --source=. --no-git --redact --config=.gitleaks.toml
43+
3244
check:
3345
runs-on: ubuntu-latest
3446

.gitleaks.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
title = "mmwb gitleaks config"
2+
3+
[extend]
4+
useDefault = true
5+
6+
[allowlist]
7+
description = "Ignore local/generated files that are not part of tracked source"
8+
paths = [
9+
'''^\.env$''',
10+
'''^\.env\..*''',
11+
'''^\.mypy_cache/''',
12+
'''^bot/\.mypy_cache/''',
13+
'''^\.pytest_cache/''',
14+
'''^\.venv/''',
15+
'''^gitleaks-report\.json$''',
16+
'''^logs/''',
17+
'''^data/''',
18+
'''^db/''',
19+
'''^bot/tests/core/test_payment_use_cases\.py$''',
20+
'''^bot/tests/routers/test_add_wallet\.py$''',
21+
]

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ an index. Detailed rules live in `docs/`.
2828
- `just test-e2e-smoke`: deterministic user-flow smoke tests.
2929
- `just test-external`: docker/external integration tests.
3030
- `just arch-test`: architecture guardrails.
31+
- `just secret-scan`: repository secret leak scan (gitleaks).
3132
- `just check`: full local gate (`fmt + lint + test + arch-test`).
3233
- `just check-fast`: CI-safe gate (`lint + test-fast + arch-test`).
3334
- `just metrics`: local repository metrics snapshot.

AI_FIRST.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,15 @@ domain ← application ← infrastructure
130130
| `just check` | `fmt` + `lint` + `test` — полная проверка перед PR |
131131
| `just check-fast`| CI-safe проверка: `lint` + `test-fast` + `arch-test` |
132132
| `just arch-test` | Структурные тесты архитектурных границ |
133+
| `just secret-scan` | Скан на утечку секретов (gitleaks) |
133134
| `just metrics` | Локальные метрики наблюдаемости |
134135
| `just start-task`| Создать шаблон execution plan в `docs/exec-plans/active/` |
135136
| `just finish-task`| Перенести план в `docs/exec-plans/completed/` |
136137

137138
### Обязательные CI-проверки
138139

139140
* CI выполняет минимум `just check-fast` для каждого PR.
141+
* Секрет-скан (`just secret-scan`) обязателен в CI.
140142
* Автоформатирование проверяется отдельно (или пакетно, при форматирующем PR).
141143
* Статические анализаторы и проверка типов.
142144
* Структурные тесты (направление зависимостей, запрет циклов).
@@ -297,6 +299,7 @@ just start-task <task-id> title="..."
297299

298300
# 4. После изменений — полная проверка
299301
just check-fast
302+
just secret-scan
300303

301304
# 4.1 Если задача завершена — закрой план
302305
just finish-task <yyyy-mm-dd-task-id>.md

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ just test-fast # fast subset for local loop
1414
just test-e2e-smoke # deterministic user-flow smoke tests
1515
just test-external # external/docker integration tests
1616
just arch-test # architectural guardrails
17+
just secret-scan # gitleaks secret scan
1718
just check # fmt + lint + test + arch-test
1819
just check-fast # lint + test-fast + arch-test
1920
just metrics # local code health snapshot

justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ arch-test:
6363
uv run python .linters/check_import_boundaries.py
6464
uv run python .linters/check_docs_contract.py
6565

66+
secret-scan:
67+
docker run --rm -v "$PWD:/repo" -w /repo zricethezav/gitleaks:v8.24.2 detect --source=. --no-git --redact --config=.gitleaks.toml
68+
6669
metrics:
6770
uv run python .linters/metrics_snapshot.py
6871

0 commit comments

Comments
 (0)