codefence 1.0.0__tar.gz → 1.0.1__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.
- codefence-1.0.1/PKG-INFO +329 -0
- codefence-1.0.1/codefence.egg-info/PKG-INFO +329 -0
- {codefence-1.0.0 → codefence-1.0.1}/codefence.py +23 -2
- {codefence-1.0.0 → codefence-1.0.1}/pyproject.toml +4 -7
- codefence-1.0.0/PKG-INFO +0 -524
- codefence-1.0.0/codefence.egg-info/PKG-INFO +0 -524
- {codefence-1.0.0 → codefence-1.0.1}/CHANGELOG.md +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/LICENSE.txt +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/LICENSE_FAQ.md +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/NOTICE.md +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/README.md +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/REFUND_POLICY.md +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/SECURITY.md +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/TERMS_OF_USE.md +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/codefence.egg-info/SOURCES.txt +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/codefence.egg-info/dependency_links.txt +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/codefence.egg-info/entry_points.txt +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/codefence.egg-info/top_level.txt +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/rules.json +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/samples/bad_javascript.js +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/samples/bad_python.py +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/samples/clean_example.js +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/samples/clean_example.py +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/setup.cfg +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/tests/test_baseline.py +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/tests/test_history.py +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/tests/test_integration.py +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/tests/test_lexer.py +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/tests/test_policy.py +0 -0
- {codefence-1.0.0 → codefence-1.0.1}/tests/test_rules.py +0 -0
codefence-1.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codefence
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: A tiny offline policy gate for code. Check AI-generated code before it reaches Git.
|
|
5
|
+
Author: CodeFence
|
|
6
|
+
License-Expression: LicenseRef-CodeFence-EULA
|
|
7
|
+
Project-URL: Homepage, https://codefence.dev
|
|
8
|
+
Project-URL: Source, https://github.com/USERNAME/codefence
|
|
9
|
+
Project-URL: Issues, https://github.com/USERNAME/codefence/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/USERNAME/codefence/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: security,static-analysis,pre-commit,git-hook,ai-generated-code,sast,sarif,offline,policy
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
+
Classifier: Topic :: Software Development :: Testing
|
|
23
|
+
Classifier: Topic :: Security
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE.txt
|
|
27
|
+
License-File: LICENSE_FAQ.md
|
|
28
|
+
License-File: NOTICE.md
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# CodeFence
|
|
32
|
+
|
|
33
|
+
**A tiny offline policy gate for code.**
|
|
34
|
+
|
|
35
|
+
Check AI-generated code before it reaches Git.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## What it does
|
|
40
|
+
|
|
41
|
+
CodeFence is a single-file, zero-dependency Python CLI that scans
|
|
42
|
+
source code for selected dangerous patterns before you commit. It
|
|
43
|
+
runs a curated set of rules and reports findings with:
|
|
44
|
+
|
|
45
|
+
- severity (critical / high / medium / low / info)
|
|
46
|
+
- exact location (file:line:column)
|
|
47
|
+
- code snippet
|
|
48
|
+
- short remediation
|
|
49
|
+
- typical before/after fix example
|
|
50
|
+
|
|
51
|
+
It is designed around the risks commonly encountered in AI-assisted
|
|
52
|
+
development, but scans ordinary source code regardless of how it
|
|
53
|
+
was written.
|
|
54
|
+
|
|
55
|
+
**The gate workflow:**
|
|
56
|
+
|
|
57
|
+
AI writes code
|
|
58
|
+
|
|
|
59
|
+
v
|
|
60
|
+
CodeFence runs on staged files
|
|
61
|
+
|
|
|
62
|
+
v
|
|
63
|
+
policy evaluation (allow / warn / block)
|
|
64
|
+
|
|
|
65
|
+
v
|
|
66
|
+
PASS or BLOCKED
|
|
67
|
+
|
|
|
68
|
+
v
|
|
69
|
+
git commit
|
|
70
|
+
|
|
71
|
+
## What it does NOT do
|
|
72
|
+
|
|
73
|
+
- Not an autofixer. It shows a typical fix; it does not edit files.
|
|
74
|
+
- Not a security audit. It is a pattern-based sanity checker.
|
|
75
|
+
- Not a replacement for Semgrep, CodeQL, or professional review.
|
|
76
|
+
- Not interprocedural. No dataflow, no taint analysis.
|
|
77
|
+
- Not a guarantee. A clean scan does not mean the code is secure.
|
|
78
|
+
|
|
79
|
+
## Install
|
|
80
|
+
|
|
81
|
+
pip install codefence
|
|
82
|
+
|
|
83
|
+
Or run it directly:
|
|
84
|
+
|
|
85
|
+
python3 codefence.py app.py
|
|
86
|
+
|
|
87
|
+
## Quick start
|
|
88
|
+
|
|
89
|
+
**One-time setup in a git repository:**
|
|
90
|
+
|
|
91
|
+
codefence init
|
|
92
|
+
|
|
93
|
+
This installs a pre-commit hook and creates .codefence/config.json.
|
|
94
|
+
Every commit is then gated automatically.
|
|
95
|
+
|
|
96
|
+
**Daily usage:**
|
|
97
|
+
|
|
98
|
+
codefence --staged # scan only what is staged
|
|
99
|
+
codefence --staged --diff # only NEW findings since baseline
|
|
100
|
+
codefence baseline # snapshot current findings
|
|
101
|
+
|
|
102
|
+
**One-off scans:**
|
|
103
|
+
|
|
104
|
+
codefence src/
|
|
105
|
+
codefence --format json --output report.json src/
|
|
106
|
+
codefence --format html --output report.html src/
|
|
107
|
+
codefence --format sarif --output results.sarif .
|
|
108
|
+
|
|
109
|
+
**Policy-as-code:**
|
|
110
|
+
|
|
111
|
+
codefence --policy company-policy.json --staged
|
|
112
|
+
codefence policy validate company-policy.json
|
|
113
|
+
|
|
114
|
+
**Explanation:**
|
|
115
|
+
|
|
116
|
+
codefence explain R002
|
|
117
|
+
## The 30 rules
|
|
118
|
+
|
|
119
|
+
Rules are shipped in rules.json (human-readable JSON). You can
|
|
120
|
+
inspect them, and you can add or disable rules for your own use.
|
|
121
|
+
|
|
122
|
+
### Secrets
|
|
123
|
+
- R001 - Hardcoded API keys / secrets
|
|
124
|
+
- R011 - Hardcoded database credentials
|
|
125
|
+
- R028 - Env var with hardcoded fallback secret
|
|
126
|
+
|
|
127
|
+
### Injection
|
|
128
|
+
- R002 - SQL injection via string concatenation (Python)
|
|
129
|
+
- R003 - eval() / exec() on untrusted input (Python)
|
|
130
|
+
- R004 - Command injection via shell=True (Python)
|
|
131
|
+
- R005 - innerHTML with unsanitized data (JavaScript)
|
|
132
|
+
- R010 - Path traversal
|
|
133
|
+
- R014 - Prototype pollution (JavaScript)
|
|
134
|
+
- R019 - Unsafe deserialization (pickle, yaml.load)
|
|
135
|
+
|
|
136
|
+
### Authentication
|
|
137
|
+
- R006 - Missing authentication on endpoints
|
|
138
|
+
- R015 - Missing rate limiting on public endpoints
|
|
139
|
+
- R018 - Open redirect
|
|
140
|
+
- R020 - Never-expiring tokens / JWT
|
|
141
|
+
|
|
142
|
+
### Cryptography
|
|
143
|
+
- R008 - Insecure random for security tokens (Python)
|
|
144
|
+
- R009 - Disabled TLS/SSL verification
|
|
145
|
+
- R016 - MD5 / SHA1 for password hashing
|
|
146
|
+
|
|
147
|
+
### Configuration
|
|
148
|
+
- R007 - Overly permissive CORS (*)
|
|
149
|
+
- R017 - Debug mode left enabled
|
|
150
|
+
- R021 - Missing security headers (Express)
|
|
151
|
+
|
|
152
|
+
### Reliability
|
|
153
|
+
- R022 - Race conditions (check-then-act)
|
|
154
|
+
- R026 - HTTP request without timeout
|
|
155
|
+
- R027 - Naive datetime (no timezone, context-aware)
|
|
156
|
+
|
|
157
|
+
### Quality
|
|
158
|
+
- R012 - Broad except: pass
|
|
159
|
+
- R013 - Mutable default arguments
|
|
160
|
+
- R023 - Logging sensitive data
|
|
161
|
+
- R024 - Unused imports / dead code
|
|
162
|
+
- R025 - Promise rejection ignored (JavaScript)
|
|
163
|
+
|
|
164
|
+
### AI-specific
|
|
165
|
+
- R030 - Typosquatted package imports
|
|
166
|
+
- R031 - TODO / FIXME / HACK in new code
|
|
167
|
+
|
|
168
|
+
Each rule carries a confidence level and a stable rule_version +
|
|
169
|
+
fingerprint for baseline stability.
|
|
170
|
+
|
|
171
|
+
## Configuration
|
|
172
|
+
|
|
173
|
+
Options can be passed as CLI flags or through a JSON config file
|
|
174
|
+
(auto-discovered at .codefence/config.json after 'codefence init').
|
|
175
|
+
|
|
176
|
+
Example .codefence/config.json:
|
|
177
|
+
|
|
178
|
+
{
|
|
179
|
+
"schema": "codefence/config-v1",
|
|
180
|
+
"format": "json",
|
|
181
|
+
"severity": "medium",
|
|
182
|
+
"include": ["*.py", "*.js"],
|
|
183
|
+
"exclude": ["node_modules", ".git", "venv", "samples"],
|
|
184
|
+
"max_size": 2097152,
|
|
185
|
+
"cache": false
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
Priority: CLI flags > config file > built-in defaults.
|
|
189
|
+
|
|
190
|
+
### Optional cache
|
|
191
|
+
|
|
192
|
+
Pass --cache to enable a local cache at ~/.cache/codefence/. The
|
|
193
|
+
cache is keyed by SHA-256 of the file content plus a fingerprint
|
|
194
|
+
of rules.json. It is off by default. See SECURITY.md for how the
|
|
195
|
+
cache is protected.
|
|
196
|
+
|
|
197
|
+
### Optional history
|
|
198
|
+
|
|
199
|
+
Pass --history to record this scan in a local SQLite database at
|
|
200
|
+
~/.local/share/codefence/history.db. Off by default.
|
|
201
|
+
|
|
202
|
+
Set CODEFENCE_NO_HISTORY=1 to disable history entirely, even when
|
|
203
|
+
--history is set.
|
|
204
|
+
|
|
205
|
+
Query history:
|
|
206
|
+
|
|
207
|
+
codefence history
|
|
208
|
+
codefence stats
|
|
209
|
+
## Security and privacy
|
|
210
|
+
|
|
211
|
+
- Zero network calls. Zero.
|
|
212
|
+
- Zero telemetry.
|
|
213
|
+
- Zero data upload.
|
|
214
|
+
- Writes only to --output, and optionally to:
|
|
215
|
+
~/.cache/codefence/ (only when --cache is set)
|
|
216
|
+
~/.local/share/codefence/ (only when --history is set)
|
|
217
|
+
- Never writes to the files you scan.
|
|
218
|
+
- Never executes the code you scan.
|
|
219
|
+
|
|
220
|
+
The full threat model is documented in SECURITY.md.
|
|
221
|
+
|
|
222
|
+
## Verifying the download
|
|
223
|
+
|
|
224
|
+
Every shipped file is hashed in CHECKSUMS.txt. To verify:
|
|
225
|
+
|
|
226
|
+
sha256sum codefence.py rules.json
|
|
227
|
+
|
|
228
|
+
Compare the output with the corresponding lines in CHECKSUMS.txt.
|
|
229
|
+
If the hashes do not match, do not use the file.
|
|
230
|
+
|
|
231
|
+
## Payment and pricing
|
|
232
|
+
|
|
233
|
+
**$12 USD, one-time.**
|
|
234
|
+
|
|
235
|
+
Includes the current major version (v1.x) and its maintenance
|
|
236
|
+
releases. No subscription. No support. No account.
|
|
237
|
+
|
|
238
|
+
Payments are available in cryptocurrency only:
|
|
239
|
+
|
|
240
|
+
- USDT (TRC20 or BEP20)
|
|
241
|
+
- USDC
|
|
242
|
+
- BTC
|
|
243
|
+
- TRX
|
|
244
|
+
- XRP
|
|
245
|
+
|
|
246
|
+
Official purchase channels:
|
|
247
|
+
|
|
248
|
+
- Getly
|
|
249
|
+
- SilkRoadx402
|
|
250
|
+
- ctlx.cc
|
|
251
|
+
|
|
252
|
+
If you find CodeFence on any other site claiming to sell it,
|
|
253
|
+
treat that site as unofficial.
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
Source-available. Not open source.
|
|
258
|
+
|
|
259
|
+
Summary:
|
|
260
|
+
|
|
261
|
+
- Personal use on up to 3 devices that you own or control.
|
|
262
|
+
- Read, study, and privately modify the source.
|
|
263
|
+
- No redistribution. No resale. No bundling.
|
|
264
|
+
- No scanning-as-a-service on a commercial basis.
|
|
265
|
+
|
|
266
|
+
For plain-language answers to common questions, see LICENSE_FAQ.md.
|
|
267
|
+
For the full legal terms, see LICENSE.txt and TERMS_OF_USE.md.
|
|
268
|
+
|
|
269
|
+
**Governing law:** England and Wales. Mandatory consumer
|
|
270
|
+
protections in your country of residence remain fully applicable.
|
|
271
|
+
|
|
272
|
+
## Support
|
|
273
|
+
|
|
274
|
+
There is no support.
|
|
275
|
+
|
|
276
|
+
- No email. No chat. No issue tracker.
|
|
277
|
+
- No guaranteed updates.
|
|
278
|
+
- No bug-fix commitments.
|
|
279
|
+
|
|
280
|
+
If you need a product with ongoing support, please look elsewhere.
|
|
281
|
+
|
|
282
|
+
## FAQ
|
|
283
|
+
|
|
284
|
+
**Q: Will this find every security issue in my code?**
|
|
285
|
+
A: No. It finds a curated set of dangerous patterns. It is a
|
|
286
|
+
sanity check, not a security audit.
|
|
287
|
+
|
|
288
|
+
**Q: Can I use it in CI?**
|
|
289
|
+
A: Yes. JSON and SARIF outputs are pure on stdout. Exit codes are
|
|
290
|
+
stable.
|
|
291
|
+
|
|
292
|
+
**Q: Does it phone home?**
|
|
293
|
+
A: No. Zero network calls. You can verify by reading the source
|
|
294
|
+
or by running it under strace.
|
|
295
|
+
|
|
296
|
+
**Q: Does it fix my code?**
|
|
297
|
+
A: No. It shows a typical before/after fix. You apply it yourself.
|
|
298
|
+
|
|
299
|
+
**Q: Does it support TypeScript?**
|
|
300
|
+
A: No. Python, JavaScript (.js, .mjs, .cjs).
|
|
301
|
+
|
|
302
|
+
**Q: What about false positives?**
|
|
303
|
+
A: Pattern-based scanners always produce some. Rules with lower
|
|
304
|
+
confidence are flagged as such. You can disable any rule in
|
|
305
|
+
rules.json or via policy overrides.
|
|
306
|
+
|
|
307
|
+
**Q: Can I modify the source?**
|
|
308
|
+
A: Yes, privately. See LICENSE_FAQ.md.
|
|
309
|
+
|
|
310
|
+
**Q: Can my team use it?**
|
|
311
|
+
A: Each developer using CodeFence on their own machine needs
|
|
312
|
+
their own license. One license covers one individual on up to
|
|
313
|
+
three devices.
|
|
314
|
+
|
|
315
|
+
**Q: How do I get updates?**
|
|
316
|
+
A: There are no guaranteed updates.
|
|
317
|
+
|
|
318
|
+
**Q: Can I get a refund?**
|
|
319
|
+
A: See REFUND_POLICY.md.
|
|
320
|
+
|
|
321
|
+
## A note on honesty
|
|
322
|
+
|
|
323
|
+
This product is built to do a specific, limited thing well. It
|
|
324
|
+
does not overstate what it can do. Every claim in this README is
|
|
325
|
+
traceable to a line of code or a test. If you find a claim that
|
|
326
|
+
is not supported by what the tool actually does, please report
|
|
327
|
+
it.
|
|
328
|
+
|
|
329
|
+
*End of README.*
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codefence
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: A tiny offline policy gate for code. Check AI-generated code before it reaches Git.
|
|
5
|
+
Author: CodeFence
|
|
6
|
+
License-Expression: LicenseRef-CodeFence-EULA
|
|
7
|
+
Project-URL: Homepage, https://codefence.dev
|
|
8
|
+
Project-URL: Source, https://github.com/USERNAME/codefence
|
|
9
|
+
Project-URL: Issues, https://github.com/USERNAME/codefence/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/USERNAME/codefence/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: security,static-analysis,pre-commit,git-hook,ai-generated-code,sast,sarif,offline,policy
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
+
Classifier: Topic :: Software Development :: Testing
|
|
23
|
+
Classifier: Topic :: Security
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE.txt
|
|
27
|
+
License-File: LICENSE_FAQ.md
|
|
28
|
+
License-File: NOTICE.md
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# CodeFence
|
|
32
|
+
|
|
33
|
+
**A tiny offline policy gate for code.**
|
|
34
|
+
|
|
35
|
+
Check AI-generated code before it reaches Git.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## What it does
|
|
40
|
+
|
|
41
|
+
CodeFence is a single-file, zero-dependency Python CLI that scans
|
|
42
|
+
source code for selected dangerous patterns before you commit. It
|
|
43
|
+
runs a curated set of rules and reports findings with:
|
|
44
|
+
|
|
45
|
+
- severity (critical / high / medium / low / info)
|
|
46
|
+
- exact location (file:line:column)
|
|
47
|
+
- code snippet
|
|
48
|
+
- short remediation
|
|
49
|
+
- typical before/after fix example
|
|
50
|
+
|
|
51
|
+
It is designed around the risks commonly encountered in AI-assisted
|
|
52
|
+
development, but scans ordinary source code regardless of how it
|
|
53
|
+
was written.
|
|
54
|
+
|
|
55
|
+
**The gate workflow:**
|
|
56
|
+
|
|
57
|
+
AI writes code
|
|
58
|
+
|
|
|
59
|
+
v
|
|
60
|
+
CodeFence runs on staged files
|
|
61
|
+
|
|
|
62
|
+
v
|
|
63
|
+
policy evaluation (allow / warn / block)
|
|
64
|
+
|
|
|
65
|
+
v
|
|
66
|
+
PASS or BLOCKED
|
|
67
|
+
|
|
|
68
|
+
v
|
|
69
|
+
git commit
|
|
70
|
+
|
|
71
|
+
## What it does NOT do
|
|
72
|
+
|
|
73
|
+
- Not an autofixer. It shows a typical fix; it does not edit files.
|
|
74
|
+
- Not a security audit. It is a pattern-based sanity checker.
|
|
75
|
+
- Not a replacement for Semgrep, CodeQL, or professional review.
|
|
76
|
+
- Not interprocedural. No dataflow, no taint analysis.
|
|
77
|
+
- Not a guarantee. A clean scan does not mean the code is secure.
|
|
78
|
+
|
|
79
|
+
## Install
|
|
80
|
+
|
|
81
|
+
pip install codefence
|
|
82
|
+
|
|
83
|
+
Or run it directly:
|
|
84
|
+
|
|
85
|
+
python3 codefence.py app.py
|
|
86
|
+
|
|
87
|
+
## Quick start
|
|
88
|
+
|
|
89
|
+
**One-time setup in a git repository:**
|
|
90
|
+
|
|
91
|
+
codefence init
|
|
92
|
+
|
|
93
|
+
This installs a pre-commit hook and creates .codefence/config.json.
|
|
94
|
+
Every commit is then gated automatically.
|
|
95
|
+
|
|
96
|
+
**Daily usage:**
|
|
97
|
+
|
|
98
|
+
codefence --staged # scan only what is staged
|
|
99
|
+
codefence --staged --diff # only NEW findings since baseline
|
|
100
|
+
codefence baseline # snapshot current findings
|
|
101
|
+
|
|
102
|
+
**One-off scans:**
|
|
103
|
+
|
|
104
|
+
codefence src/
|
|
105
|
+
codefence --format json --output report.json src/
|
|
106
|
+
codefence --format html --output report.html src/
|
|
107
|
+
codefence --format sarif --output results.sarif .
|
|
108
|
+
|
|
109
|
+
**Policy-as-code:**
|
|
110
|
+
|
|
111
|
+
codefence --policy company-policy.json --staged
|
|
112
|
+
codefence policy validate company-policy.json
|
|
113
|
+
|
|
114
|
+
**Explanation:**
|
|
115
|
+
|
|
116
|
+
codefence explain R002
|
|
117
|
+
## The 30 rules
|
|
118
|
+
|
|
119
|
+
Rules are shipped in rules.json (human-readable JSON). You can
|
|
120
|
+
inspect them, and you can add or disable rules for your own use.
|
|
121
|
+
|
|
122
|
+
### Secrets
|
|
123
|
+
- R001 - Hardcoded API keys / secrets
|
|
124
|
+
- R011 - Hardcoded database credentials
|
|
125
|
+
- R028 - Env var with hardcoded fallback secret
|
|
126
|
+
|
|
127
|
+
### Injection
|
|
128
|
+
- R002 - SQL injection via string concatenation (Python)
|
|
129
|
+
- R003 - eval() / exec() on untrusted input (Python)
|
|
130
|
+
- R004 - Command injection via shell=True (Python)
|
|
131
|
+
- R005 - innerHTML with unsanitized data (JavaScript)
|
|
132
|
+
- R010 - Path traversal
|
|
133
|
+
- R014 - Prototype pollution (JavaScript)
|
|
134
|
+
- R019 - Unsafe deserialization (pickle, yaml.load)
|
|
135
|
+
|
|
136
|
+
### Authentication
|
|
137
|
+
- R006 - Missing authentication on endpoints
|
|
138
|
+
- R015 - Missing rate limiting on public endpoints
|
|
139
|
+
- R018 - Open redirect
|
|
140
|
+
- R020 - Never-expiring tokens / JWT
|
|
141
|
+
|
|
142
|
+
### Cryptography
|
|
143
|
+
- R008 - Insecure random for security tokens (Python)
|
|
144
|
+
- R009 - Disabled TLS/SSL verification
|
|
145
|
+
- R016 - MD5 / SHA1 for password hashing
|
|
146
|
+
|
|
147
|
+
### Configuration
|
|
148
|
+
- R007 - Overly permissive CORS (*)
|
|
149
|
+
- R017 - Debug mode left enabled
|
|
150
|
+
- R021 - Missing security headers (Express)
|
|
151
|
+
|
|
152
|
+
### Reliability
|
|
153
|
+
- R022 - Race conditions (check-then-act)
|
|
154
|
+
- R026 - HTTP request without timeout
|
|
155
|
+
- R027 - Naive datetime (no timezone, context-aware)
|
|
156
|
+
|
|
157
|
+
### Quality
|
|
158
|
+
- R012 - Broad except: pass
|
|
159
|
+
- R013 - Mutable default arguments
|
|
160
|
+
- R023 - Logging sensitive data
|
|
161
|
+
- R024 - Unused imports / dead code
|
|
162
|
+
- R025 - Promise rejection ignored (JavaScript)
|
|
163
|
+
|
|
164
|
+
### AI-specific
|
|
165
|
+
- R030 - Typosquatted package imports
|
|
166
|
+
- R031 - TODO / FIXME / HACK in new code
|
|
167
|
+
|
|
168
|
+
Each rule carries a confidence level and a stable rule_version +
|
|
169
|
+
fingerprint for baseline stability.
|
|
170
|
+
|
|
171
|
+
## Configuration
|
|
172
|
+
|
|
173
|
+
Options can be passed as CLI flags or through a JSON config file
|
|
174
|
+
(auto-discovered at .codefence/config.json after 'codefence init').
|
|
175
|
+
|
|
176
|
+
Example .codefence/config.json:
|
|
177
|
+
|
|
178
|
+
{
|
|
179
|
+
"schema": "codefence/config-v1",
|
|
180
|
+
"format": "json",
|
|
181
|
+
"severity": "medium",
|
|
182
|
+
"include": ["*.py", "*.js"],
|
|
183
|
+
"exclude": ["node_modules", ".git", "venv", "samples"],
|
|
184
|
+
"max_size": 2097152,
|
|
185
|
+
"cache": false
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
Priority: CLI flags > config file > built-in defaults.
|
|
189
|
+
|
|
190
|
+
### Optional cache
|
|
191
|
+
|
|
192
|
+
Pass --cache to enable a local cache at ~/.cache/codefence/. The
|
|
193
|
+
cache is keyed by SHA-256 of the file content plus a fingerprint
|
|
194
|
+
of rules.json. It is off by default. See SECURITY.md for how the
|
|
195
|
+
cache is protected.
|
|
196
|
+
|
|
197
|
+
### Optional history
|
|
198
|
+
|
|
199
|
+
Pass --history to record this scan in a local SQLite database at
|
|
200
|
+
~/.local/share/codefence/history.db. Off by default.
|
|
201
|
+
|
|
202
|
+
Set CODEFENCE_NO_HISTORY=1 to disable history entirely, even when
|
|
203
|
+
--history is set.
|
|
204
|
+
|
|
205
|
+
Query history:
|
|
206
|
+
|
|
207
|
+
codefence history
|
|
208
|
+
codefence stats
|
|
209
|
+
## Security and privacy
|
|
210
|
+
|
|
211
|
+
- Zero network calls. Zero.
|
|
212
|
+
- Zero telemetry.
|
|
213
|
+
- Zero data upload.
|
|
214
|
+
- Writes only to --output, and optionally to:
|
|
215
|
+
~/.cache/codefence/ (only when --cache is set)
|
|
216
|
+
~/.local/share/codefence/ (only when --history is set)
|
|
217
|
+
- Never writes to the files you scan.
|
|
218
|
+
- Never executes the code you scan.
|
|
219
|
+
|
|
220
|
+
The full threat model is documented in SECURITY.md.
|
|
221
|
+
|
|
222
|
+
## Verifying the download
|
|
223
|
+
|
|
224
|
+
Every shipped file is hashed in CHECKSUMS.txt. To verify:
|
|
225
|
+
|
|
226
|
+
sha256sum codefence.py rules.json
|
|
227
|
+
|
|
228
|
+
Compare the output with the corresponding lines in CHECKSUMS.txt.
|
|
229
|
+
If the hashes do not match, do not use the file.
|
|
230
|
+
|
|
231
|
+
## Payment and pricing
|
|
232
|
+
|
|
233
|
+
**$12 USD, one-time.**
|
|
234
|
+
|
|
235
|
+
Includes the current major version (v1.x) and its maintenance
|
|
236
|
+
releases. No subscription. No support. No account.
|
|
237
|
+
|
|
238
|
+
Payments are available in cryptocurrency only:
|
|
239
|
+
|
|
240
|
+
- USDT (TRC20 or BEP20)
|
|
241
|
+
- USDC
|
|
242
|
+
- BTC
|
|
243
|
+
- TRX
|
|
244
|
+
- XRP
|
|
245
|
+
|
|
246
|
+
Official purchase channels:
|
|
247
|
+
|
|
248
|
+
- Getly
|
|
249
|
+
- SilkRoadx402
|
|
250
|
+
- ctlx.cc
|
|
251
|
+
|
|
252
|
+
If you find CodeFence on any other site claiming to sell it,
|
|
253
|
+
treat that site as unofficial.
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
Source-available. Not open source.
|
|
258
|
+
|
|
259
|
+
Summary:
|
|
260
|
+
|
|
261
|
+
- Personal use on up to 3 devices that you own or control.
|
|
262
|
+
- Read, study, and privately modify the source.
|
|
263
|
+
- No redistribution. No resale. No bundling.
|
|
264
|
+
- No scanning-as-a-service on a commercial basis.
|
|
265
|
+
|
|
266
|
+
For plain-language answers to common questions, see LICENSE_FAQ.md.
|
|
267
|
+
For the full legal terms, see LICENSE.txt and TERMS_OF_USE.md.
|
|
268
|
+
|
|
269
|
+
**Governing law:** England and Wales. Mandatory consumer
|
|
270
|
+
protections in your country of residence remain fully applicable.
|
|
271
|
+
|
|
272
|
+
## Support
|
|
273
|
+
|
|
274
|
+
There is no support.
|
|
275
|
+
|
|
276
|
+
- No email. No chat. No issue tracker.
|
|
277
|
+
- No guaranteed updates.
|
|
278
|
+
- No bug-fix commitments.
|
|
279
|
+
|
|
280
|
+
If you need a product with ongoing support, please look elsewhere.
|
|
281
|
+
|
|
282
|
+
## FAQ
|
|
283
|
+
|
|
284
|
+
**Q: Will this find every security issue in my code?**
|
|
285
|
+
A: No. It finds a curated set of dangerous patterns. It is a
|
|
286
|
+
sanity check, not a security audit.
|
|
287
|
+
|
|
288
|
+
**Q: Can I use it in CI?**
|
|
289
|
+
A: Yes. JSON and SARIF outputs are pure on stdout. Exit codes are
|
|
290
|
+
stable.
|
|
291
|
+
|
|
292
|
+
**Q: Does it phone home?**
|
|
293
|
+
A: No. Zero network calls. You can verify by reading the source
|
|
294
|
+
or by running it under strace.
|
|
295
|
+
|
|
296
|
+
**Q: Does it fix my code?**
|
|
297
|
+
A: No. It shows a typical before/after fix. You apply it yourself.
|
|
298
|
+
|
|
299
|
+
**Q: Does it support TypeScript?**
|
|
300
|
+
A: No. Python, JavaScript (.js, .mjs, .cjs).
|
|
301
|
+
|
|
302
|
+
**Q: What about false positives?**
|
|
303
|
+
A: Pattern-based scanners always produce some. Rules with lower
|
|
304
|
+
confidence are flagged as such. You can disable any rule in
|
|
305
|
+
rules.json or via policy overrides.
|
|
306
|
+
|
|
307
|
+
**Q: Can I modify the source?**
|
|
308
|
+
A: Yes, privately. See LICENSE_FAQ.md.
|
|
309
|
+
|
|
310
|
+
**Q: Can my team use it?**
|
|
311
|
+
A: Each developer using CodeFence on their own machine needs
|
|
312
|
+
their own license. One license covers one individual on up to
|
|
313
|
+
three devices.
|
|
314
|
+
|
|
315
|
+
**Q: How do I get updates?**
|
|
316
|
+
A: There are no guaranteed updates.
|
|
317
|
+
|
|
318
|
+
**Q: Can I get a refund?**
|
|
319
|
+
A: See REFUND_POLICY.md.
|
|
320
|
+
|
|
321
|
+
## A note on honesty
|
|
322
|
+
|
|
323
|
+
This product is built to do a specific, limited thing well. It
|
|
324
|
+
does not overstate what it can do. Every claim in this README is
|
|
325
|
+
traceable to a line of code or a test. If you find a claim that
|
|
326
|
+
is not supported by what the tool actually does, please report
|
|
327
|
+
it.
|
|
328
|
+
|
|
329
|
+
*End of README.*
|
|
@@ -40,7 +40,7 @@ from typing import Callable, Iterable, Iterator, Sequence
|
|
|
40
40
|
# =============================================================================
|
|
41
41
|
|
|
42
42
|
TOOL_NAME = "codefence"
|
|
43
|
-
TOOL_VERSION = "1.0.
|
|
43
|
+
TOOL_VERSION = "1.0.1"
|
|
44
44
|
RULES_SCHEMA = "codefence/rules-v1"
|
|
45
45
|
DEFAULT_MAX_SIZE = 2 * 1024 * 1024
|
|
46
46
|
DEFAULT_RULES_FILENAME = "rules.json"
|
|
@@ -3966,7 +3966,28 @@ def _build_argparser() -> argparse.ArgumentParser:
|
|
|
3966
3966
|
|
|
3967
3967
|
|
|
3968
3968
|
def _default_rules_path() -> Path:
|
|
3969
|
-
|
|
3969
|
+
"""Search common locations for rules.json.
|
|
3970
|
+
|
|
3971
|
+
Covers: source checkout, pip install with --user or --system,
|
|
3972
|
+
data-files installation under sys.prefix or sys.prefix/share,
|
|
3973
|
+
current working directory, and per-user config.
|
|
3974
|
+
"""
|
|
3975
|
+
here = Path(__file__).resolve().parent
|
|
3976
|
+
candidates = [
|
|
3977
|
+
here / DEFAULT_RULES_FILENAME,
|
|
3978
|
+
here.parent.parent.parent / DEFAULT_RULES_FILENAME,
|
|
3979
|
+
Path(sys.prefix) / DEFAULT_RULES_FILENAME,
|
|
3980
|
+
Path(sys.prefix) / "share" / "codefence" / DEFAULT_RULES_FILENAME,
|
|
3981
|
+
Path(sys.prefix) / "local" / DEFAULT_RULES_FILENAME,
|
|
3982
|
+
Path(sys.prefix) / "local" / "share" / "codefence" / DEFAULT_RULES_FILENAME,
|
|
3983
|
+
Path.cwd() / DEFAULT_RULES_FILENAME,
|
|
3984
|
+
Path.home() / ".codefence" / DEFAULT_RULES_FILENAME,
|
|
3985
|
+
Path.home() / ".config" / "codefence" / DEFAULT_RULES_FILENAME,
|
|
3986
|
+
]
|
|
3987
|
+
for c in candidates:
|
|
3988
|
+
if c.is_file():
|
|
3989
|
+
return c
|
|
3990
|
+
return candidates[0]
|
|
3970
3991
|
|
|
3971
3992
|
|
|
3972
3993
|
def _collect_paths(paths: Sequence[str],
|