codefence 1.0.1__tar.gz → 1.0.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 (30) hide show
  1. codefence-1.0.2/PKG-INFO +523 -0
  2. codefence-1.0.2/codefence.egg-info/PKG-INFO +523 -0
  3. {codefence-1.0.1 → codefence-1.0.2}/codefence.py +1 -1
  4. {codefence-1.0.1 → codefence-1.0.2}/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.2}/CHANGELOG.md +0 -0
  8. {codefence-1.0.1 → codefence-1.0.2}/LICENSE.txt +0 -0
  9. {codefence-1.0.1 → codefence-1.0.2}/LICENSE_FAQ.md +0 -0
  10. {codefence-1.0.1 → codefence-1.0.2}/NOTICE.md +0 -0
  11. {codefence-1.0.1 → codefence-1.0.2}/README.md +0 -0
  12. {codefence-1.0.1 → codefence-1.0.2}/REFUND_POLICY.md +0 -0
  13. {codefence-1.0.1 → codefence-1.0.2}/SECURITY.md +0 -0
  14. {codefence-1.0.1 → codefence-1.0.2}/TERMS_OF_USE.md +0 -0
  15. {codefence-1.0.1 → codefence-1.0.2}/codefence.egg-info/SOURCES.txt +0 -0
  16. {codefence-1.0.1 → codefence-1.0.2}/codefence.egg-info/dependency_links.txt +0 -0
  17. {codefence-1.0.1 → codefence-1.0.2}/codefence.egg-info/entry_points.txt +0 -0
  18. {codefence-1.0.1 → codefence-1.0.2}/codefence.egg-info/top_level.txt +0 -0
  19. {codefence-1.0.1 → codefence-1.0.2}/rules.json +0 -0
  20. {codefence-1.0.1 → codefence-1.0.2}/samples/bad_javascript.js +0 -0
  21. {codefence-1.0.1 → codefence-1.0.2}/samples/bad_python.py +0 -0
  22. {codefence-1.0.1 → codefence-1.0.2}/samples/clean_example.js +0 -0
  23. {codefence-1.0.1 → codefence-1.0.2}/samples/clean_example.py +0 -0
  24. {codefence-1.0.1 → codefence-1.0.2}/setup.cfg +0 -0
  25. {codefence-1.0.1 → codefence-1.0.2}/tests/test_baseline.py +0 -0
  26. {codefence-1.0.1 → codefence-1.0.2}/tests/test_history.py +0 -0
  27. {codefence-1.0.1 → codefence-1.0.2}/tests/test_integration.py +0 -0
  28. {codefence-1.0.1 → codefence-1.0.2}/tests/test_lexer.py +0 -0
  29. {codefence-1.0.1 → codefence-1.0.2}/tests/test_policy.py +0 -0
  30. {codefence-1.0.1 → codefence-1.0.2}/tests/test_rules.py +0 -0
@@ -0,0 +1,523 @@
1
+ Metadata-Version: 2.4
2
+ Name: codefence
3
+ Version: 1.0.2
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
+ Dynamic: license-file
224
+
225
+ # CodeFence
226
+
227
+ **A tiny offline policy gate for code.**
228
+
229
+ Check AI-generated code before it reaches Git.
230
+
231
+ ---
232
+
233
+ ## What it does
234
+
235
+ CodeFence is a single-file, zero-dependency Python CLI that scans
236
+ source code for selected dangerous patterns before you commit. It
237
+ runs a curated set of rules and reports findings with:
238
+
239
+ - severity (critical / high / medium / low / info)
240
+ - exact location (file:line:column)
241
+ - code snippet
242
+ - short remediation
243
+ - typical before/after fix example
244
+
245
+ It is designed around the risks commonly encountered in AI-assisted
246
+ development, but scans ordinary source code regardless of how it
247
+ was written.
248
+
249
+ **The gate workflow:**
250
+
251
+ AI writes code
252
+ |
253
+ v
254
+ CodeFence runs on staged files
255
+ |
256
+ v
257
+ policy evaluation (allow / warn / block)
258
+ |
259
+ v
260
+ PASS or BLOCKED
261
+ |
262
+ v
263
+ git commit
264
+
265
+ ## What it does NOT do
266
+
267
+ - Not an autofixer. It shows a typical fix; it does not edit files.
268
+ - Not a security audit. It is a pattern-based sanity checker.
269
+ - Not a replacement for Semgrep, CodeQL, or professional review.
270
+ - Not interprocedural. No dataflow, no taint analysis.
271
+ - Not a guarantee. A clean scan does not mean the code is secure.
272
+
273
+ ## Install
274
+
275
+ pip install codefence
276
+
277
+ Or run it directly:
278
+
279
+ python3 codefence.py app.py
280
+
281
+ ## Quick start
282
+
283
+ **One-time setup in a git repository:**
284
+
285
+ codefence init
286
+
287
+ This installs a pre-commit hook and creates .codefence/config.json.
288
+ Every commit is then gated automatically.
289
+
290
+ **Daily usage:**
291
+
292
+ codefence --staged # scan only what is staged
293
+ codefence --staged --diff # only NEW findings since baseline
294
+ codefence baseline # snapshot current findings
295
+
296
+ **One-off scans:**
297
+
298
+ codefence src/
299
+ codefence --format json --output report.json src/
300
+ codefence --format html --output report.html src/
301
+ codefence --format sarif --output results.sarif .
302
+
303
+ **Policy-as-code:**
304
+
305
+ codefence --policy company-policy.json --staged
306
+ codefence policy validate company-policy.json
307
+
308
+ **Explanation:**
309
+
310
+ codefence explain R002
311
+ ## The 30 rules
312
+
313
+ Rules are shipped in rules.json (human-readable JSON). You can
314
+ inspect them, and you can add or disable rules for your own use.
315
+
316
+ ### Secrets
317
+ - R001 - Hardcoded API keys / secrets
318
+ - R011 - Hardcoded database credentials
319
+ - R028 - Env var with hardcoded fallback secret
320
+
321
+ ### Injection
322
+ - R002 - SQL injection via string concatenation (Python)
323
+ - R003 - eval() / exec() on untrusted input (Python)
324
+ - R004 - Command injection via shell=True (Python)
325
+ - R005 - innerHTML with unsanitized data (JavaScript)
326
+ - R010 - Path traversal
327
+ - R014 - Prototype pollution (JavaScript)
328
+ - R019 - Unsafe deserialization (pickle, yaml.load)
329
+
330
+ ### Authentication
331
+ - R006 - Missing authentication on endpoints
332
+ - R015 - Missing rate limiting on public endpoints
333
+ - R018 - Open redirect
334
+ - R020 - Never-expiring tokens / JWT
335
+
336
+ ### Cryptography
337
+ - R008 - Insecure random for security tokens (Python)
338
+ - R009 - Disabled TLS/SSL verification
339
+ - R016 - MD5 / SHA1 for password hashing
340
+
341
+ ### Configuration
342
+ - R007 - Overly permissive CORS (*)
343
+ - R017 - Debug mode left enabled
344
+ - R021 - Missing security headers (Express)
345
+
346
+ ### Reliability
347
+ - R022 - Race conditions (check-then-act)
348
+ - R026 - HTTP request without timeout
349
+ - R027 - Naive datetime (no timezone, context-aware)
350
+
351
+ ### Quality
352
+ - R012 - Broad except: pass
353
+ - R013 - Mutable default arguments
354
+ - R023 - Logging sensitive data
355
+ - R024 - Unused imports / dead code
356
+ - R025 - Promise rejection ignored (JavaScript)
357
+
358
+ ### AI-specific
359
+ - R030 - Typosquatted package imports
360
+ - R031 - TODO / FIXME / HACK in new code
361
+
362
+ Each rule carries a confidence level and a stable rule_version +
363
+ fingerprint for baseline stability.
364
+
365
+ ## Configuration
366
+
367
+ Options can be passed as CLI flags or through a JSON config file
368
+ (auto-discovered at .codefence/config.json after 'codefence init').
369
+
370
+ Example .codefence/config.json:
371
+
372
+ {
373
+ "schema": "codefence/config-v1",
374
+ "format": "json",
375
+ "severity": "medium",
376
+ "include": ["*.py", "*.js"],
377
+ "exclude": ["node_modules", ".git", "venv", "samples"],
378
+ "max_size": 2097152,
379
+ "cache": false
380
+ }
381
+
382
+ Priority: CLI flags > config file > built-in defaults.
383
+
384
+ ### Optional cache
385
+
386
+ Pass --cache to enable a local cache at ~/.cache/codefence/. The
387
+ cache is keyed by SHA-256 of the file content plus a fingerprint
388
+ of rules.json. It is off by default. See SECURITY.md for how the
389
+ cache is protected.
390
+
391
+ ### Optional history
392
+
393
+ Pass --history to record this scan in a local SQLite database at
394
+ ~/.local/share/codefence/history.db. Off by default.
395
+
396
+ Set CODEFENCE_NO_HISTORY=1 to disable history entirely, even when
397
+ --history is set.
398
+
399
+ Query history:
400
+
401
+ codefence history
402
+ codefence stats
403
+ ## Security and privacy
404
+
405
+ - Zero network calls. Zero.
406
+ - Zero telemetry.
407
+ - Zero data upload.
408
+ - Writes only to --output, and optionally to:
409
+ ~/.cache/codefence/ (only when --cache is set)
410
+ ~/.local/share/codefence/ (only when --history is set)
411
+ - Never writes to the files you scan.
412
+ - Never executes the code you scan.
413
+
414
+ The full threat model is documented in SECURITY.md.
415
+
416
+ ## Verifying the download
417
+
418
+ Every shipped file is hashed in CHECKSUMS.txt. To verify:
419
+
420
+ sha256sum codefence.py rules.json
421
+
422
+ Compare the output with the corresponding lines in CHECKSUMS.txt.
423
+ If the hashes do not match, do not use the file.
424
+
425
+ ## Payment and pricing
426
+
427
+ **$12 USD, one-time.**
428
+
429
+ Includes the current major version (v1.x) and its maintenance
430
+ releases. No subscription. No support. No account.
431
+
432
+ Payments are available in cryptocurrency only:
433
+
434
+ - USDT (TRC20 or BEP20)
435
+ - USDC
436
+ - BTC
437
+ - TRX
438
+ - XRP
439
+
440
+ Official purchase channels:
441
+
442
+ - Getly
443
+ - SilkRoadx402
444
+ - ctlx.cc
445
+
446
+ If you find CodeFence on any other site claiming to sell it,
447
+ treat that site as unofficial.
448
+
449
+ ## License
450
+
451
+ Source-available. Not open source.
452
+
453
+ Summary:
454
+
455
+ - Personal use on up to 3 devices that you own or control.
456
+ - Read, study, and privately modify the source.
457
+ - No redistribution. No resale. No bundling.
458
+ - No scanning-as-a-service on a commercial basis.
459
+
460
+ For plain-language answers to common questions, see LICENSE_FAQ.md.
461
+ For the full legal terms, see LICENSE.txt and TERMS_OF_USE.md.
462
+
463
+ **Governing law:** England and Wales. Mandatory consumer
464
+ protections in your country of residence remain fully applicable.
465
+
466
+ ## Support
467
+
468
+ There is no support.
469
+
470
+ - No email. No chat. No issue tracker.
471
+ - No guaranteed updates.
472
+ - No bug-fix commitments.
473
+
474
+ If you need a product with ongoing support, please look elsewhere.
475
+
476
+ ## FAQ
477
+
478
+ **Q: Will this find every security issue in my code?**
479
+ A: No. It finds a curated set of dangerous patterns. It is a
480
+ sanity check, not a security audit.
481
+
482
+ **Q: Can I use it in CI?**
483
+ A: Yes. JSON and SARIF outputs are pure on stdout. Exit codes are
484
+ stable.
485
+
486
+ **Q: Does it phone home?**
487
+ A: No. Zero network calls. You can verify by reading the source
488
+ or by running it under strace.
489
+
490
+ **Q: Does it fix my code?**
491
+ A: No. It shows a typical before/after fix. You apply it yourself.
492
+
493
+ **Q: Does it support TypeScript?**
494
+ A: No. Python, JavaScript (.js, .mjs, .cjs).
495
+
496
+ **Q: What about false positives?**
497
+ A: Pattern-based scanners always produce some. Rules with lower
498
+ confidence are flagged as such. You can disable any rule in
499
+ rules.json or via policy overrides.
500
+
501
+ **Q: Can I modify the source?**
502
+ A: Yes, privately. See LICENSE_FAQ.md.
503
+
504
+ **Q: Can my team use it?**
505
+ A: Each developer using CodeFence on their own machine needs
506
+ their own license. One license covers one individual on up to
507
+ three devices.
508
+
509
+ **Q: How do I get updates?**
510
+ A: There are no guaranteed updates.
511
+
512
+ **Q: Can I get a refund?**
513
+ A: See REFUND_POLICY.md.
514
+
515
+ ## A note on honesty
516
+
517
+ This product is built to do a specific, limited thing well. It
518
+ does not overstate what it can do. Every claim in this README is
519
+ traceable to a line of code or a test. If you find a claim that
520
+ is not supported by what the tool actually does, please report
521
+ it.
522
+
523
+ *End of README.*