bexar 0.1.0__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 (33) hide show
  1. bexar-0.1.0/LICENSE +21 -0
  2. bexar-0.1.0/PKG-INFO +167 -0
  3. bexar-0.1.0/README.md +124 -0
  4. bexar-0.1.0/pyproject.toml +34 -0
  5. bexar-0.1.0/setup.cfg +4 -0
  6. bexar-0.1.0/src/bexar/__init__.py +3 -0
  7. bexar-0.1.0/src/bexar/__main__.py +6 -0
  8. bexar-0.1.0/src/bexar/analysis/__init__.py +1 -0
  9. bexar-0.1.0/src/bexar/analysis/project.py +529 -0
  10. bexar-0.1.0/src/bexar/analysis/statistics.py +130 -0
  11. bexar-0.1.0/src/bexar/atomic.py +84 -0
  12. bexar-0.1.0/src/bexar/cli.py +560 -0
  13. bexar-0.1.0/src/bexar/exceptions.py +21 -0
  14. bexar-0.1.0/src/bexar/integrity.py +527 -0
  15. bexar-0.1.0/src/bexar/packaging.py +543 -0
  16. bexar-0.1.0/src/bexar/parser.py +192 -0
  17. bexar-0.1.0/src/bexar/protection.py +575 -0
  18. bexar-0.1.0/src/bexar/transform/__init__.py +79 -0
  19. bexar-0.1.0/src/bexar/transform/constants.py +548 -0
  20. bexar-0.1.0/src/bexar/transform/engine.py +719 -0
  21. bexar-0.1.0/src/bexar/transform/identifiers.py +471 -0
  22. bexar-0.1.0/src/bexar/transform/packaging.py +1030 -0
  23. bexar-0.1.0/src/bexar/transform/profiles.py +320 -0
  24. bexar-0.1.0/src/bexar/transform/safety.py +404 -0
  25. bexar-0.1.0/src/bexar/transform/scan.py +249 -0
  26. bexar-0.1.0/src/bexar/transform/scopes.py +827 -0
  27. bexar-0.1.0/src/bexar/transform/strings.py +1632 -0
  28. bexar-0.1.0/src/bexar/verifier.py +451 -0
  29. bexar-0.1.0/src/bexar.egg-info/PKG-INFO +167 -0
  30. bexar-0.1.0/src/bexar.egg-info/SOURCES.txt +31 -0
  31. bexar-0.1.0/src/bexar.egg-info/dependency_links.txt +1 -0
  32. bexar-0.1.0/src/bexar.egg-info/entry_points.txt +2 -0
  33. bexar-0.1.0/src/bexar.egg-info/top_level.txt +1 -0
bexar-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BEXAR contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
bexar-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,167 @@
1
+ Metadata-Version: 2.4
2
+ Name: bexar
3
+ Version: 0.1.0
4
+ Summary: An independent Python source protection and compilation toolkit.
5
+ Author: BEXAR contributors
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 BEXAR contributors
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Classifier: Development Status :: 3 - Alpha
29
+ Classifier: Environment :: Console
30
+ Classifier: Intended Audience :: Developers
31
+ Classifier: License :: OSI Approved :: MIT License
32
+ Classifier: Operating System :: OS Independent
33
+ Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3.11
35
+ Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Programming Language :: Python :: 3.13
37
+ Classifier: Programming Language :: Python :: 3.14
38
+ Classifier: Topic :: Software Development :: Build Tools
39
+ Requires-Python: >=3.11
40
+ Description-Content-Type: text/markdown
41
+ License-File: LICENSE
42
+ Dynamic: license-file
43
+
44
+ # BEXAR
45
+
46
+ BEXAR is an independent Python source protection and compilation toolkit. It is
47
+ designed to make casual source inspection harder through documented,
48
+ semantics-conscious transformations; it does not promise perfect secrecy.
49
+ Obfuscation, compilation, packaging, and encryption are different techniques.
50
+
51
+ ## Status
52
+
53
+ Version `0.1.0` provides an initial source-protection engine, static Python
54
+ source inspection, non-executing source verification, bounded static
55
+ project-import analysis, SHA-256 file integrity manifests, and a reproducible
56
+ `.pyz` packaging workflow.
57
+
58
+ `bexar -p FILE.py` applies the strongest **implemented** protection profile and
59
+ writes one protected `.py` file (default `FILE_bexar.py`). Today that means:
60
+
61
+ - **scope-aware identifier renaming** — locals, closure cells, comprehension
62
+ targets and unambiguous import aliases are renamed to opaque generated names
63
+ (built only from `I` and `l`, so they read as noise), while parameters,
64
+ module-level names and class attributes are left intact;
65
+ - **string and bytes literal protection** — eligible literals are replaced by
66
+ calls to a generated decoder that rebuilds them from a masked payload, so
67
+ URLs, SQL, tokens and messages no longer appear as plain text. When the four
68
+ section names are free the payload pool is carried by the `BEXAR-PROTECTED`
69
+ data header (`magic`, `love`, `god`, `destiny` plus descriptive metadata) and
70
+ each literal becomes a lookup into that pool;
71
+ - **numeric constant protection** — eligible integer and float literals are
72
+ replaced by equivalent arithmetic that the interpreter folds back to the same
73
+ value, so ports, timeouts and protocol constants are no longer readable as
74
+ literals.
75
+
76
+ The generated part of a protected file contains no readable keywords, no
77
+ imports and no builtin names. The decoder is a single lambda assignment, every
78
+ name it needs (`__import__`, `base64`, `b85decode`, `zlib`, `decompress`,
79
+ `len`, `ValueError`, `enumerate`, `join`, `zip_longest`, `itertools`, ...) is
80
+ carried as a masked `%c` literal rather than as an identifier, builtins are
81
+ reached through a frame object instead of the `builtins` module, and the
82
+ generated lambda takes unused junk parameters so its signature does not match
83
+ the decoder it actually implements. Every protected module is stamped with the
84
+ `" Bexar made by Bashar "` watermark inside a generated tuple statement, which
85
+ also carries deterministic filler strings that lengthen the output in
86
+ proportion to the encoded payload. The banner comments at the top of a
87
+ protected file are four lines — format name and version, section names, pool
88
+ checksum, watermark — and no longer describe the pool layout, the distribution
89
+ rule or the decoder signature. Only the statements of the *original* program —
90
+ including its own `def`, `class` and `return` — are reproduced verbatim,
91
+ because the verifier requires the protected output to re-parse to the same
92
+ statement and node shape as the input.
93
+
94
+ Control-flow transformation, runtime integrity and native compilation are
95
+ declared stages that are **not implemented**; every protection report lists
96
+ them explicitly rather than implying coverage. `bexar doctor` prints the same
97
+ stage list, the selected interpreter and any detected optional backend.
98
+
99
+ Protection is not a security guarantee. Renaming, literal masking and constant
100
+ rewriting make casual source reading harder; they do not make code
101
+ unrecoverable — the generated decoder ships in the output, so anyone who reads
102
+ it can recover every payload, and every constant is recoverable by evaluating
103
+ its expression. The engine refuses to transform any file whose behavior it
104
+ cannot reason about statically. See
105
+ [`docs/commands.md`](docs/commands.md) for the transformation scope, refusal
106
+ rules and measured performance, and the [roadmap](docs/roadmap.md) for the gap
107
+ analysis and engineering plan.
108
+
109
+ ## Install for development
110
+
111
+ ```powershell
112
+ python -m pip install -e .
113
+ bexar --version
114
+ bexar help
115
+ bexar -p main.py
116
+ bexar inspect main.py
117
+ bexar package main.py --output dist
118
+ python .\dist\main.pyz
119
+ ```
120
+
121
+ Requires Python 3.11 or newer. BEXAR currently has no runtime dependencies.
122
+
123
+ ## Safety
124
+
125
+ BEXAR's static-analysis and protection commands do not execute input programs.
126
+ Behavioral comparison of original and protected code happens only in the test
127
+ suite, against fixtures BEXAR itself controls, in separate subprocesses.
128
+
129
+ `bexar -p FILE.py` parses the input, rewrites the AST, re-parses and compiles
130
+ the generated module, checks that the output has the same AST node-type
131
+ histogram and binds the same module-level names, and only then writes the result
132
+ atomically. If any check fails, nothing is written and the run exits non-zero.
133
+ The input file is never overwritten unless `--in-place` is given explicitly.
134
+
135
+ `bexar inspect` reads source with Python's encoding-cookie detection, rejects
136
+ files above 64 MiB by default, and reports syntax errors without executing the
137
+ file. The limit can be adjusted with `--max-bytes`.
138
+
139
+ `bexar verify FILE` additionally checks Python compile-time constraints by
140
+ building and discarding a code object. It never evaluates that object or runs
141
+ the inspected file. This is a source-validity check, not a protection or
142
+ generated-output integrity guarantee.
143
+
144
+ `bexar analyze DIRECTORY` scans Python source statically. It reports project,
145
+ standard-library, external-or-unresolved, and dynamic import references. It
146
+ does not install dependencies, import project modules, or prove that a project
147
+ can be bundled into a single file.
148
+
149
+ `bexar integrity create FILE` creates a deterministic `.bexar.json` sidecar;
150
+ `bexar integrity verify FILE` checks the file against it. A hash manifest is
151
+ not signed, so it only detects tampering when the manifest itself comes from a
152
+ trusted source.
153
+
154
+ `bexar package ENTRY.py --output DIRECTORY` creates one `.pyz` ZIP application
155
+ containing the entry point and statically reachable local Python modules.
156
+ Detected external or unresolved imports and dynamic imports are reported.
157
+ Native extensions and non-Python resources are not bundled or scanned, and the
158
+ report therefore does not claim the result is self-contained. Optional
159
+ `--signature SIGNATURE --public-key KEY` checks an OpenSSL SHA-256 detached
160
+ signature over the completed `.pyz` archive before publishing it. The public
161
+ key must be trusted independently; BEXAR does not generate keys or signatures.
162
+ See
163
+ [`docs/commands.md`](docs/commands.md) for limits and examples.
164
+
165
+ ## License
166
+
167
+ MIT; see [LICENSE](LICENSE).
bexar-0.1.0/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # BEXAR
2
+
3
+ BEXAR is an independent Python source protection and compilation toolkit. It is
4
+ designed to make casual source inspection harder through documented,
5
+ semantics-conscious transformations; it does not promise perfect secrecy.
6
+ Obfuscation, compilation, packaging, and encryption are different techniques.
7
+
8
+ ## Status
9
+
10
+ Version `0.1.0` provides an initial source-protection engine, static Python
11
+ source inspection, non-executing source verification, bounded static
12
+ project-import analysis, SHA-256 file integrity manifests, and a reproducible
13
+ `.pyz` packaging workflow.
14
+
15
+ `bexar -p FILE.py` applies the strongest **implemented** protection profile and
16
+ writes one protected `.py` file (default `FILE_bexar.py`). Today that means:
17
+
18
+ - **scope-aware identifier renaming** — locals, closure cells, comprehension
19
+ targets and unambiguous import aliases are renamed to opaque generated names
20
+ (built only from `I` and `l`, so they read as noise), while parameters,
21
+ module-level names and class attributes are left intact;
22
+ - **string and bytes literal protection** — eligible literals are replaced by
23
+ calls to a generated decoder that rebuilds them from a masked payload, so
24
+ URLs, SQL, tokens and messages no longer appear as plain text. When the four
25
+ section names are free the payload pool is carried by the `BEXAR-PROTECTED`
26
+ data header (`magic`, `love`, `god`, `destiny` plus descriptive metadata) and
27
+ each literal becomes a lookup into that pool;
28
+ - **numeric constant protection** — eligible integer and float literals are
29
+ replaced by equivalent arithmetic that the interpreter folds back to the same
30
+ value, so ports, timeouts and protocol constants are no longer readable as
31
+ literals.
32
+
33
+ The generated part of a protected file contains no readable keywords, no
34
+ imports and no builtin names. The decoder is a single lambda assignment, every
35
+ name it needs (`__import__`, `base64`, `b85decode`, `zlib`, `decompress`,
36
+ `len`, `ValueError`, `enumerate`, `join`, `zip_longest`, `itertools`, ...) is
37
+ carried as a masked `%c` literal rather than as an identifier, builtins are
38
+ reached through a frame object instead of the `builtins` module, and the
39
+ generated lambda takes unused junk parameters so its signature does not match
40
+ the decoder it actually implements. Every protected module is stamped with the
41
+ `" Bexar made by Bashar "` watermark inside a generated tuple statement, which
42
+ also carries deterministic filler strings that lengthen the output in
43
+ proportion to the encoded payload. The banner comments at the top of a
44
+ protected file are four lines — format name and version, section names, pool
45
+ checksum, watermark — and no longer describe the pool layout, the distribution
46
+ rule or the decoder signature. Only the statements of the *original* program —
47
+ including its own `def`, `class` and `return` — are reproduced verbatim,
48
+ because the verifier requires the protected output to re-parse to the same
49
+ statement and node shape as the input.
50
+
51
+ Control-flow transformation, runtime integrity and native compilation are
52
+ declared stages that are **not implemented**; every protection report lists
53
+ them explicitly rather than implying coverage. `bexar doctor` prints the same
54
+ stage list, the selected interpreter and any detected optional backend.
55
+
56
+ Protection is not a security guarantee. Renaming, literal masking and constant
57
+ rewriting make casual source reading harder; they do not make code
58
+ unrecoverable — the generated decoder ships in the output, so anyone who reads
59
+ it can recover every payload, and every constant is recoverable by evaluating
60
+ its expression. The engine refuses to transform any file whose behavior it
61
+ cannot reason about statically. See
62
+ [`docs/commands.md`](docs/commands.md) for the transformation scope, refusal
63
+ rules and measured performance, and the [roadmap](docs/roadmap.md) for the gap
64
+ analysis and engineering plan.
65
+
66
+ ## Install for development
67
+
68
+ ```powershell
69
+ python -m pip install -e .
70
+ bexar --version
71
+ bexar help
72
+ bexar -p main.py
73
+ bexar inspect main.py
74
+ bexar package main.py --output dist
75
+ python .\dist\main.pyz
76
+ ```
77
+
78
+ Requires Python 3.11 or newer. BEXAR currently has no runtime dependencies.
79
+
80
+ ## Safety
81
+
82
+ BEXAR's static-analysis and protection commands do not execute input programs.
83
+ Behavioral comparison of original and protected code happens only in the test
84
+ suite, against fixtures BEXAR itself controls, in separate subprocesses.
85
+
86
+ `bexar -p FILE.py` parses the input, rewrites the AST, re-parses and compiles
87
+ the generated module, checks that the output has the same AST node-type
88
+ histogram and binds the same module-level names, and only then writes the result
89
+ atomically. If any check fails, nothing is written and the run exits non-zero.
90
+ The input file is never overwritten unless `--in-place` is given explicitly.
91
+
92
+ `bexar inspect` reads source with Python's encoding-cookie detection, rejects
93
+ files above 64 MiB by default, and reports syntax errors without executing the
94
+ file. The limit can be adjusted with `--max-bytes`.
95
+
96
+ `bexar verify FILE` additionally checks Python compile-time constraints by
97
+ building and discarding a code object. It never evaluates that object or runs
98
+ the inspected file. This is a source-validity check, not a protection or
99
+ generated-output integrity guarantee.
100
+
101
+ `bexar analyze DIRECTORY` scans Python source statically. It reports project,
102
+ standard-library, external-or-unresolved, and dynamic import references. It
103
+ does not install dependencies, import project modules, or prove that a project
104
+ can be bundled into a single file.
105
+
106
+ `bexar integrity create FILE` creates a deterministic `.bexar.json` sidecar;
107
+ `bexar integrity verify FILE` checks the file against it. A hash manifest is
108
+ not signed, so it only detects tampering when the manifest itself comes from a
109
+ trusted source.
110
+
111
+ `bexar package ENTRY.py --output DIRECTORY` creates one `.pyz` ZIP application
112
+ containing the entry point and statically reachable local Python modules.
113
+ Detected external or unresolved imports and dynamic imports are reported.
114
+ Native extensions and non-Python resources are not bundled or scanned, and the
115
+ report therefore does not claim the result is self-contained. Optional
116
+ `--signature SIGNATURE --public-key KEY` checks an OpenSSL SHA-256 detached
117
+ signature over the completed `.pyz` archive before publishing it. The public
118
+ key must be trusted independently; BEXAR does not generate keys or signatures.
119
+ See
120
+ [`docs/commands.md`](docs/commands.md) for limits and examples.
121
+
122
+ ## License
123
+
124
+ MIT; see [LICENSE](LICENSE).
@@ -0,0 +1,34 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "bexar"
7
+ version = "0.1.0"
8
+ description = "An independent Python source protection and compilation toolkit."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name = "BEXAR contributors" }]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Environment :: Console",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
24
+ "Topic :: Software Development :: Build Tools",
25
+ ]
26
+
27
+ [project.scripts]
28
+ bexar = "bexar.cli:main"
29
+
30
+ [tool.setuptools]
31
+ package-dir = { "" = "src" }
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
bexar-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """BEXAR Python source protection and compilation toolkit."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,6 @@
1
+ """Run BEXAR as a module."""
2
+
3
+ from bexar.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(main())
@@ -0,0 +1 @@
1
+ """Static analysis helpers for Python source code."""