Skip to content

Commit 40fb7e6

Browse files
committed
config: Add various pre-commit hooks (#33)
1 parent c59ab99 commit 40fb7e6

5 files changed

Lines changed: 194 additions & 2 deletions

File tree

.pre-commit-config.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: check-added-large-files
6+
description: Prevents adding large files to the repository
7+
- id: check-merge-conflict
8+
description: Prevents adding files with merge conflict markers
9+
- id: check-toml
10+
description: Checks TOML files for syntax errors
11+
- id: name-tests-test
12+
description: Checks that test files are named correctly
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
rev: v0.8.2
15+
hooks:
16+
# Run the linter.
17+
- id: ruff
18+
types_or: [python, pyi]
19+
args: [--fix]
20+
# Run the formatter.
21+
- id: ruff-format
22+
types_or: [python, pyi]
23+
- repo: https://github.com/PyCQA/bandit
24+
rev: 1.8.0
25+
hooks:
26+
- id: bandit
27+
description: Checks Python code for security issues
28+
- repo: https://github.com/Yelp/detect-secrets
29+
rev: v1.5.0
30+
hooks:
31+
- id: detect-secrets
32+
args: ["--baseline", ".secrets.baseline"]
33+
# exclude: some_file.py

.secrets.baseline

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
{
2+
"version": "1.5.0",
3+
"plugins_used": [
4+
{
5+
"name": "ArtifactoryDetector"
6+
},
7+
{
8+
"name": "AWSKeyDetector"
9+
},
10+
{
11+
"name": "AzureStorageKeyDetector"
12+
},
13+
{
14+
"name": "Base64HighEntropyString",
15+
"limit": 4.5
16+
},
17+
{
18+
"name": "BasicAuthDetector"
19+
},
20+
{
21+
"name": "CloudantDetector"
22+
},
23+
{
24+
"name": "DiscordBotTokenDetector"
25+
},
26+
{
27+
"name": "GitHubTokenDetector"
28+
},
29+
{
30+
"name": "GitLabTokenDetector"
31+
},
32+
{
33+
"name": "HexHighEntropyString",
34+
"limit": 3.0
35+
},
36+
{
37+
"name": "IbmCloudIamDetector"
38+
},
39+
{
40+
"name": "IbmCosHmacDetector"
41+
},
42+
{
43+
"name": "IPPublicDetector"
44+
},
45+
{
46+
"name": "JwtTokenDetector"
47+
},
48+
{
49+
"name": "KeywordDetector",
50+
"keyword_exclude": ""
51+
},
52+
{
53+
"name": "MailchimpDetector"
54+
},
55+
{
56+
"name": "NpmDetector"
57+
},
58+
{
59+
"name": "OpenAIDetector"
60+
},
61+
{
62+
"name": "PrivateKeyDetector"
63+
},
64+
{
65+
"name": "PypiTokenDetector"
66+
},
67+
{
68+
"name": "SendGridDetector"
69+
},
70+
{
71+
"name": "SlackDetector"
72+
},
73+
{
74+
"name": "SoftlayerDetector"
75+
},
76+
{
77+
"name": "SquareOAuthDetector"
78+
},
79+
{
80+
"name": "StripeDetector"
81+
},
82+
{
83+
"name": "TelegramBotTokenDetector"
84+
},
85+
{
86+
"name": "TwilioKeyDetector"
87+
}
88+
],
89+
"filters_used": [
90+
{
91+
"path": "detect_secrets.filters.allowlist.is_line_allowlisted"
92+
},
93+
{
94+
"path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
95+
"min_level": 2
96+
},
97+
{
98+
"path": "detect_secrets.filters.heuristic.is_indirect_reference"
99+
},
100+
{
101+
"path": "detect_secrets.filters.heuristic.is_likely_id_string"
102+
},
103+
{
104+
"path": "detect_secrets.filters.heuristic.is_lock_file"
105+
},
106+
{
107+
"path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
108+
},
109+
{
110+
"path": "detect_secrets.filters.heuristic.is_potential_uuid"
111+
},
112+
{
113+
"path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
114+
},
115+
{
116+
"path": "detect_secrets.filters.heuristic.is_sequential_string"
117+
},
118+
{
119+
"path": "detect_secrets.filters.heuristic.is_swagger_file"
120+
},
121+
{
122+
"path": "detect_secrets.filters.heuristic.is_templated_secret"
123+
}
124+
],
125+
"results": {
126+
".env.sample": [
127+
{
128+
"type": "Secret Keyword",
129+
"filename": ".env.sample",
130+
"hashed_secret": "57f319532cf4f5f2f506b9d546524ce8d1fed6e9",
131+
"is_verified": false,
132+
"line_number": 2
133+
},
134+
{
135+
"type": "Secret Keyword",
136+
"filename": ".env.sample",
137+
"hashed_secret": "b60d121b438a380c343d5ec3c2037564b82ffef3",
138+
"is_verified": false,
139+
"line_number": 5
140+
}
141+
],
142+
"docker-compose.yml": [
143+
{
144+
"type": "Secret Keyword",
145+
"filename": "docker-compose.yml",
146+
"hashed_secret": "57f319532cf4f5f2f506b9d546524ce8d1fed6e9",
147+
"is_verified": false,
148+
"line_number": 11
149+
}
150+
]
151+
},
152+
"generated_at": "2024-12-10T17:38:23Z"
153+
}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
## Installation et lancement
44

55
```sh
6-
poetry shell
7-
poetry install
6+
make install
7+
pre-commit run --all-files
88
poetry run start # or poetry run python -m srdt_analysis
99
ruff check --fix
1010
ruff format

makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
install:
2+
poetry install
3+
poetry run pre-commit install --allow-missing-config -f
4+
poetry run detect-secrets scan > .secrets.baseline

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ python-dotenv = "^1.0.1"
1212
httpx = "^0.27.2"
1313
pandas = "^2.2.3"
1414
langchain-text-splitters = "^0.3.2"
15+
detect-secrets = "^1.5.0"
16+
pre-commit = "^4.0.1"
1517

1618
[tool.poetry.group.dev.dependencies]
1719
pyright = "^1.1.389"

0 commit comments

Comments
 (0)