credlock 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- credlock-1.0.0/LICENSE +21 -0
- credlock-1.0.0/PKG-INFO +317 -0
- credlock-1.0.0/README.md +273 -0
- credlock-1.0.0/credlock/__init__.py +8 -0
- credlock-1.0.0/credlock/cli.py +244 -0
- credlock-1.0.0/credlock/config.py +95 -0
- credlock-1.0.0/credlock/formatter.py +231 -0
- credlock-1.0.0/credlock/git_hook.py +85 -0
- credlock-1.0.0/credlock/patterns.py +179 -0
- credlock-1.0.0/credlock/scanner.py +189 -0
- credlock-1.0.0/credlock/storage.py +134 -0
- credlock-1.0.0/credlock.egg-info/PKG-INFO +317 -0
- credlock-1.0.0/credlock.egg-info/SOURCES.txt +21 -0
- credlock-1.0.0/credlock.egg-info/dependency_links.txt +1 -0
- credlock-1.0.0/credlock.egg-info/entry_points.txt +2 -0
- credlock-1.0.0/credlock.egg-info/requires.txt +7 -0
- credlock-1.0.0/credlock.egg-info/top_level.txt +2 -0
- credlock-1.0.0/setup.cfg +4 -0
- credlock-1.0.0/setup.py +55 -0
- credlock-1.0.0/tests/__init__.py +1 -0
- credlock-1.0.0/tests/test_cli.py +159 -0
- credlock-1.0.0/tests/test_patterns.py +104 -0
- credlock-1.0.0/tests/test_scanner.py +221 -0
credlock-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Your Name
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
credlock-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: credlock
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: 🔐 Prevent accidental credential commits to Git
|
|
5
|
+
Home-page: https://github.com/yourusername/credlock
|
|
6
|
+
Author: Your Name
|
|
7
|
+
Author-email: your.email@example.com
|
|
8
|
+
Project-URL: Bug Reports, https://github.com/yourusername/credlock/issues
|
|
9
|
+
Project-URL: Source, https://github.com/yourusername/credlock
|
|
10
|
+
Keywords: security credential secret git pre-commit detection
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Development Status :: 4 - Beta
|
|
18
|
+
Classifier: Environment :: Console
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: Topic :: Software Development :: Version Control
|
|
21
|
+
Classifier: Topic :: Security
|
|
22
|
+
Requires-Python: >=3.9
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: typer[all]>=0.9.0
|
|
26
|
+
Requires-Dist: rich>=13.7.0
|
|
27
|
+
Requires-Dist: pyyaml>=6.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
31
|
+
Dynamic: author
|
|
32
|
+
Dynamic: author-email
|
|
33
|
+
Dynamic: classifier
|
|
34
|
+
Dynamic: description
|
|
35
|
+
Dynamic: description-content-type
|
|
36
|
+
Dynamic: home-page
|
|
37
|
+
Dynamic: keywords
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
Dynamic: project-url
|
|
40
|
+
Dynamic: provides-extra
|
|
41
|
+
Dynamic: requires-dist
|
|
42
|
+
Dynamic: requires-python
|
|
43
|
+
Dynamic: summary
|
|
44
|
+
|
|
45
|
+
# CredLock 🔐
|
|
46
|
+
|
|
47
|
+
**Prevent accidental credential commits to Git**
|
|
48
|
+
|
|
49
|
+
CredLock is an automatic secret detection tool that scans your code before pushing to GitHub. It detects 50+ types of secrets (API keys, passwords, tokens, private keys) and blocks commits if sensitive data is found.
|
|
50
|
+
|
|
51
|
+
## 🎯 Features
|
|
52
|
+
|
|
53
|
+
- ✅ **50+ Detection Patterns**: Detects AWS keys, API tokens, passwords, database URLs, private keys, JWT tokens, and more
|
|
54
|
+
- ✅ **Automatic Git Integration**: Pre-commit hook runs automatically before every push
|
|
55
|
+
- ✅ **Zero Configuration**: Works out of the box, no complex setup
|
|
56
|
+
- ✅ **Beautiful Terminal Output**: Color-coded, formatted scan results
|
|
57
|
+
- ✅ **Scan History**: Tracks all scans locally in JSON format
|
|
58
|
+
- ✅ **Custom Patterns**: Add your own detection rules
|
|
59
|
+
- ✅ **Cross-Platform**: Works on macOS, Linux, and Windows
|
|
60
|
+
- ✅ **Fast**: Scans directories in milliseconds
|
|
61
|
+
|
|
62
|
+
## 📦 Installation
|
|
63
|
+
|
|
64
|
+
### From PyPI (Recommended)
|
|
65
|
+
```bash
|
|
66
|
+
pip install credlock
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### From Source
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/yourusername/credlock.git
|
|
72
|
+
cd credlock
|
|
73
|
+
pip install -e .
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 🚀 Quick Start
|
|
77
|
+
|
|
78
|
+
### 1. Install CredLock
|
|
79
|
+
```bash
|
|
80
|
+
pip install credlock
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 2. Setup Git Hook in Your Project
|
|
84
|
+
```bash
|
|
85
|
+
cd your-project
|
|
86
|
+
credlock setup-git
|
|
87
|
+
|
|
88
|
+
✅ Git pre-commit hook installed!
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### 3. That's It!
|
|
92
|
+
Now every time you `git push`, CredLock will automatically scan for secrets:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
$ git push origin main
|
|
96
|
+
|
|
97
|
+
🔍 Running CredLock...
|
|
98
|
+
✅ No secrets found. Push allowed!
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 📋 Commands
|
|
102
|
+
|
|
103
|
+
### Scan Directory
|
|
104
|
+
```bash
|
|
105
|
+
credlock scan # Scan current directory
|
|
106
|
+
credlock scan /path/to/dir # Scan specific directory
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### View Scan History
|
|
110
|
+
```bash
|
|
111
|
+
credlock history # Show last 10 scans
|
|
112
|
+
credlock history --limit=5 # Show last 5 scans
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Configure Settings
|
|
116
|
+
```bash
|
|
117
|
+
credlock configure # Interactive configuration
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Show Version
|
|
121
|
+
```bash
|
|
122
|
+
credlock --version
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## 🔍 What Does It Detect?
|
|
126
|
+
|
|
127
|
+
### AWS Credentials
|
|
128
|
+
- AWS Access Key ID: `AKIA...`
|
|
129
|
+
- AWS Secret Access Key
|
|
130
|
+
- AWS Config files
|
|
131
|
+
|
|
132
|
+
### API Keys
|
|
133
|
+
- Generic API keys
|
|
134
|
+
- GitHub tokens
|
|
135
|
+
- Stripe keys (live and test)
|
|
136
|
+
- Firebase keys
|
|
137
|
+
- SendGrid API keys
|
|
138
|
+
|
|
139
|
+
### Passwords & Secrets
|
|
140
|
+
- Password assignments
|
|
141
|
+
- Database URLs (MySQL, PostgreSQL, MongoDB)
|
|
142
|
+
- Private SSH keys
|
|
143
|
+
- JWT tokens
|
|
144
|
+
|
|
145
|
+
### Communication Tokens
|
|
146
|
+
- Slack tokens
|
|
147
|
+
- Discord webhooks
|
|
148
|
+
- Telegram tokens
|
|
149
|
+
|
|
150
|
+
### Cloud Providers
|
|
151
|
+
- Google Cloud credentials
|
|
152
|
+
- Azure keys
|
|
153
|
+
- DigitalOcean tokens
|
|
154
|
+
- Heroku API keys
|
|
155
|
+
|
|
156
|
+
### More
|
|
157
|
+
- Environment variables with secrets
|
|
158
|
+
- Authorization headers
|
|
159
|
+
- OAuth tokens
|
|
160
|
+
- **50+ total patterns**
|
|
161
|
+
|
|
162
|
+
## 📝 Example Output
|
|
163
|
+
|
|
164
|
+
### When Secrets Are Found
|
|
165
|
+
```
|
|
166
|
+
🔍 Scanning current directory...
|
|
167
|
+
|
|
168
|
+
⛔ SECRETS DETECTED! Found 3 potential secrets
|
|
169
|
+
|
|
170
|
+
📄 .env (2 secrets)
|
|
171
|
+
Line 2: [aws_access_key] AWS_ACCESS_KEY_ID=AKIA...
|
|
172
|
+
Line 3: [database_password] DB_PASSWORD=mysecret123
|
|
173
|
+
|
|
174
|
+
📄 src/config.js (1 secret)
|
|
175
|
+
Line 45: [stripe_key] API_KEY = "sk_live_4eC39HqLyjWDar..."
|
|
176
|
+
|
|
177
|
+
❌ PUSH BLOCKED - 3 SECRETS FOUND
|
|
178
|
+
|
|
179
|
+
Recommendations:
|
|
180
|
+
1. Move secrets to .env file
|
|
181
|
+
2. Add .env to .gitignore
|
|
182
|
+
3. Use environment variables in code
|
|
183
|
+
|
|
184
|
+
$ echo ".env" >> .gitignore
|
|
185
|
+
$ git rm --cached .env
|
|
186
|
+
$ git commit --amend
|
|
187
|
+
$ git push origin main
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### When No Secrets Found
|
|
191
|
+
```
|
|
192
|
+
🔍 Scanning current directory...
|
|
193
|
+
✅ No secrets found. Scan clean!
|
|
194
|
+
|
|
195
|
+
Files scanned: 15
|
|
196
|
+
Duration: 0.234 seconds
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## ⚙️ Configuration
|
|
200
|
+
|
|
201
|
+
CredLock is configured via `~/.credlock/config.yaml`:
|
|
202
|
+
|
|
203
|
+
```yaml
|
|
204
|
+
patterns_enabled: 50
|
|
205
|
+
custom_patterns: {}
|
|
206
|
+
ignored_files:
|
|
207
|
+
- .git/*
|
|
208
|
+
- node_modules/*
|
|
209
|
+
- __pycache__/*
|
|
210
|
+
auto_scan: true
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Add Custom Pattern
|
|
214
|
+
```bash
|
|
215
|
+
credlock configure
|
|
216
|
+
|
|
217
|
+
Choose: 1 (Add custom pattern)
|
|
218
|
+
Pattern name: my_api_key
|
|
219
|
+
Regex: MY_KEY_[A-Z0-9]{32}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## 🔒 Security Notes
|
|
223
|
+
|
|
224
|
+
- **Secrets are NOT stored**: CredLock only detects and blocks commits
|
|
225
|
+
- **No network calls**: Everything runs locally
|
|
226
|
+
- **Scan history is local**: Stored in `~/.credlock/history.json`
|
|
227
|
+
- **No data collection**: Your code never leaves your machine
|
|
228
|
+
|
|
229
|
+
## 📚 How It Works
|
|
230
|
+
|
|
231
|
+
1. **Pre-commit Hook**: Git runs CredLock before every push
|
|
232
|
+
2. **File Scanning**: Reads all project files (respects .gitignore)
|
|
233
|
+
3. **Pattern Matching**: Uses 50+ regex patterns to detect secrets
|
|
234
|
+
4. **Reporting**: Shows findings with file names and line numbers
|
|
235
|
+
5. **Exit Code**: Returns 1 if secrets found (blocks push), 0 if clean
|
|
236
|
+
|
|
237
|
+
## 🐛 Troubleshooting
|
|
238
|
+
|
|
239
|
+
### "credlock: command not found"
|
|
240
|
+
Ensure CredLock is installed globally:
|
|
241
|
+
```bash
|
|
242
|
+
pip install credlock
|
|
243
|
+
which credlock # Should show /path/to/credlock
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Pre-commit hook not running
|
|
247
|
+
Check hook is installed and executable:
|
|
248
|
+
```bash
|
|
249
|
+
cat .git/hooks/pre-commit
|
|
250
|
+
chmod +x .git/hooks/pre-commit
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### False positives (normal code flagged as secret)
|
|
254
|
+
Add custom ignore patterns in config:
|
|
255
|
+
```bash
|
|
256
|
+
credlock configure
|
|
257
|
+
# Choose to disable specific patterns
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Want to force push anyway?
|
|
261
|
+
You can temporarily bypass CredLock:
|
|
262
|
+
```bash
|
|
263
|
+
# This skips the pre-commit hook
|
|
264
|
+
git push --no-verify
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
But don't make this a habit! 🚨
|
|
268
|
+
|
|
269
|
+
## 📊 Performance
|
|
270
|
+
|
|
271
|
+
- Scans 100+ files in **<1 second**
|
|
272
|
+
- Minimal CPU/memory overhead
|
|
273
|
+
- No impact on normal Git workflow
|
|
274
|
+
|
|
275
|
+
## 🤝 Contributing
|
|
276
|
+
|
|
277
|
+
Found a bug? Want to add more patterns? Contributions welcome!
|
|
278
|
+
|
|
279
|
+
1. Fork the repository
|
|
280
|
+
2. Create a branch: `git checkout -b feature/new-pattern`
|
|
281
|
+
3. Add tests for new patterns
|
|
282
|
+
4. Submit a pull request
|
|
283
|
+
|
|
284
|
+
## 📜 License
|
|
285
|
+
|
|
286
|
+
MIT License - see LICENSE file for details
|
|
287
|
+
|
|
288
|
+
## ⭐ Support
|
|
289
|
+
|
|
290
|
+
- **Documentation**: Read this README
|
|
291
|
+
- **Issues**: Report bugs on GitHub
|
|
292
|
+
- **Discussions**: Ask questions in GitHub Discussions
|
|
293
|
+
|
|
294
|
+
## 🎓 Interview Points
|
|
295
|
+
|
|
296
|
+
When asked about CredLock:
|
|
297
|
+
|
|
298
|
+
- **"What problem does it solve?"** → Prevents accidental secret commits, which happen all the time
|
|
299
|
+
- **"How does it work?"** → Git pre-commit hook + regex pattern matching
|
|
300
|
+
- **"Why local storage?"** → Fast, no dependencies, users control their data
|
|
301
|
+
- **"How is it different?"** → Better UX than existing tools, modern CLI, easy setup
|
|
302
|
+
- **"What's the hardest part?"** → Balancing security (not too many patterns) with usability (not too many false positives)
|
|
303
|
+
|
|
304
|
+
## 📈 Future Enhancements
|
|
305
|
+
|
|
306
|
+
- [ ] Team shared config (EnvVault integration)
|
|
307
|
+
- [ ] Real-time monitoring dashboard
|
|
308
|
+
- [ ] Slack/email notifications
|
|
309
|
+
- [ ] Repository statistics
|
|
310
|
+
- [ ] CI/CD pipeline integration
|
|
311
|
+
- [ ] Custom rule templates
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
Made with ❤️ for developers who value security
|
|
316
|
+
|
|
317
|
+
**Star this repo if you found it useful!** ⭐
|
credlock-1.0.0/README.md
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# CredLock 🔐
|
|
2
|
+
|
|
3
|
+
**Prevent accidental credential commits to Git**
|
|
4
|
+
|
|
5
|
+
CredLock is an automatic secret detection tool that scans your code before pushing to GitHub. It detects 50+ types of secrets (API keys, passwords, tokens, private keys) and blocks commits if sensitive data is found.
|
|
6
|
+
|
|
7
|
+
## 🎯 Features
|
|
8
|
+
|
|
9
|
+
- ✅ **50+ Detection Patterns**: Detects AWS keys, API tokens, passwords, database URLs, private keys, JWT tokens, and more
|
|
10
|
+
- ✅ **Automatic Git Integration**: Pre-commit hook runs automatically before every push
|
|
11
|
+
- ✅ **Zero Configuration**: Works out of the box, no complex setup
|
|
12
|
+
- ✅ **Beautiful Terminal Output**: Color-coded, formatted scan results
|
|
13
|
+
- ✅ **Scan History**: Tracks all scans locally in JSON format
|
|
14
|
+
- ✅ **Custom Patterns**: Add your own detection rules
|
|
15
|
+
- ✅ **Cross-Platform**: Works on macOS, Linux, and Windows
|
|
16
|
+
- ✅ **Fast**: Scans directories in milliseconds
|
|
17
|
+
|
|
18
|
+
## 📦 Installation
|
|
19
|
+
|
|
20
|
+
### From PyPI (Recommended)
|
|
21
|
+
```bash
|
|
22
|
+
pip install credlock
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### From Source
|
|
26
|
+
```bash
|
|
27
|
+
git clone https://github.com/yourusername/credlock.git
|
|
28
|
+
cd credlock
|
|
29
|
+
pip install -e .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🚀 Quick Start
|
|
33
|
+
|
|
34
|
+
### 1. Install CredLock
|
|
35
|
+
```bash
|
|
36
|
+
pip install credlock
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 2. Setup Git Hook in Your Project
|
|
40
|
+
```bash
|
|
41
|
+
cd your-project
|
|
42
|
+
credlock setup-git
|
|
43
|
+
|
|
44
|
+
✅ Git pre-commit hook installed!
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 3. That's It!
|
|
48
|
+
Now every time you `git push`, CredLock will automatically scan for secrets:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
$ git push origin main
|
|
52
|
+
|
|
53
|
+
🔍 Running CredLock...
|
|
54
|
+
✅ No secrets found. Push allowed!
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 📋 Commands
|
|
58
|
+
|
|
59
|
+
### Scan Directory
|
|
60
|
+
```bash
|
|
61
|
+
credlock scan # Scan current directory
|
|
62
|
+
credlock scan /path/to/dir # Scan specific directory
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### View Scan History
|
|
66
|
+
```bash
|
|
67
|
+
credlock history # Show last 10 scans
|
|
68
|
+
credlock history --limit=5 # Show last 5 scans
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Configure Settings
|
|
72
|
+
```bash
|
|
73
|
+
credlock configure # Interactive configuration
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Show Version
|
|
77
|
+
```bash
|
|
78
|
+
credlock --version
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 🔍 What Does It Detect?
|
|
82
|
+
|
|
83
|
+
### AWS Credentials
|
|
84
|
+
- AWS Access Key ID: `AKIA...`
|
|
85
|
+
- AWS Secret Access Key
|
|
86
|
+
- AWS Config files
|
|
87
|
+
|
|
88
|
+
### API Keys
|
|
89
|
+
- Generic API keys
|
|
90
|
+
- GitHub tokens
|
|
91
|
+
- Stripe keys (live and test)
|
|
92
|
+
- Firebase keys
|
|
93
|
+
- SendGrid API keys
|
|
94
|
+
|
|
95
|
+
### Passwords & Secrets
|
|
96
|
+
- Password assignments
|
|
97
|
+
- Database URLs (MySQL, PostgreSQL, MongoDB)
|
|
98
|
+
- Private SSH keys
|
|
99
|
+
- JWT tokens
|
|
100
|
+
|
|
101
|
+
### Communication Tokens
|
|
102
|
+
- Slack tokens
|
|
103
|
+
- Discord webhooks
|
|
104
|
+
- Telegram tokens
|
|
105
|
+
|
|
106
|
+
### Cloud Providers
|
|
107
|
+
- Google Cloud credentials
|
|
108
|
+
- Azure keys
|
|
109
|
+
- DigitalOcean tokens
|
|
110
|
+
- Heroku API keys
|
|
111
|
+
|
|
112
|
+
### More
|
|
113
|
+
- Environment variables with secrets
|
|
114
|
+
- Authorization headers
|
|
115
|
+
- OAuth tokens
|
|
116
|
+
- **50+ total patterns**
|
|
117
|
+
|
|
118
|
+
## 📝 Example Output
|
|
119
|
+
|
|
120
|
+
### When Secrets Are Found
|
|
121
|
+
```
|
|
122
|
+
🔍 Scanning current directory...
|
|
123
|
+
|
|
124
|
+
⛔ SECRETS DETECTED! Found 3 potential secrets
|
|
125
|
+
|
|
126
|
+
📄 .env (2 secrets)
|
|
127
|
+
Line 2: [aws_access_key] AWS_ACCESS_KEY_ID=AKIA...
|
|
128
|
+
Line 3: [database_password] DB_PASSWORD=mysecret123
|
|
129
|
+
|
|
130
|
+
📄 src/config.js (1 secret)
|
|
131
|
+
Line 45: [stripe_key] API_KEY = "sk_live_4eC39HqLyjWDar..."
|
|
132
|
+
|
|
133
|
+
❌ PUSH BLOCKED - 3 SECRETS FOUND
|
|
134
|
+
|
|
135
|
+
Recommendations:
|
|
136
|
+
1. Move secrets to .env file
|
|
137
|
+
2. Add .env to .gitignore
|
|
138
|
+
3. Use environment variables in code
|
|
139
|
+
|
|
140
|
+
$ echo ".env" >> .gitignore
|
|
141
|
+
$ git rm --cached .env
|
|
142
|
+
$ git commit --amend
|
|
143
|
+
$ git push origin main
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### When No Secrets Found
|
|
147
|
+
```
|
|
148
|
+
🔍 Scanning current directory...
|
|
149
|
+
✅ No secrets found. Scan clean!
|
|
150
|
+
|
|
151
|
+
Files scanned: 15
|
|
152
|
+
Duration: 0.234 seconds
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## ⚙️ Configuration
|
|
156
|
+
|
|
157
|
+
CredLock is configured via `~/.credlock/config.yaml`:
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
patterns_enabled: 50
|
|
161
|
+
custom_patterns: {}
|
|
162
|
+
ignored_files:
|
|
163
|
+
- .git/*
|
|
164
|
+
- node_modules/*
|
|
165
|
+
- __pycache__/*
|
|
166
|
+
auto_scan: true
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Add Custom Pattern
|
|
170
|
+
```bash
|
|
171
|
+
credlock configure
|
|
172
|
+
|
|
173
|
+
Choose: 1 (Add custom pattern)
|
|
174
|
+
Pattern name: my_api_key
|
|
175
|
+
Regex: MY_KEY_[A-Z0-9]{32}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## 🔒 Security Notes
|
|
179
|
+
|
|
180
|
+
- **Secrets are NOT stored**: CredLock only detects and blocks commits
|
|
181
|
+
- **No network calls**: Everything runs locally
|
|
182
|
+
- **Scan history is local**: Stored in `~/.credlock/history.json`
|
|
183
|
+
- **No data collection**: Your code never leaves your machine
|
|
184
|
+
|
|
185
|
+
## 📚 How It Works
|
|
186
|
+
|
|
187
|
+
1. **Pre-commit Hook**: Git runs CredLock before every push
|
|
188
|
+
2. **File Scanning**: Reads all project files (respects .gitignore)
|
|
189
|
+
3. **Pattern Matching**: Uses 50+ regex patterns to detect secrets
|
|
190
|
+
4. **Reporting**: Shows findings with file names and line numbers
|
|
191
|
+
5. **Exit Code**: Returns 1 if secrets found (blocks push), 0 if clean
|
|
192
|
+
|
|
193
|
+
## 🐛 Troubleshooting
|
|
194
|
+
|
|
195
|
+
### "credlock: command not found"
|
|
196
|
+
Ensure CredLock is installed globally:
|
|
197
|
+
```bash
|
|
198
|
+
pip install credlock
|
|
199
|
+
which credlock # Should show /path/to/credlock
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Pre-commit hook not running
|
|
203
|
+
Check hook is installed and executable:
|
|
204
|
+
```bash
|
|
205
|
+
cat .git/hooks/pre-commit
|
|
206
|
+
chmod +x .git/hooks/pre-commit
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### False positives (normal code flagged as secret)
|
|
210
|
+
Add custom ignore patterns in config:
|
|
211
|
+
```bash
|
|
212
|
+
credlock configure
|
|
213
|
+
# Choose to disable specific patterns
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Want to force push anyway?
|
|
217
|
+
You can temporarily bypass CredLock:
|
|
218
|
+
```bash
|
|
219
|
+
# This skips the pre-commit hook
|
|
220
|
+
git push --no-verify
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
But don't make this a habit! 🚨
|
|
224
|
+
|
|
225
|
+
## 📊 Performance
|
|
226
|
+
|
|
227
|
+
- Scans 100+ files in **<1 second**
|
|
228
|
+
- Minimal CPU/memory overhead
|
|
229
|
+
- No impact on normal Git workflow
|
|
230
|
+
|
|
231
|
+
## 🤝 Contributing
|
|
232
|
+
|
|
233
|
+
Found a bug? Want to add more patterns? Contributions welcome!
|
|
234
|
+
|
|
235
|
+
1. Fork the repository
|
|
236
|
+
2. Create a branch: `git checkout -b feature/new-pattern`
|
|
237
|
+
3. Add tests for new patterns
|
|
238
|
+
4. Submit a pull request
|
|
239
|
+
|
|
240
|
+
## 📜 License
|
|
241
|
+
|
|
242
|
+
MIT License - see LICENSE file for details
|
|
243
|
+
|
|
244
|
+
## ⭐ Support
|
|
245
|
+
|
|
246
|
+
- **Documentation**: Read this README
|
|
247
|
+
- **Issues**: Report bugs on GitHub
|
|
248
|
+
- **Discussions**: Ask questions in GitHub Discussions
|
|
249
|
+
|
|
250
|
+
## 🎓 Interview Points
|
|
251
|
+
|
|
252
|
+
When asked about CredLock:
|
|
253
|
+
|
|
254
|
+
- **"What problem does it solve?"** → Prevents accidental secret commits, which happen all the time
|
|
255
|
+
- **"How does it work?"** → Git pre-commit hook + regex pattern matching
|
|
256
|
+
- **"Why local storage?"** → Fast, no dependencies, users control their data
|
|
257
|
+
- **"How is it different?"** → Better UX than existing tools, modern CLI, easy setup
|
|
258
|
+
- **"What's the hardest part?"** → Balancing security (not too many patterns) with usability (not too many false positives)
|
|
259
|
+
|
|
260
|
+
## 📈 Future Enhancements
|
|
261
|
+
|
|
262
|
+
- [ ] Team shared config (EnvVault integration)
|
|
263
|
+
- [ ] Real-time monitoring dashboard
|
|
264
|
+
- [ ] Slack/email notifications
|
|
265
|
+
- [ ] Repository statistics
|
|
266
|
+
- [ ] CI/CD pipeline integration
|
|
267
|
+
- [ ] Custom rule templates
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
Made with ❤️ for developers who value security
|
|
272
|
+
|
|
273
|
+
**Star this repo if you found it useful!** ⭐
|