-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
82 lines (71 loc) · 2.1 KB
/
.pre-commit-config.yaml
File metadata and controls
82 lines (71 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
repos:
# ----------------------------
# Formatting
# ----------------------------
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
language_version: python3.10
# ----------------------------
# Linting (hard errors only)
# ----------------------------
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
args:
- --count
- --select=E9,F63,F7,F82
- --show-source
- --statistics
# ----------------------------
# Generic hygiene
# ----------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
- id: check-added-large-files
args: ["--maxkb=100"]
# ----------------------------
# Project-specific hooks
# ----------------------------
- repo: local
hooks:
- id: pytest
name: pytest
entry: python -c "import os,sys,pytest; os.environ['PYTHONPATH']='src'; sys.exit(pytest.main(['-q']))"
language: system
pass_filenames: false
- id: secret-scan
name: simple secret scan
entry: |
python - <<'EOF'
import sys, re, pathlib
patterns = [
re.compile(r"AIzaSy[A-Za-z0-9_-]{33}"),
re.compile(r"client_secrets\.json"),
re.compile(r"oauth", re.I),
]
bad = False
for p in pathlib.Path(".").rglob("*"):
if not p.is_file():
continue
if p.suffix in {".pyc", ".png", ".jpg", ".jpeg", ".gif"}:
continue
try:
text = p.read_text(errors="ignore")
except Exception:
continue
for pat in patterns:
if pat.search(text):
print(f"Secret pattern found in {p}")
bad = True
sys.exit(1 if bad else 0)
EOF
language: system
pass_filenames: false