codefence 1.0.1__tar.gz → 1.0.3__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 (30) hide show
  1. codefence-1.0.3/PKG-INFO +522 -0
  2. codefence-1.0.3/codefence.egg-info/PKG-INFO +522 -0
  3. {codefence-1.0.1 → codefence-1.0.3}/codefence.py +1 -1
  4. {codefence-1.0.1 → codefence-1.0.3}/pyproject.toml +3 -4
  5. codefence-1.0.1/PKG-INFO +0 -329
  6. codefence-1.0.1/codefence.egg-info/PKG-INFO +0 -329
  7. {codefence-1.0.1 → codefence-1.0.3}/CHANGELOG.md +0 -0
  8. {codefence-1.0.1 → codefence-1.0.3}/LICENSE.txt +0 -0
  9. {codefence-1.0.1 → codefence-1.0.3}/LICENSE_FAQ.md +0 -0
  10. {codefence-1.0.1 → codefence-1.0.3}/NOTICE.md +0 -0
  11. {codefence-1.0.1 → codefence-1.0.3}/README.md +0 -0
  12. {codefence-1.0.1 → codefence-1.0.3}/REFUND_POLICY.md +0 -0
  13. {codefence-1.0.1 → codefence-1.0.3}/SECURITY.md +0 -0
  14. {codefence-1.0.1 → codefence-1.0.3}/TERMS_OF_USE.md +0 -0
  15. {codefence-1.0.1 → codefence-1.0.3}/codefence.egg-info/SOURCES.txt +0 -0
  16. {codefence-1.0.1 → codefence-1.0.3}/codefence.egg-info/dependency_links.txt +0 -0
  17. {codefence-1.0.1 → codefence-1.0.3}/codefence.egg-info/entry_points.txt +0 -0
  18. {codefence-1.0.1 → codefence-1.0.3}/codefence.egg-info/top_level.txt +0 -0
  19. {codefence-1.0.1 → codefence-1.0.3}/rules.json +0 -0
  20. {codefence-1.0.1 → codefence-1.0.3}/samples/bad_javascript.js +0 -0
  21. {codefence-1.0.1 → codefence-1.0.3}/samples/bad_python.py +0 -0
  22. {codefence-1.0.1 → codefence-1.0.3}/samples/clean_example.js +0 -0
  23. {codefence-1.0.1 → codefence-1.0.3}/samples/clean_example.py +0 -0
  24. {codefence-1.0.1 → codefence-1.0.3}/setup.cfg +0 -0
  25. {codefence-1.0.1 → codefence-1.0.3}/tests/test_baseline.py +0 -0
  26. {codefence-1.0.1 → codefence-1.0.3}/tests/test_history.py +0 -0
  27. {codefence-1.0.1 → codefence-1.0.3}/tests/test_integration.py +0 -0
  28. {codefence-1.0.1 → codefence-1.0.3}/tests/test_lexer.py +0 -0
  29. {codefence-1.0.1 → codefence-1.0.3}/tests/test_policy.py +0 -0
  30. {codefence-1.0.1 → codefence-1.0.3}/tests/test_rules.py +0 -0
@@ -0,0 +1,522 @@
1
+ Metadata-Version: 2.2
2
+ Name: codefence
3
+ Version: 1.0.3
4
+ Summary: A tiny offline policy gate for code. Check AI-generated code before it reaches Git.
5
+ Author: CodeFence
6
+ License: CODEFENCE
7
+ END USER LICENSE AGREEMENT (EULA)
8
+ Version 1.0.0
9
+
10
+ Copyright (c) 2026 CodeFence. All rights reserved.
11
+
12
+ PLEASE READ THIS AGREEMENT CAREFULLY BEFORE USING THIS SOFTWARE.
13
+ BY USING THIS SOFTWARE, YOU AGREE TO BE BOUND BY ITS TERMS.
14
+
15
+ --------------------------------------------------------------------
16
+ 1. DEFINITIONS
17
+ --------------------------------------------------------------------
18
+
19
+ "Software" means the CodeFence command-line tool, its source
20
+ code, documentation, rules file (rules.json), sample files, and any
21
+ accompanying materials delivered together.
22
+
23
+ "Licensor" means the copyright holder of the Software.
24
+
25
+ "You" or "Licensee" means the individual person who purchased or
26
+ acquired the Software.
27
+
28
+ "Personal Use" means use of the Software by a single individual, on
29
+ computers that the individual owns or controls, for that individual's
30
+ own development work. Personal Use does not include use on behalf of
31
+ a commercial entity as a service to third parties.
32
+
33
+ --------------------------------------------------------------------
34
+ 2. GRANT OF LICENSE
35
+ --------------------------------------------------------------------
36
+
37
+ Subject to your compliance with this Agreement, the Licensor grants
38
+ You a non-exclusive, non-transferable, worldwide, perpetual license
39
+ to:
40
+
41
+ (a) install and use the Software on up to three (3) devices that
42
+ You personally own or control;
43
+ (b) read, study, and audit the source code for Your own personal
44
+ understanding of its behavior;
45
+ (c) create private modifications of the source code for Your own
46
+ personal use, provided such modifications remain strictly
47
+ private and are not distributed.
48
+
49
+ This is a license, not a sale. The Licensor retains all right, title,
50
+ and interest in and to the Software.
51
+
52
+ --------------------------------------------------------------------
53
+ 3. RESTRICTIONS
54
+ --------------------------------------------------------------------
55
+
56
+ You may NOT:
57
+
58
+ (a) redistribute, sublicense, sell, resell, rent, lease, lend, or
59
+ otherwise transfer the Software or any modification of it;
60
+ (b) publish, share, or make available the source code, in original
61
+ or modified form, on any public or private repository, forum,
62
+ chat, file-sharing service, or bundle;
63
+ (c) include the Software in any commercial product, bundle, or
64
+ service offering;
65
+ (d) remove, alter, or obscure any copyright, license, or
66
+ attribution notice in the Software;
67
+ (e) use the Software for any unlawful purpose;
68
+ (f) use the Software to provide scanning-as-a-service to third
69
+ parties on a commercial basis.
70
+
71
+ --------------------------------------------------------------------
72
+ 4. SOURCE CODE AVAILABILITY
73
+ --------------------------------------------------------------------
74
+
75
+ The Software is delivered in human-readable source form. This is done
76
+ intentionally so that any user can inspect exactly what the tool does,
77
+ confirm that it performs no network calls, and verify that it does not
78
+ touch files outside the scope documented in SECURITY.md.
79
+
80
+ Availability of the source code under this Agreement does NOT make
81
+ the Software open source. Open-source licenses grant redistribution
82
+ rights; this Agreement does not.
83
+
84
+ --------------------------------------------------------------------
85
+ 5. NO SUPPORT, NO UPDATES
86
+ --------------------------------------------------------------------
87
+
88
+ The Software is provided as-is at the time of purchase. The Licensor
89
+ has no obligation to:
90
+
91
+ (a) provide technical support, bug fixes, or updates;
92
+ (b) maintain compatibility with future Python versions, operating
93
+ systems, or third-party libraries;
94
+ (c) respond to any communication regarding the Software.
95
+
96
+ Any future updates, if ever released, are provided at the Licensor's
97
+ sole discretion and do not extend the obligations of this Agreement.
98
+
99
+ --------------------------------------------------------------------
100
+ 6. CONSUMER RIGHTS (EU/UK)
101
+ --------------------------------------------------------------------
102
+
103
+ If You are a consumer resident in the European Union or the United
104
+ Kingdom, nothing in this Agreement limits or excludes any statutory
105
+ right or remedy You have under applicable mandatory consumer law.
106
+
107
+ In particular:
108
+
109
+ (a) RIGHT OF WITHDRAWAL (EU): You have the right to withdraw from
110
+ the purchase within fourteen (14) days of delivery, without
111
+ giving any reason, provided that You have not downloaded the
112
+ Software file. Once digital content has been downloaded, the
113
+ withdrawal right is typically waived under the EU Consumer
114
+ Rights Directive (2011/83/EU), Article 16(m), unless the
115
+ vendor has obtained Your prior express consent and
116
+ acknowledgement of that waiver.
117
+
118
+ (b) CONFORMITY: If the Software does not conform to its
119
+ description, You may be entitled to a remedy under the
120
+ applicable EU/UK consumer legislation.
121
+
122
+ To exercise the right of withdrawal, follow the process documented
123
+ in REFUND_POLICY.md.
124
+
125
+ --------------------------------------------------------------------
126
+ 7. DISCLAIMER OF WARRANTY
127
+ --------------------------------------------------------------------
128
+
129
+ THE SOFTWARE IS PROVIDED "AS IS" AND "AS AVAILABLE", WITHOUT WARRANTY
130
+ OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
131
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
132
+ NON-INFRINGEMENT.
133
+
134
+ THE LICENSOR DOES NOT WARRANT THAT:
135
+
136
+ (a) the Software will detect every issue in the scanned code;
137
+ (b) the Software will produce no false positives or false negatives;
138
+ (c) a clean scan means the scanned code is secure, correct, or
139
+ complete;
140
+ (d) the Software will run uninterrupted or error-free on every
141
+ environment.
142
+
143
+ The Software is a pattern-based sanity checker. It is NOT a security
144
+ audit, NOT a substitute for professional security review, and NOT a
145
+ guarantee of code quality.
146
+
147
+ --------------------------------------------------------------------
148
+ 8. LIMITATION OF LIABILITY
149
+ --------------------------------------------------------------------
150
+
151
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE TOTAL
152
+ AGGREGATE LIABILITY OF THE LICENSOR ARISING OUT OF OR RELATING TO
153
+ THIS AGREEMENT OR THE SOFTWARE SHALL NOT EXCEED THE AMOUNT ACTUALLY
154
+ PAID BY YOU FOR THE SOFTWARE.
155
+
156
+ IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY INDIRECT,
157
+ INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR FOR ANY
158
+ LOSS OF PROFITS, DATA, BUSINESS, OR GOODWILL, ARISING OUT OF OR
159
+ RELATING TO THE USE OR INABILITY TO USE THE SOFTWARE.
160
+
161
+ NOTHING IN THIS SECTION EXCLUDES OR LIMITS LIABILITY THAT CANNOT BE
162
+ EXCLUDED OR LIMITED UNDER APPLICABLE MANDATORY LAW.
163
+
164
+ --------------------------------------------------------------------
165
+ 9. TERMINATION
166
+ --------------------------------------------------------------------
167
+
168
+ This Agreement is effective until terminated. Your rights under this
169
+ Agreement terminate automatically if You materially breach any of its
170
+ terms. Upon termination, You must stop using the Software and delete
171
+ all copies in Your possession or control.
172
+
173
+ Sections 3, 4, 7, 8, 10, and 11 survive termination.
174
+
175
+ --------------------------------------------------------------------
176
+ 10. GOVERNING LAW
177
+ --------------------------------------------------------------------
178
+
179
+ This Agreement is governed by the laws of England and Wales, without
180
+ regard to its conflict of law rules. Any dispute that cannot be
181
+ resolved amicably shall be subject to the exclusive jurisdiction of
182
+ the courts of England and Wales, except that mandatory consumer
183
+ protections in Your country of residence may grant You the right to
184
+ bring proceedings in Your local courts.
185
+
186
+ --------------------------------------------------------------------
187
+ 11. ENTIRE AGREEMENT
188
+ --------------------------------------------------------------------
189
+
190
+ This Agreement, together with TERMS_OF_USE.md, REFUND_POLICY.md, and
191
+ SECURITY.md, constitutes the entire agreement between You and the
192
+ Licensor concerning the Software.
193
+
194
+ If any provision is held unenforceable, the remaining provisions
195
+ remain in full force and effect.
196
+
197
+ --------------------------------------------------------------------
198
+ END OF LICENSE
199
+ --------------------------------------------------------------------
200
+
201
+ Project-URL: Homepage, https://codefence.dev
202
+ Project-URL: Source, https://github.com/USERNAME/codefence
203
+ Project-URL: Issues, https://github.com/USERNAME/codefence/issues
204
+ Project-URL: Changelog, https://github.com/USERNAME/codefence/blob/main/CHANGELOG.md
205
+ Keywords: security,static-analysis,pre-commit,git-hook,ai-generated-code,sast,sarif,offline,policy
206
+ Classifier: Development Status :: 5 - Production/Stable
207
+ Classifier: Environment :: Console
208
+ Classifier: Intended Audience :: Developers
209
+ Classifier: Operating System :: OS Independent
210
+ Classifier: Programming Language :: Python :: 3
211
+ Classifier: Programming Language :: Python :: 3.10
212
+ Classifier: Programming Language :: Python :: 3.11
213
+ Classifier: Programming Language :: Python :: 3.12
214
+ Classifier: Programming Language :: Python :: 3.13
215
+ Classifier: Topic :: Software Development :: Quality Assurance
216
+ Classifier: Topic :: Software Development :: Testing
217
+ Classifier: Topic :: Security
218
+ Requires-Python: >=3.10
219
+ Description-Content-Type: text/markdown
220
+ License-File: LICENSE.txt
221
+ License-File: LICENSE_FAQ.md
222
+ License-File: NOTICE.md
223
+
224
+ # CodeFence
225
+
226
+ **A tiny offline policy gate for code.**
227
+
228
+ Check AI-generated code before it reaches Git.
229
+
230
+ ---
231
+
232
+ ## What it does
233
+
234
+ CodeFence is a single-file, zero-dependency Python CLI that scans
235
+ source code for selected dangerous patterns before you commit. It
236
+ runs a curated set of rules and reports findings with:
237
+
238
+ - severity (critical / high / medium / low / info)
239
+ - exact location (file:line:column)
240
+ - code snippet
241
+ - short remediation
242
+ - typical before/after fix example
243
+
244
+ It is designed around the risks commonly encountered in AI-assisted
245
+ development, but scans ordinary source code regardless of how it
246
+ was written.
247
+
248
+ **The gate workflow:**
249
+
250
+ AI writes code
251
+ |
252
+ v
253
+ CodeFence runs on staged files
254
+ |
255
+ v
256
+ policy evaluation (allow / warn / block)
257
+ |
258
+ v
259
+ PASS or BLOCKED
260
+ |
261
+ v
262
+ git commit
263
+
264
+ ## What it does NOT do
265
+
266
+ - Not an autofixer. It shows a typical fix; it does not edit files.
267
+ - Not a security audit. It is a pattern-based sanity checker.
268
+ - Not a replacement for Semgrep, CodeQL, or professional review.
269
+ - Not interprocedural. No dataflow, no taint analysis.
270
+ - Not a guarantee. A clean scan does not mean the code is secure.
271
+
272
+ ## Install
273
+
274
+ pip install codefence
275
+
276
+ Or run it directly:
277
+
278
+ python3 codefence.py app.py
279
+
280
+ ## Quick start
281
+
282
+ **One-time setup in a git repository:**
283
+
284
+ codefence init
285
+
286
+ This installs a pre-commit hook and creates .codefence/config.json.
287
+ Every commit is then gated automatically.
288
+
289
+ **Daily usage:**
290
+
291
+ codefence --staged # scan only what is staged
292
+ codefence --staged --diff # only NEW findings since baseline
293
+ codefence baseline # snapshot current findings
294
+
295
+ **One-off scans:**
296
+
297
+ codefence src/
298
+ codefence --format json --output report.json src/
299
+ codefence --format html --output report.html src/
300
+ codefence --format sarif --output results.sarif .
301
+
302
+ **Policy-as-code:**
303
+
304
+ codefence --policy company-policy.json --staged
305
+ codefence policy validate company-policy.json
306
+
307
+ **Explanation:**
308
+
309
+ codefence explain R002
310
+ ## The 30 rules
311
+
312
+ Rules are shipped in rules.json (human-readable JSON). You can
313
+ inspect them, and you can add or disable rules for your own use.
314
+
315
+ ### Secrets
316
+ - R001 - Hardcoded API keys / secrets
317
+ - R011 - Hardcoded database credentials
318
+ - R028 - Env var with hardcoded fallback secret
319
+
320
+ ### Injection
321
+ - R002 - SQL injection via string concatenation (Python)
322
+ - R003 - eval() / exec() on untrusted input (Python)
323
+ - R004 - Command injection via shell=True (Python)
324
+ - R005 - innerHTML with unsanitized data (JavaScript)
325
+ - R010 - Path traversal
326
+ - R014 - Prototype pollution (JavaScript)
327
+ - R019 - Unsafe deserialization (pickle, yaml.load)
328
+
329
+ ### Authentication
330
+ - R006 - Missing authentication on endpoints
331
+ - R015 - Missing rate limiting on public endpoints
332
+ - R018 - Open redirect
333
+ - R020 - Never-expiring tokens / JWT
334
+
335
+ ### Cryptography
336
+ - R008 - Insecure random for security tokens (Python)
337
+ - R009 - Disabled TLS/SSL verification
338
+ - R016 - MD5 / SHA1 for password hashing
339
+
340
+ ### Configuration
341
+ - R007 - Overly permissive CORS (*)
342
+ - R017 - Debug mode left enabled
343
+ - R021 - Missing security headers (Express)
344
+
345
+ ### Reliability
346
+ - R022 - Race conditions (check-then-act)
347
+ - R026 - HTTP request without timeout
348
+ - R027 - Naive datetime (no timezone, context-aware)
349
+
350
+ ### Quality
351
+ - R012 - Broad except: pass
352
+ - R013 - Mutable default arguments
353
+ - R023 - Logging sensitive data
354
+ - R024 - Unused imports / dead code
355
+ - R025 - Promise rejection ignored (JavaScript)
356
+
357
+ ### AI-specific
358
+ - R030 - Typosquatted package imports
359
+ - R031 - TODO / FIXME / HACK in new code
360
+
361
+ Each rule carries a confidence level and a stable rule_version +
362
+ fingerprint for baseline stability.
363
+
364
+ ## Configuration
365
+
366
+ Options can be passed as CLI flags or through a JSON config file
367
+ (auto-discovered at .codefence/config.json after 'codefence init').
368
+
369
+ Example .codefence/config.json:
370
+
371
+ {
372
+ "schema": "codefence/config-v1",
373
+ "format": "json",
374
+ "severity": "medium",
375
+ "include": ["*.py", "*.js"],
376
+ "exclude": ["node_modules", ".git", "venv", "samples"],
377
+ "max_size": 2097152,
378
+ "cache": false
379
+ }
380
+
381
+ Priority: CLI flags > config file > built-in defaults.
382
+
383
+ ### Optional cache
384
+
385
+ Pass --cache to enable a local cache at ~/.cache/codefence/. The
386
+ cache is keyed by SHA-256 of the file content plus a fingerprint
387
+ of rules.json. It is off by default. See SECURITY.md for how the
388
+ cache is protected.
389
+
390
+ ### Optional history
391
+
392
+ Pass --history to record this scan in a local SQLite database at
393
+ ~/.local/share/codefence/history.db. Off by default.
394
+
395
+ Set CODEFENCE_NO_HISTORY=1 to disable history entirely, even when
396
+ --history is set.
397
+
398
+ Query history:
399
+
400
+ codefence history
401
+ codefence stats
402
+ ## Security and privacy
403
+
404
+ - Zero network calls. Zero.
405
+ - Zero telemetry.
406
+ - Zero data upload.
407
+ - Writes only to --output, and optionally to:
408
+ ~/.cache/codefence/ (only when --cache is set)
409
+ ~/.local/share/codefence/ (only when --history is set)
410
+ - Never writes to the files you scan.
411
+ - Never executes the code you scan.
412
+
413
+ The full threat model is documented in SECURITY.md.
414
+
415
+ ## Verifying the download
416
+
417
+ Every shipped file is hashed in CHECKSUMS.txt. To verify:
418
+
419
+ sha256sum codefence.py rules.json
420
+
421
+ Compare the output with the corresponding lines in CHECKSUMS.txt.
422
+ If the hashes do not match, do not use the file.
423
+
424
+ ## Payment and pricing
425
+
426
+ **$12 USD, one-time.**
427
+
428
+ Includes the current major version (v1.x) and its maintenance
429
+ releases. No subscription. No support. No account.
430
+
431
+ Payments are available in cryptocurrency only:
432
+
433
+ - USDT (TRC20 or BEP20)
434
+ - USDC
435
+ - BTC
436
+ - TRX
437
+ - XRP
438
+
439
+ Official purchase channels:
440
+
441
+ - Getly
442
+ - SilkRoadx402
443
+ - ctlx.cc
444
+
445
+ If you find CodeFence on any other site claiming to sell it,
446
+ treat that site as unofficial.
447
+
448
+ ## License
449
+
450
+ Source-available. Not open source.
451
+
452
+ Summary:
453
+
454
+ - Personal use on up to 3 devices that you own or control.
455
+ - Read, study, and privately modify the source.
456
+ - No redistribution. No resale. No bundling.
457
+ - No scanning-as-a-service on a commercial basis.
458
+
459
+ For plain-language answers to common questions, see LICENSE_FAQ.md.
460
+ For the full legal terms, see LICENSE.txt and TERMS_OF_USE.md.
461
+
462
+ **Governing law:** England and Wales. Mandatory consumer
463
+ protections in your country of residence remain fully applicable.
464
+
465
+ ## Support
466
+
467
+ There is no support.
468
+
469
+ - No email. No chat. No issue tracker.
470
+ - No guaranteed updates.
471
+ - No bug-fix commitments.
472
+
473
+ If you need a product with ongoing support, please look elsewhere.
474
+
475
+ ## FAQ
476
+
477
+ **Q: Will this find every security issue in my code?**
478
+ A: No. It finds a curated set of dangerous patterns. It is a
479
+ sanity check, not a security audit.
480
+
481
+ **Q: Can I use it in CI?**
482
+ A: Yes. JSON and SARIF outputs are pure on stdout. Exit codes are
483
+ stable.
484
+
485
+ **Q: Does it phone home?**
486
+ A: No. Zero network calls. You can verify by reading the source
487
+ or by running it under strace.
488
+
489
+ **Q: Does it fix my code?**
490
+ A: No. It shows a typical before/after fix. You apply it yourself.
491
+
492
+ **Q: Does it support TypeScript?**
493
+ A: No. Python, JavaScript (.js, .mjs, .cjs).
494
+
495
+ **Q: What about false positives?**
496
+ A: Pattern-based scanners always produce some. Rules with lower
497
+ confidence are flagged as such. You can disable any rule in
498
+ rules.json or via policy overrides.
499
+
500
+ **Q: Can I modify the source?**
501
+ A: Yes, privately. See LICENSE_FAQ.md.
502
+
503
+ **Q: Can my team use it?**
504
+ A: Each developer using CodeFence on their own machine needs
505
+ their own license. One license covers one individual on up to
506
+ three devices.
507
+
508
+ **Q: How do I get updates?**
509
+ A: There are no guaranteed updates.
510
+
511
+ **Q: Can I get a refund?**
512
+ A: See REFUND_POLICY.md.
513
+
514
+ ## A note on honesty
515
+
516
+ This product is built to do a specific, limited thing well. It
517
+ does not overstate what it can do. Every claim in this README is
518
+ traceable to a line of code or a test. If you find a claim that
519
+ is not supported by what the tool actually does, please report
520
+ it.
521
+
522
+ *End of README.*