codefence 1.0.0__py3-none-any.whl

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.
@@ -0,0 +1,138 @@
1
+ # Changelog
2
+
3
+ All notable changes to CodeFence.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
+ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] — 2026-09-16
9
+
10
+ ### Added
11
+ - Initial public release.
12
+ - Offline, single-file CLI scanner for AI-generated Python and
13
+ JavaScript source code.
14
+ - 28 pattern rules across secrets, injection, cryptography,
15
+ authentication, configuration, quality, and reliability.
16
+ - Four output formats: colored CLI, JSON, HTML (dark/light theme),
17
+ SARIF 2.1.0.
18
+ - Support for `.py`, `.js`, `.mjs`, `.cjs` input files.
19
+ - Config file (`--config`), glob include/exclude (`--include`,
20
+ `--exclude`), and severity threshold (`--severity`).
21
+ - Optional local cache (`--cache`), off by default, mode 0o600.
22
+ - Strict `rules.json` schema validation and ReDoS mitigation
23
+ (line-by-line regex with per-call timeout).
24
+ - Friendly welcome screen on zero-argument invocation and a full
25
+ `--help` reference.
26
+ - JSON and SARIF outputs are pure on stdout (no banners), suitable
27
+ for CI/CD and agent pipelines.
28
+
29
+ ### Security
30
+ - Zero network calls. Zero telemetry.
31
+ - Zero third-party dependencies (Python standard library only).
32
+ - Cache path is not user-overridable via environment variables.
33
+ - `CHECKSUMS.txt` shipped for verification.
34
+
35
+ ### Known limitations
36
+ - Autofix is intentionally not provided.
37
+ - No TypeScript support.
38
+ - No interprocedural or dataflow analysis.
39
+ - Clean scan does not mean the code is secure.
40
+
41
+ [1.0.0]: https://example.invalid/codefence/releases/v1.0.0
42
+
43
+ ### Added during pre-release preparation (Day 12)
44
+ - `SECURITY.md` — transparent threat model and design rationale.
45
+ - `NOTICE.md` — statement on source availability (source-readable, not
46
+ open source).
47
+ - `LICENSE.txt` — Custom Source-Available EULA with machine-use and
48
+ redistribution restrictions.
49
+ - `TERMS_OF_USE.md` — Terms of Use with explicit scope, payment, and
50
+ no-support clauses.
51
+ - `REFUND_POLICY.md` — Refund policy preserving EU/UK statutory
52
+ consumer rights.
53
+ - `README.md` — full user-facing documentation, honest about scope
54
+ and limitations.
55
+ - `tools/make_checksums.py` — internal helper for generating
56
+ `CHECKSUMS.txt`.
57
+ - Copyright header in `codefence.py`.
58
+ - `fix_before` / `fix_after` fields per rule (typical fix examples).
59
+ - CLI fix blocks and HTML fix blocks with Copy button.
60
+ - HTML dark/light theme toggle with system-preference detection.
61
+ - Friendly welcome screen on zero-argument invocation.
62
+ - Comprehensive `--help` reference.
63
+ - `--config`, `--include`, `--exclude` flags for flexible scanning.
64
+ - ReDoS mitigation: line-by-line regex with per-call timeout.
65
+ - Strict `rules.json` schema validation.
66
+ - Optional cache (opt-in, mode 0o600, keyed by SHA-256).
67
+
68
+ ### Changed
69
+ - Default excludes expanded to cover common build/cache directories.
70
+ - `--severity` accepts `info` for full verbosity.
71
+
72
+ ### Fixed
73
+ - Removed duplicate `debug=True` pattern in R017.
74
+ - R024 no longer flags `from __future__ import annotations`.
75
+ - R027 is now context-aware (only fires in security-relevant contexts).
76
+ - Empty target list produces a clear message instead of silent output.
77
+
78
+ ### Added (post-consultation, Days 14-28)
79
+ - `codefence init` — one-command setup (config + hook)
80
+ - `codefence init-hook` / `uninstall-hook` — git pre-commit integration
81
+ - `codefence init-github` — GitHub Actions workflow installer
82
+ - `codefence baseline` — snapshot current findings to .codefence/baseline.json
83
+ - `--staged` — scan only git-staged files
84
+ - `--diff` — report only new findings since baseline
85
+ - `--no-baseline` — ignore baseline even with --diff
86
+ - `--policy FILE` — policy-as-code with ORG-* rules and allow/warn/block
87
+ - `codefence policy validate FILE` — schema validation for policy files
88
+ - `--evidence FILE` — deterministic evidence JSON
89
+ (result_hash, rules_hash, policy_hash, baseline_hash, commit_sha, scan_id)
90
+ - `--history` — record scans in SQLite at ~/.local/share/codefence/history.db
91
+ - `codefence history` — recent scans table
92
+ - `codefence stats` — summary statistics
93
+ - `codefence explain RXXX` — structured rule explanation
94
+ - `# noqa` / `# noqa: R001,R002` inline suppression
95
+ - `CODEFENCE_CMD` / `CODEFENCE_RULES` env overrides for the hook
96
+ - `CODEFENCE_NO_HISTORY=1` env to disable history
97
+ - Two AI-specific rules: R030 (typosquatted imports), R031 (TODO/FIXME/HACK)
98
+ - Rule versioning + fingerprints (rule_version, fingerprint)
99
+ - SARIF partialFingerprints with `codefence/v1` key
100
+ - Auto-discovery of `.codefence/config.json`
101
+ - `pyproject.toml` (PEP 621), pip-installable as `codefence`
102
+ - Console scripts: `cfence` and `codefence`
103
+ - LICENSE_FAQ.md
104
+ - 80 tests (unit + integration), pytest suite
105
+ - Internal docs: NAMING_DUE_DILIGENCE.md
106
+
107
+ ### Changed (post-consultation)
108
+ - Renamed product from "AI Code Sanitizer" to "CodeFence"
109
+ - Product definition: "A tiny offline policy gate for code."
110
+ - Acquisition tagline: "Check AI-generated code before it reaches Git."
111
+ - README rewritten (no forbidden phrases, no geographic identity)
112
+ - LICENSE_FAQ.md added for source-available clarity
113
+ - SECURITY.md updated (history DB, path corrections)
114
+ - `--help` USAGE line now shows `cfence [OPTIONS] PATH...`
115
+ - Default `action` for all rules: `block`
116
+
117
+ ### Removed (from earlier v1.0 plan)
118
+ - Watch mode (deferred)
119
+ - VS Code extension (deferred to v1.1)
120
+ - R029 hallucinated packages (deferred to v1.1)
121
+ - R032 prompt-context secrets (deferred to v1.1)
122
+ - Team tier pricing (deferred to v1.1)
123
+
124
+ ### Fixed
125
+ - R024 no longer flags `from __future__ import annotations`
126
+ - R027 context-aware (only fires in security-relevant contexts)
127
+ - R017 duplicate pattern removed
128
+ - R022 expanded to detect both TOCTOU directions
129
+ - Hook env override (CODEFENCE_CMD) for testing and custom installs
130
+
131
+ ### Security
132
+ - ReDoS mitigation: line-by-line regex, per-call timeout
133
+ - rules.json schema validation (strict)
134
+ - Cache mode 0o600, dir 0o700
135
+ - History DB mode 0o600, dir 0o700
136
+ - Symlink rejection in cache
137
+ - Atomic writes (mkstemp + os.replace)
138
+ - noqa directives parsed safely (regex, no eval)
@@ -0,0 +1,194 @@
1
+ CODEFENCE
2
+ END USER LICENSE AGREEMENT (EULA)
3
+ Version 1.0.0
4
+
5
+ Copyright (c) 2026 CodeFence. All rights reserved.
6
+
7
+ PLEASE READ THIS AGREEMENT CAREFULLY BEFORE USING THIS SOFTWARE.
8
+ BY USING THIS SOFTWARE, YOU AGREE TO BE BOUND BY ITS TERMS.
9
+
10
+ --------------------------------------------------------------------
11
+ 1. DEFINITIONS
12
+ --------------------------------------------------------------------
13
+
14
+ "Software" means the CodeFence command-line tool, its source
15
+ code, documentation, rules file (rules.json), sample files, and any
16
+ accompanying materials delivered together.
17
+
18
+ "Licensor" means the copyright holder of the Software.
19
+
20
+ "You" or "Licensee" means the individual person who purchased or
21
+ acquired the Software.
22
+
23
+ "Personal Use" means use of the Software by a single individual, on
24
+ computers that the individual owns or controls, for that individual's
25
+ own development work. Personal Use does not include use on behalf of
26
+ a commercial entity as a service to third parties.
27
+
28
+ --------------------------------------------------------------------
29
+ 2. GRANT OF LICENSE
30
+ --------------------------------------------------------------------
31
+
32
+ Subject to your compliance with this Agreement, the Licensor grants
33
+ You a non-exclusive, non-transferable, worldwide, perpetual license
34
+ to:
35
+
36
+ (a) install and use the Software on up to three (3) devices that
37
+ You personally own or control;
38
+ (b) read, study, and audit the source code for Your own personal
39
+ understanding of its behavior;
40
+ (c) create private modifications of the source code for Your own
41
+ personal use, provided such modifications remain strictly
42
+ private and are not distributed.
43
+
44
+ This is a license, not a sale. The Licensor retains all right, title,
45
+ and interest in and to the Software.
46
+
47
+ --------------------------------------------------------------------
48
+ 3. RESTRICTIONS
49
+ --------------------------------------------------------------------
50
+
51
+ You may NOT:
52
+
53
+ (a) redistribute, sublicense, sell, resell, rent, lease, lend, or
54
+ otherwise transfer the Software or any modification of it;
55
+ (b) publish, share, or make available the source code, in original
56
+ or modified form, on any public or private repository, forum,
57
+ chat, file-sharing service, or bundle;
58
+ (c) include the Software in any commercial product, bundle, or
59
+ service offering;
60
+ (d) remove, alter, or obscure any copyright, license, or
61
+ attribution notice in the Software;
62
+ (e) use the Software for any unlawful purpose;
63
+ (f) use the Software to provide scanning-as-a-service to third
64
+ parties on a commercial basis.
65
+
66
+ --------------------------------------------------------------------
67
+ 4. SOURCE CODE AVAILABILITY
68
+ --------------------------------------------------------------------
69
+
70
+ The Software is delivered in human-readable source form. This is done
71
+ intentionally so that any user can inspect exactly what the tool does,
72
+ confirm that it performs no network calls, and verify that it does not
73
+ touch files outside the scope documented in SECURITY.md.
74
+
75
+ Availability of the source code under this Agreement does NOT make
76
+ the Software open source. Open-source licenses grant redistribution
77
+ rights; this Agreement does not.
78
+
79
+ --------------------------------------------------------------------
80
+ 5. NO SUPPORT, NO UPDATES
81
+ --------------------------------------------------------------------
82
+
83
+ The Software is provided as-is at the time of purchase. The Licensor
84
+ has no obligation to:
85
+
86
+ (a) provide technical support, bug fixes, or updates;
87
+ (b) maintain compatibility with future Python versions, operating
88
+ systems, or third-party libraries;
89
+ (c) respond to any communication regarding the Software.
90
+
91
+ Any future updates, if ever released, are provided at the Licensor's
92
+ sole discretion and do not extend the obligations of this Agreement.
93
+
94
+ --------------------------------------------------------------------
95
+ 6. CONSUMER RIGHTS (EU/UK)
96
+ --------------------------------------------------------------------
97
+
98
+ If You are a consumer resident in the European Union or the United
99
+ Kingdom, nothing in this Agreement limits or excludes any statutory
100
+ right or remedy You have under applicable mandatory consumer law.
101
+
102
+ In particular:
103
+
104
+ (a) RIGHT OF WITHDRAWAL (EU): You have the right to withdraw from
105
+ the purchase within fourteen (14) days of delivery, without
106
+ giving any reason, provided that You have not downloaded the
107
+ Software file. Once digital content has been downloaded, the
108
+ withdrawal right is typically waived under the EU Consumer
109
+ Rights Directive (2011/83/EU), Article 16(m), unless the
110
+ vendor has obtained Your prior express consent and
111
+ acknowledgement of that waiver.
112
+
113
+ (b) CONFORMITY: If the Software does not conform to its
114
+ description, You may be entitled to a remedy under the
115
+ applicable EU/UK consumer legislation.
116
+
117
+ To exercise the right of withdrawal, follow the process documented
118
+ in REFUND_POLICY.md.
119
+
120
+ --------------------------------------------------------------------
121
+ 7. DISCLAIMER OF WARRANTY
122
+ --------------------------------------------------------------------
123
+
124
+ THE SOFTWARE IS PROVIDED "AS IS" AND "AS AVAILABLE", WITHOUT WARRANTY
125
+ OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
126
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
127
+ NON-INFRINGEMENT.
128
+
129
+ THE LICENSOR DOES NOT WARRANT THAT:
130
+
131
+ (a) the Software will detect every issue in the scanned code;
132
+ (b) the Software will produce no false positives or false negatives;
133
+ (c) a clean scan means the scanned code is secure, correct, or
134
+ complete;
135
+ (d) the Software will run uninterrupted or error-free on every
136
+ environment.
137
+
138
+ The Software is a pattern-based sanity checker. It is NOT a security
139
+ audit, NOT a substitute for professional security review, and NOT a
140
+ guarantee of code quality.
141
+
142
+ --------------------------------------------------------------------
143
+ 8. LIMITATION OF LIABILITY
144
+ --------------------------------------------------------------------
145
+
146
+ TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE TOTAL
147
+ AGGREGATE LIABILITY OF THE LICENSOR ARISING OUT OF OR RELATING TO
148
+ THIS AGREEMENT OR THE SOFTWARE SHALL NOT EXCEED THE AMOUNT ACTUALLY
149
+ PAID BY YOU FOR THE SOFTWARE.
150
+
151
+ IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY INDIRECT,
152
+ INCIDENTAL, SPECIAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR FOR ANY
153
+ LOSS OF PROFITS, DATA, BUSINESS, OR GOODWILL, ARISING OUT OF OR
154
+ RELATING TO THE USE OR INABILITY TO USE THE SOFTWARE.
155
+
156
+ NOTHING IN THIS SECTION EXCLUDES OR LIMITS LIABILITY THAT CANNOT BE
157
+ EXCLUDED OR LIMITED UNDER APPLICABLE MANDATORY LAW.
158
+
159
+ --------------------------------------------------------------------
160
+ 9. TERMINATION
161
+ --------------------------------------------------------------------
162
+
163
+ This Agreement is effective until terminated. Your rights under this
164
+ Agreement terminate automatically if You materially breach any of its
165
+ terms. Upon termination, You must stop using the Software and delete
166
+ all copies in Your possession or control.
167
+
168
+ Sections 3, 4, 7, 8, 10, and 11 survive termination.
169
+
170
+ --------------------------------------------------------------------
171
+ 10. GOVERNING LAW
172
+ --------------------------------------------------------------------
173
+
174
+ This Agreement is governed by the laws of England and Wales, without
175
+ regard to its conflict of law rules. Any dispute that cannot be
176
+ resolved amicably shall be subject to the exclusive jurisdiction of
177
+ the courts of England and Wales, except that mandatory consumer
178
+ protections in Your country of residence may grant You the right to
179
+ bring proceedings in Your local courts.
180
+
181
+ --------------------------------------------------------------------
182
+ 11. ENTIRE AGREEMENT
183
+ --------------------------------------------------------------------
184
+
185
+ This Agreement, together with TERMS_OF_USE.md, REFUND_POLICY.md, and
186
+ SECURITY.md, constitutes the entire agreement between You and the
187
+ Licensor concerning the Software.
188
+
189
+ If any provision is held unenforceable, the remaining provisions
190
+ remain in full force and effect.
191
+
192
+ --------------------------------------------------------------------
193
+ END OF LICENSE
194
+ --------------------------------------------------------------------
@@ -0,0 +1,83 @@
1
+ # License FAQ
2
+
3
+ CodeFence is **source-available**, not open source. This document
4
+ answers the questions developers actually ask before adopting it.
5
+
6
+ For the full legal terms, see LICENSE.txt and TERMS_OF_USE.md.
7
+
8
+ ---
9
+
10
+ ## Can I read the source code?
11
+
12
+ Yes. The tool ships as a single readable Python file. You can open it,
13
+ inspect every line, and verify that it performs no network calls,
14
+ collects no telemetry, and writes only to the documented locations.
15
+
16
+ ## Can I modify the source?
17
+
18
+ Yes, for private use. You can change rules, tune detection, or add
19
+ your own checks. Your modifications stay yours. You may not
20
+ redistribute modified versions.
21
+
22
+ ## Can I fork the repository?
23
+
24
+ You may fork for personal use. You may not publish the fork, sell it,
25
+ or offer it as a service. If you want to contribute back, open an
26
+ issue or pull request on the upstream repository.
27
+
28
+ ## Can my company use it?
29
+
30
+ Yes, but each developer who uses CodeFence on their own machine
31
+ needs their own license. A single license covers one individual on
32
+ up to three devices they own or control.
33
+
34
+ ## Can CI download and run it?
35
+
36
+ Yes, if the CI job runs on behalf of a licensed user. The GitHub
37
+ Action workflow installed by codefence init-github is designed
38
+ for this. The workflow does not transmit source code to any third
39
+ party; the scan runs locally in the CI runner.
40
+
41
+ ## Can I vendor the single file into my project?
42
+
43
+ For private use on your own machine, yes. You may not redistribute
44
+ it as part of your own product or bundle.
45
+
46
+ ## Can I offer CodeFence as a paid service?
47
+
48
+ No. Scanning-as-a-service on a commercial basis is not permitted.
49
+
50
+ ## Can I redistribute my copy?
51
+
52
+ No. Redistribution, resale, sublicensing, and bundling are all
53
+ prohibited. If you find CodeFence useful and would like others to
54
+ benefit, please point them to the official distribution channels.
55
+
56
+ ## What if I lost my copy?
57
+
58
+ There is no license recovery process. This is intentional and part
59
+ of the product design: no email, no chat, no support, no trackers.
60
+ Keep your download.
61
+
62
+ ## Is this the same as open source?
63
+
64
+ No. Open source licenses grant redistribution rights; this license
65
+ does not. Source-available means you can read, study, and privately
66
+ modify; it does not mean you can share or resell.
67
+
68
+ ## Why source-available and not open source?
69
+
70
+ A security tool that hides its own behavior cannot be trusted. Source
71
+ is shipped readable so that you can verify what it does. At the same
72
+ time, this is a commercial product, and it is not intended to be
73
+ repackaged by others under a different name.
74
+
75
+ ## What about the rules file (rules.json)?
76
+
77
+ rules.json is part of the product and is covered by the same license.
78
+ You may edit it for your own use. You may not redistribute it as a
79
+ standalone rules package.
80
+
81
+ ---
82
+
83
+ *End of License FAQ.*
@@ -0,0 +1,56 @@
1
+ # Notice on Source Availability
2
+
3
+ CodeFence is shipped as **human-readable source code**. This
4
+ is a deliberate design decision, not an accident.
5
+
6
+ ## Why the source is readable
7
+
8
+ 1. **Trust.** A security tool that hides its own behavior cannot be
9
+ trusted. You can read every line before running it.
10
+
11
+ 2. **Auditability.** You can verify that the tool:
12
+ - performs **zero network calls**,
13
+ - collects **zero telemetry**,
14
+ - writes only to `--output` and (optionally) `~/.cache/codefence/`,
15
+ - never executes the code it scans.
16
+
17
+ 3. **Portability.** The tool is a single Python file with zero
18
+ third-party dependencies. You can read it, keep it, and run it
19
+ on any system with Python 3.10 or newer.
20
+
21
+ ## What this is not
22
+
23
+ Being able to read the source does **not** make this open-source
24
+ software. The license (`LICENSE.txt`) grants you the right to read,
25
+ study, and privately modify the code, but **not** to redistribute it,
26
+ resell it, bundle it, or offer it as a service.
27
+
28
+ ## What you may do
29
+
30
+ - Read the source.
31
+ - Audit the source.
32
+ - Modify the source for your own personal use.
33
+ - Run it on up to 3 devices that you own.
34
+
35
+ ## What you may not do
36
+
37
+ - Publish the source.
38
+ - Share it with others.
39
+ - Sell it or bundle it.
40
+ - Offer it as part of a commercial service.
41
+
42
+ If you find the tool useful and would like others to benefit, please
43
+ point them to the official purchase page rather than sharing your
44
+ copy. This keeps the project sustainable.
45
+
46
+ ## A note on honesty
47
+
48
+ The vendor of this product has made a deliberate choice to be
49
+ transparent about what the tool does and does not do. The limitations
50
+ listed in `README.md` and `SECURITY.md` are real. The tool does not
51
+ claim to be a complete security solution. It claims to be a fast,
52
+ offline, pattern-based sanity checker — nothing more, nothing less.
53
+
54
+ ---
55
+
56
+ *End of Notice.*