secretshield 0.4.0__tar.gz → 0.4.2__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.
Files changed (46) hide show
  1. secretshield-0.4.2/PKG-INFO +359 -0
  2. secretshield-0.4.2/README.md +333 -0
  3. {secretshield-0.4.0 → secretshield-0.4.2}/pyproject.toml +3 -2
  4. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/__init__.py +1 -1
  5. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/cli.py +19 -0
  6. secretshield-0.4.2/secretshield.egg-info/PKG-INFO +359 -0
  7. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield.egg-info/SOURCES.txt +1 -0
  8. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield.egg-info/entry_points.txt +1 -0
  9. secretshield-0.4.2/tests/test_ss_alias_and_creator.py +147 -0
  10. secretshield-0.4.0/PKG-INFO +0 -642
  11. secretshield-0.4.0/README.md +0 -616
  12. secretshield-0.4.0/secretshield.egg-info/PKG-INFO +0 -642
  13. {secretshield-0.4.0 → secretshield-0.4.2}/LICENSE +0 -0
  14. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/autofix/__init__.py +0 -0
  15. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/autofix/env.py +0 -0
  16. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/autofix/fixer.py +0 -0
  17. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/autofix/gitignore.py +0 -0
  18. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/autofix/python.py +0 -0
  19. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/baseline.py +0 -0
  20. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/config.py +0 -0
  21. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/detector.py +0 -0
  22. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/git/__init__.py +0 -0
  23. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/git/hooks.py +0 -0
  24. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/github/__init__.py +0 -0
  25. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/github/actions.py +0 -0
  26. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/guardian.py +0 -0
  27. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/notifications.py +0 -0
  28. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/patterns.py +0 -0
  29. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/project_config.py +0 -0
  30. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield/redactor.py +0 -0
  31. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield.egg-info/dependency_links.txt +0 -0
  32. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield.egg-info/requires.txt +0 -0
  33. {secretshield-0.4.0 → secretshield-0.4.2}/secretshield.egg-info/top_level.txt +0 -0
  34. {secretshield-0.4.0 → secretshield-0.4.2}/setup.cfg +0 -0
  35. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_autofix.py +0 -0
  36. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_baseline.py +0 -0
  37. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_detector.py +0 -0
  38. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_git_hooks.py +0 -0
  39. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_github_action.py +0 -0
  40. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_logging.py +0 -0
  41. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_project_config.py +0 -0
  42. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_redactor.py +0 -0
  43. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_scan.py +0 -0
  44. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_stdout.py +0 -0
  45. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_v030_cli_integration.py +0 -0
  46. {secretshield-0.4.0 → secretshield-0.4.2}/tests/test_v040_cli_integration.py +0 -0
@@ -0,0 +1,359 @@
1
+ Metadata-Version: 2.4
2
+ Name: secretshield
3
+ Version: 0.4.2
4
+ Summary: Stop secrets before they leak -- runtime redaction, multi-language scanning, auto-fix, Git hooks, and CI, all in one CLI.
5
+ Author: Samarth Chugh (Sam3360)
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Sam3360/secretshield
8
+ Project-URL: Repository, https://github.com/Sam3360/secretshield
9
+ Project-URL: Issues, https://github.com/Sam3360/secretshield/issues
10
+ Keywords: security,secrets,redaction,logging,stdout,credentials
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Security
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: tomli>=2.0; python_version < "3.11"
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7.0; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ <div align="center">
28
+
29
+ # 🛡️ SecretShield
30
+
31
+ **Your secrets shouldn't end up in your terminal, your logs, or your commit history.**
32
+ **SecretShield makes sure they don't — automatically.**
33
+
34
+ [![PyPI version](https://img.shields.io/pypi/v/secretshield?color=blue)](https://pypi.org/project/secretshield/)
35
+ [![Python versions](https://img.shields.io/pypi/pyversions/secretshield)](https://pypi.org/project/secretshield/)
36
+ [![PyPI downloads](https://img.shields.io/pypi/dm/secretshield)](https://pypi.org/project/secretshield/)
37
+ [![License: MIT](https://img.shields.io/pypi/l/secretshield)](LICENSE)
38
+
39
+ [Install](#installation) · [Demo](#demo) · [Quick start](#quick-start) · [Features](#what-secretshield-does) · [Docs below](#cli-reference)
40
+
41
+ </div>
42
+
43
+ ---
44
+
45
+ ## The problem
46
+
47
+ You've done this. Everyone has.
48
+
49
+ ```python
50
+ print("API key:", api_key) # ...now it's in your terminal history
51
+ logger.info("Token: %s", token) # ...now it's in your log files
52
+ API_KEY = "sk-live-abc123..." # ...now it's about to get committed
53
+ ```
54
+
55
+ One `print()` left in from debugging. One log line that dumps a config
56
+ dict. One hardcoded key that slips past code review. That's usually all
57
+ it takes.
58
+
59
+ ## The fix
60
+
61
+ ```bash
62
+ pip install secretshield
63
+ ```
64
+
65
+ ```python
66
+ import secretshield
67
+
68
+ api_key = "sk-example1234567890abcdefFAKEKEY"
69
+ print("API key:", api_key)
70
+ ```
71
+
72
+ ```text
73
+ API key: ********
74
+ ⚠ secretshield: Potential secret detected and redacted.
75
+ ```
76
+
77
+ **No configuration. No code changes. Just `pip install` and `import`.**
78
+ The moment you import it, your terminal output, your logs — protected.
79
+
80
+ ## Demo
81
+
82
+ See SecretShield in action:
83
+
84
+ [![SecretShield Demo](https://img.youtube.com/vi/g95lNIhWsXM/maxresdefault.jpg)](https://youtu.be/g95lNIhWsXM)
85
+
86
+ **[▶ Watch the full demo on YouTube](https://youtu.be/g95lNIhWsXM)**
87
+
88
+ ## Quick start
89
+
90
+ ```bash
91
+ pip install secretshield
92
+ ```
93
+
94
+ Protect a running script:
95
+ ```python
96
+ import secretshield # that's it — stdout, stderr, and logging are now protected
97
+ ```
98
+
99
+ Scan an entire project for hardcoded secrets:
100
+ ```bash
101
+ secretshield scan .
102
+ ```
103
+
104
+ Set a whole project up in one step (config file + Git hook + CI):
105
+ ```bash
106
+ secretshield init
107
+ ```
108
+
109
+ > Typing `secretshield` a lot? Every command also works with the short
110
+ > alias `ss` — `ss scan .`, `ss init`, `ss --fix`, all identical to
111
+ > their `secretshield` equivalents.
112
+
113
+ ## What SecretShield does
114
+
115
+ SecretShield isn't just one trick — it's five layers that cover the
116
+ whole path a secret takes from your keyboard to a place you can't take
117
+ it back from:
118
+
119
+ | | |
120
+ |---|---|
121
+ | 🖥️ **Runtime protection** | Automatically redacts secrets from `stdout`, `stderr`, and `logging` the instant you `import secretshield` |
122
+ | 🔍 **Static scanning** | `secretshield scan .` finds hardcoded secrets across Python, JS/TS, HTML, YAML, `.env`, and more |
123
+ | 🔧 **Auto-Fix** | `scan . --fix` interactively moves a hardcoded secret into `.env` and rewrites your code to use it — safely, and only when it's unambiguous |
124
+ | 🪝 **Git pre-commit hook** | `install-hook` blocks a commit before a secret ever reaches your repo's history |
125
+ | ⚙️ **GitHub Actions** | `github-action` generates a workflow that scans every push and PR automatically |
126
+
127
+ All of it: **zero required dependencies, no telemetry, no network calls, nothing sent anywhere.** Everything happens locally, in your own process.
128
+
129
+ ## Why star this repo
130
+
131
+ If SecretShield has ever caught something before it hit your terminal
132
+ or your Git history — that's the whole point of the project working.
133
+ Starring it costs nothing and helps the next developer who's about to
134
+ `print()` an API key by accident actually find this before it's too
135
+ late.
136
+
137
+ ---
138
+
139
+ ## Installation
140
+
141
+ ```bash
142
+ pip install secretshield
143
+ ```
144
+
145
+ Requires Python 3.10+. No required third-party runtime dependencies
146
+ (a tiny `tomli` backport is pulled in automatically, but only on Python 3.10).
147
+
148
+ ## Basic usage
149
+
150
+ ```python
151
+ import secretshield
152
+
153
+ password = "hunter2-example-not-real"
154
+ print("Using password:", password)
155
+ ```
156
+
157
+ ```text
158
+ Using password: ********
159
+ ⚠ secretshield: Potential secret detected and redacted.
160
+ ```
161
+
162
+ Toggle protection manually if you need to:
163
+
164
+ ```python
165
+ import secretshield
166
+
167
+ secretshield.disable()
168
+ secretshield.enable() # idempotent, safe to call repeatedly
169
+ secretshield.is_enabled()
170
+ ```
171
+
172
+ Or use detection/redaction directly, without touching stdout at all:
173
+
174
+ ```python
175
+ from secretshield import detect, redact
176
+
177
+ detect("aws_key=AKIAABCDEFGHIJKLMNOP")
178
+ # [Match(start=8, end=28, value='AKIA...', kind='aws_access_key_id')]
179
+
180
+ redact("aws_key=AKIAABCDEFGHIJKLMNOP")
181
+ # ("aws_key=********", True)
182
+ ```
183
+
184
+ ## CLI reference
185
+
186
+ *(Every command below also works via the shorter `ss` alias — `ss scan .` is identical to `secretshield scan .`.)*
187
+
188
+ ### `secretshield init` — set a project up in one step
189
+
190
+ ```bash
191
+ secretshield init
192
+ ```
193
+
194
+ Detects your project, then interactively offers to create a config
195
+ file, install the Git hook, and generate the GitHub Actions workflow —
196
+ all in one pass instead of discovering each command separately.
197
+
198
+ ### `secretshield scan` — find hardcoded secrets
199
+
200
+ ```bash
201
+ secretshield scan . # scan a directory
202
+ secretshield scan app.py # scan a single file
203
+ secretshield scan . --json # machine-readable, CI-safe
204
+ secretshield scan . --fix # interactively move secrets to .env
205
+ secretshield scan --staged # would this commit introduce a secret?
206
+ secretshield scan --diff HEAD~1 # did my changes introduce a secret?
207
+ secretshield scan . --baseline # adopt SecretShield without fixing everything today
208
+ ```
209
+
210
+ Scans Python, JavaScript/TypeScript, HTML, CSS, Vue, Svelte, JSON,
211
+ YAML, TOML/INI, `.env` files, shell scripts, and more — treating each
212
+ as text and running the same detection engine regardless of language.
213
+ Automatically skips `.git/`, `node_modules/`, `.venv/`, binary files,
214
+ and obvious documentation placeholders like `your_api_key_here`.
215
+
216
+ ```text
217
+ SecretShield scan
218
+
219
+ ✗ src/app.js:82
220
+ Potential secret: Bearer token
221
+ Type: token
222
+
223
+ ✓ 143 files scanned
224
+ ✗ 1 potential secret(s) found
225
+
226
+ Exit code: 1
227
+ ```
228
+
229
+ ### `secretshield run` — protect a script without editing it
230
+
231
+ ```bash
232
+ secretshield run app.py
233
+ ```
234
+
235
+ ### `secretshield install-hook` / `uninstall-hook` — stop secrets before they're committed
236
+
237
+ ```bash
238
+ secretshield install-hook
239
+ ```
240
+
241
+ Scans **staged content** (not your whole working tree) before every
242
+ commit and blocks it if something looks like a secret. Never destroys
243
+ an existing pre-commit hook — backs it up and wraps it instead.
244
+
245
+ ### `secretshield github-action` — catch what slips past locally
246
+
247
+ ```bash
248
+ secretshield github-action
249
+ ```
250
+
251
+ Generates `.github/workflows/secretshield.yml`, scanning every push and
252
+ pull request automatically.
253
+
254
+ ## Configuration file
255
+
256
+ Project-wide scan settings live in `secretshield.toml` (generate one
257
+ with `secretshield init`):
258
+
259
+ ```toml
260
+ [scan]
261
+ entropy_threshold = 4.2
262
+
263
+ [scan.ignore]
264
+ paths = ["tests/fixtures/", "docs/examples/"]
265
+
266
+ [scan.include]
267
+ patterns = ["*.py", "*.js"]
268
+
269
+ [output]
270
+ format = "text"
271
+ ```
272
+
273
+ CLI flags always override the file.
274
+
275
+ ## Runtime configuration
276
+
277
+ ```python
278
+ import secretshield
279
+
280
+ secretshield.configure(
281
+ enabled=True, # master on/off switch
282
+ redact_with="********", # placeholder used in place of a secret
283
+ entropy_threshold=4.2, # bits/char threshold for generic detection
284
+ notify=True, # print the "potential secret" warning
285
+ )
286
+ ```
287
+
288
+ ## Detection methods
289
+
290
+ SecretShield combines two strategies:
291
+
292
+ 1. **Known-format pattern matching** — AWS keys, GitHub tokens,
293
+ OpenAI-style keys, Slack tokens, Stripe keys, Google API keys, JWTs,
294
+ bearer tokens, PEM private-key blocks, and labeled generic secrets
295
+ (`password =`, `api_key:`, etc.)
296
+ 2. **High-entropy detection** — catches random-looking secrets that
297
+ don't match a known format, used as a conservative supplement (not
298
+ the primary mechanism) to keep false positives low.
299
+
300
+ ## Architecture
301
+
302
+ ```text
303
+ secretshield/
304
+ ├── patterns.py, detector.py, redactor.py # detection & redaction engine
305
+ ├── guardian.py # stdout/stderr + logging protection
306
+ ├── config.py, notifications.py # runtime settings & safe warnings
307
+ ├── project_config.py, baseline.py # secretshield.toml, --baseline
308
+ ├── cli.py # command-line interface
309
+ ├── autofix/ # interactive scan --fix
310
+ ├── git/ # pre-commit hook
311
+ └── github/ # Actions workflow generation
312
+ ```
313
+
314
+ ## Testing
315
+
316
+ ```bash
317
+ pip install -e ".[dev]"
318
+ pytest
319
+ ```
320
+
321
+ 176+ tests covering detection, redaction, runtime protection, static
322
+ scanning across languages, Auto-Fix, Git hooks, and CI integration. All
323
+ secrets used in tests and examples are fake.
324
+
325
+ ## Limitations
326
+
327
+ Be honest about what this is and isn't:
328
+
329
+ - Runtime protection covers **this Python process's** `stdout`,
330
+ `stderr`, and `logging` — not screenshots, clipboard, arbitrary file
331
+ writes, other applications, or network traffic.
332
+ - **Auto-Fix (`--fix`)** only rewrites Python, and only unambiguous
333
+ simple assignments (checked via Python's own `ast` module, not a
334
+ regex). Anything less certain is reported but left untouched.
335
+ - The pre-commit hook needs `secretshield` resolvable on `PATH` at
336
+ commit time — keep your virtual environment active.
337
+
338
+ Treat SecretShield as a strong defense-in-depth safety net, not a
339
+ replacement for proper secret management (vaults, least-privilege
340
+ credentials, secret scanning in CI, etc.).
341
+
342
+ ## Security considerations
343
+
344
+ No network calls. No telemetry. Nothing sent anywhere — detection and
345
+ redaction happen entirely locally, in-process.
346
+
347
+ ## Contributing
348
+
349
+ Issues and PRs welcome. Please add tests for new detection patterns or
350
+ behavior changes, use only fake credentials in tests/examples, and run
351
+ `pytest` before opening a PR.
352
+
353
+ ## [☕](https://github.com/sponsors/Sam3360/) Get me a coffee
354
+
355
+ If you find this project useful, consider [supporting its development through GitHub Sponsors](https://github.com/sponsors/Sam3360/).
356
+
357
+ ## License
358
+
359
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,333 @@
1
+ <div align="center">
2
+
3
+ # 🛡️ SecretShield
4
+
5
+ **Your secrets shouldn't end up in your terminal, your logs, or your commit history.**
6
+ **SecretShield makes sure they don't — automatically.**
7
+
8
+ [![PyPI version](https://img.shields.io/pypi/v/secretshield?color=blue)](https://pypi.org/project/secretshield/)
9
+ [![Python versions](https://img.shields.io/pypi/pyversions/secretshield)](https://pypi.org/project/secretshield/)
10
+ [![PyPI downloads](https://img.shields.io/pypi/dm/secretshield)](https://pypi.org/project/secretshield/)
11
+ [![License: MIT](https://img.shields.io/pypi/l/secretshield)](LICENSE)
12
+
13
+ [Install](#installation) · [Demo](#demo) · [Quick start](#quick-start) · [Features](#what-secretshield-does) · [Docs below](#cli-reference)
14
+
15
+ </div>
16
+
17
+ ---
18
+
19
+ ## The problem
20
+
21
+ You've done this. Everyone has.
22
+
23
+ ```python
24
+ print("API key:", api_key) # ...now it's in your terminal history
25
+ logger.info("Token: %s", token) # ...now it's in your log files
26
+ API_KEY = "sk-live-abc123..." # ...now it's about to get committed
27
+ ```
28
+
29
+ One `print()` left in from debugging. One log line that dumps a config
30
+ dict. One hardcoded key that slips past code review. That's usually all
31
+ it takes.
32
+
33
+ ## The fix
34
+
35
+ ```bash
36
+ pip install secretshield
37
+ ```
38
+
39
+ ```python
40
+ import secretshield
41
+
42
+ api_key = "sk-example1234567890abcdefFAKEKEY"
43
+ print("API key:", api_key)
44
+ ```
45
+
46
+ ```text
47
+ API key: ********
48
+ ⚠ secretshield: Potential secret detected and redacted.
49
+ ```
50
+
51
+ **No configuration. No code changes. Just `pip install` and `import`.**
52
+ The moment you import it, your terminal output, your logs — protected.
53
+
54
+ ## Demo
55
+
56
+ See SecretShield in action:
57
+
58
+ [![SecretShield Demo](https://img.youtube.com/vi/g95lNIhWsXM/maxresdefault.jpg)](https://youtu.be/g95lNIhWsXM)
59
+
60
+ **[▶ Watch the full demo on YouTube](https://youtu.be/g95lNIhWsXM)**
61
+
62
+ ## Quick start
63
+
64
+ ```bash
65
+ pip install secretshield
66
+ ```
67
+
68
+ Protect a running script:
69
+ ```python
70
+ import secretshield # that's it — stdout, stderr, and logging are now protected
71
+ ```
72
+
73
+ Scan an entire project for hardcoded secrets:
74
+ ```bash
75
+ secretshield scan .
76
+ ```
77
+
78
+ Set a whole project up in one step (config file + Git hook + CI):
79
+ ```bash
80
+ secretshield init
81
+ ```
82
+
83
+ > Typing `secretshield` a lot? Every command also works with the short
84
+ > alias `ss` — `ss scan .`, `ss init`, `ss --fix`, all identical to
85
+ > their `secretshield` equivalents.
86
+
87
+ ## What SecretShield does
88
+
89
+ SecretShield isn't just one trick — it's five layers that cover the
90
+ whole path a secret takes from your keyboard to a place you can't take
91
+ it back from:
92
+
93
+ | | |
94
+ |---|---|
95
+ | 🖥️ **Runtime protection** | Automatically redacts secrets from `stdout`, `stderr`, and `logging` the instant you `import secretshield` |
96
+ | 🔍 **Static scanning** | `secretshield scan .` finds hardcoded secrets across Python, JS/TS, HTML, YAML, `.env`, and more |
97
+ | 🔧 **Auto-Fix** | `scan . --fix` interactively moves a hardcoded secret into `.env` and rewrites your code to use it — safely, and only when it's unambiguous |
98
+ | 🪝 **Git pre-commit hook** | `install-hook` blocks a commit before a secret ever reaches your repo's history |
99
+ | ⚙️ **GitHub Actions** | `github-action` generates a workflow that scans every push and PR automatically |
100
+
101
+ All of it: **zero required dependencies, no telemetry, no network calls, nothing sent anywhere.** Everything happens locally, in your own process.
102
+
103
+ ## Why star this repo
104
+
105
+ If SecretShield has ever caught something before it hit your terminal
106
+ or your Git history — that's the whole point of the project working.
107
+ Starring it costs nothing and helps the next developer who's about to
108
+ `print()` an API key by accident actually find this before it's too
109
+ late.
110
+
111
+ ---
112
+
113
+ ## Installation
114
+
115
+ ```bash
116
+ pip install secretshield
117
+ ```
118
+
119
+ Requires Python 3.10+. No required third-party runtime dependencies
120
+ (a tiny `tomli` backport is pulled in automatically, but only on Python 3.10).
121
+
122
+ ## Basic usage
123
+
124
+ ```python
125
+ import secretshield
126
+
127
+ password = "hunter2-example-not-real"
128
+ print("Using password:", password)
129
+ ```
130
+
131
+ ```text
132
+ Using password: ********
133
+ ⚠ secretshield: Potential secret detected and redacted.
134
+ ```
135
+
136
+ Toggle protection manually if you need to:
137
+
138
+ ```python
139
+ import secretshield
140
+
141
+ secretshield.disable()
142
+ secretshield.enable() # idempotent, safe to call repeatedly
143
+ secretshield.is_enabled()
144
+ ```
145
+
146
+ Or use detection/redaction directly, without touching stdout at all:
147
+
148
+ ```python
149
+ from secretshield import detect, redact
150
+
151
+ detect("aws_key=AKIAABCDEFGHIJKLMNOP")
152
+ # [Match(start=8, end=28, value='AKIA...', kind='aws_access_key_id')]
153
+
154
+ redact("aws_key=AKIAABCDEFGHIJKLMNOP")
155
+ # ("aws_key=********", True)
156
+ ```
157
+
158
+ ## CLI reference
159
+
160
+ *(Every command below also works via the shorter `ss` alias — `ss scan .` is identical to `secretshield scan .`.)*
161
+
162
+ ### `secretshield init` — set a project up in one step
163
+
164
+ ```bash
165
+ secretshield init
166
+ ```
167
+
168
+ Detects your project, then interactively offers to create a config
169
+ file, install the Git hook, and generate the GitHub Actions workflow —
170
+ all in one pass instead of discovering each command separately.
171
+
172
+ ### `secretshield scan` — find hardcoded secrets
173
+
174
+ ```bash
175
+ secretshield scan . # scan a directory
176
+ secretshield scan app.py # scan a single file
177
+ secretshield scan . --json # machine-readable, CI-safe
178
+ secretshield scan . --fix # interactively move secrets to .env
179
+ secretshield scan --staged # would this commit introduce a secret?
180
+ secretshield scan --diff HEAD~1 # did my changes introduce a secret?
181
+ secretshield scan . --baseline # adopt SecretShield without fixing everything today
182
+ ```
183
+
184
+ Scans Python, JavaScript/TypeScript, HTML, CSS, Vue, Svelte, JSON,
185
+ YAML, TOML/INI, `.env` files, shell scripts, and more — treating each
186
+ as text and running the same detection engine regardless of language.
187
+ Automatically skips `.git/`, `node_modules/`, `.venv/`, binary files,
188
+ and obvious documentation placeholders like `your_api_key_here`.
189
+
190
+ ```text
191
+ SecretShield scan
192
+
193
+ ✗ src/app.js:82
194
+ Potential secret: Bearer token
195
+ Type: token
196
+
197
+ ✓ 143 files scanned
198
+ ✗ 1 potential secret(s) found
199
+
200
+ Exit code: 1
201
+ ```
202
+
203
+ ### `secretshield run` — protect a script without editing it
204
+
205
+ ```bash
206
+ secretshield run app.py
207
+ ```
208
+
209
+ ### `secretshield install-hook` / `uninstall-hook` — stop secrets before they're committed
210
+
211
+ ```bash
212
+ secretshield install-hook
213
+ ```
214
+
215
+ Scans **staged content** (not your whole working tree) before every
216
+ commit and blocks it if something looks like a secret. Never destroys
217
+ an existing pre-commit hook — backs it up and wraps it instead.
218
+
219
+ ### `secretshield github-action` — catch what slips past locally
220
+
221
+ ```bash
222
+ secretshield github-action
223
+ ```
224
+
225
+ Generates `.github/workflows/secretshield.yml`, scanning every push and
226
+ pull request automatically.
227
+
228
+ ## Configuration file
229
+
230
+ Project-wide scan settings live in `secretshield.toml` (generate one
231
+ with `secretshield init`):
232
+
233
+ ```toml
234
+ [scan]
235
+ entropy_threshold = 4.2
236
+
237
+ [scan.ignore]
238
+ paths = ["tests/fixtures/", "docs/examples/"]
239
+
240
+ [scan.include]
241
+ patterns = ["*.py", "*.js"]
242
+
243
+ [output]
244
+ format = "text"
245
+ ```
246
+
247
+ CLI flags always override the file.
248
+
249
+ ## Runtime configuration
250
+
251
+ ```python
252
+ import secretshield
253
+
254
+ secretshield.configure(
255
+ enabled=True, # master on/off switch
256
+ redact_with="********", # placeholder used in place of a secret
257
+ entropy_threshold=4.2, # bits/char threshold for generic detection
258
+ notify=True, # print the "potential secret" warning
259
+ )
260
+ ```
261
+
262
+ ## Detection methods
263
+
264
+ SecretShield combines two strategies:
265
+
266
+ 1. **Known-format pattern matching** — AWS keys, GitHub tokens,
267
+ OpenAI-style keys, Slack tokens, Stripe keys, Google API keys, JWTs,
268
+ bearer tokens, PEM private-key blocks, and labeled generic secrets
269
+ (`password =`, `api_key:`, etc.)
270
+ 2. **High-entropy detection** — catches random-looking secrets that
271
+ don't match a known format, used as a conservative supplement (not
272
+ the primary mechanism) to keep false positives low.
273
+
274
+ ## Architecture
275
+
276
+ ```text
277
+ secretshield/
278
+ ├── patterns.py, detector.py, redactor.py # detection & redaction engine
279
+ ├── guardian.py # stdout/stderr + logging protection
280
+ ├── config.py, notifications.py # runtime settings & safe warnings
281
+ ├── project_config.py, baseline.py # secretshield.toml, --baseline
282
+ ├── cli.py # command-line interface
283
+ ├── autofix/ # interactive scan --fix
284
+ ├── git/ # pre-commit hook
285
+ └── github/ # Actions workflow generation
286
+ ```
287
+
288
+ ## Testing
289
+
290
+ ```bash
291
+ pip install -e ".[dev]"
292
+ pytest
293
+ ```
294
+
295
+ 176+ tests covering detection, redaction, runtime protection, static
296
+ scanning across languages, Auto-Fix, Git hooks, and CI integration. All
297
+ secrets used in tests and examples are fake.
298
+
299
+ ## Limitations
300
+
301
+ Be honest about what this is and isn't:
302
+
303
+ - Runtime protection covers **this Python process's** `stdout`,
304
+ `stderr`, and `logging` — not screenshots, clipboard, arbitrary file
305
+ writes, other applications, or network traffic.
306
+ - **Auto-Fix (`--fix`)** only rewrites Python, and only unambiguous
307
+ simple assignments (checked via Python's own `ast` module, not a
308
+ regex). Anything less certain is reported but left untouched.
309
+ - The pre-commit hook needs `secretshield` resolvable on `PATH` at
310
+ commit time — keep your virtual environment active.
311
+
312
+ Treat SecretShield as a strong defense-in-depth safety net, not a
313
+ replacement for proper secret management (vaults, least-privilege
314
+ credentials, secret scanning in CI, etc.).
315
+
316
+ ## Security considerations
317
+
318
+ No network calls. No telemetry. Nothing sent anywhere — detection and
319
+ redaction happen entirely locally, in-process.
320
+
321
+ ## Contributing
322
+
323
+ Issues and PRs welcome. Please add tests for new detection patterns or
324
+ behavior changes, use only fake credentials in tests/examples, and run
325
+ `pytest` before opening a PR.
326
+
327
+ ## [☕](https://github.com/sponsors/Sam3360/) Get me a coffee
328
+
329
+ If you find this project useful, consider [supporting its development through GitHub Sponsors](https://github.com/sponsors/Sam3360/).
330
+
331
+ ## License
332
+
333
+ MIT — see [LICENSE](LICENSE).
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "secretshield"
7
- version = "0.4.0"
8
- description = "Detect and redact likely secrets before they reach Python's terminal output or logging system."
7
+ version = "0.4.2"
8
+ description = "Stop secrets before they leak -- runtime redaction, multi-language scanning, auto-fix, Git hooks, and CI, all in one CLI."
9
9
  readme = "README.md"
10
10
  license = "MIT"
11
11
  requires-python = ">=3.10"
@@ -39,6 +39,7 @@ Issues = "https://github.com/Sam3360/secretshield/issues"
39
39
 
40
40
  [project.scripts]
41
41
  secretshield = "secretshield.cli:main"
42
+ ss = "secretshield.cli:main"
42
43
 
43
44
  [tool.setuptools.packages.find]
44
45
  include = ["secretshield*"]