ghostcode 0.5.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,221 @@
1
+ """Standard library and framework symbol registry.
2
+
3
+ Maintains lists of known stdlib/framework symbols that should NEVER
4
+ be renamed. Used as a fallback when AST-based classification is
5
+ insufficient (e.g., unresolved templates, dynamic Python).
6
+
7
+ Profiles:
8
+ - C++ STL
9
+ - Python builtins
10
+ - Django, Flask, FastAPI, SQLAlchemy, Pydantic, PyTorch
11
+ """
12
+
13
+ # ── C++ Standard Library ──────────────────────────────────────────
14
+
15
+ CPP_STL_NAMESPACES = {
16
+ "std", "std::chrono", "std::filesystem", "std::regex",
17
+ "std::this_thread", "std::placeholders",
18
+ }
19
+
20
+ CPP_STL_TYPES = {
21
+ # Containers
22
+ "vector", "list", "deque", "array", "forward_list",
23
+ "set", "multiset", "unordered_set", "unordered_multiset",
24
+ "map", "multimap", "unordered_map", "unordered_multimap",
25
+ "stack", "queue", "priority_queue",
26
+ # Strings
27
+ "string", "wstring", "u16string", "u32string",
28
+ "string_view", "basic_string",
29
+ # Smart pointers
30
+ "unique_ptr", "shared_ptr", "weak_ptr", "auto_ptr",
31
+ # Utilities
32
+ "pair", "tuple", "optional", "variant", "any",
33
+ "function", "reference_wrapper",
34
+ # IO
35
+ "iostream", "istream", "ostream", "fstream",
36
+ "ifstream", "ofstream", "stringstream",
37
+ "istringstream", "ostringstream",
38
+ # Iterators
39
+ "iterator", "const_iterator", "reverse_iterator",
40
+ # Threading
41
+ "thread", "mutex", "lock_guard", "unique_lock",
42
+ "condition_variable", "future", "promise", "atomic",
43
+ # Memory
44
+ "allocator",
45
+ # Exceptions
46
+ "exception", "runtime_error", "logic_error",
47
+ "invalid_argument", "out_of_range", "overflow_error",
48
+ }
49
+
50
+ CPP_STL_FUNCTIONS = {
51
+ # Algorithms
52
+ "sort", "find", "find_if", "count", "count_if",
53
+ "transform", "for_each", "copy", "move",
54
+ "fill", "replace", "remove", "remove_if",
55
+ "unique", "reverse", "rotate", "shuffle",
56
+ "min", "max", "minmax", "clamp",
57
+ "accumulate", "reduce", "inner_product",
58
+ "binary_search", "lower_bound", "upper_bound",
59
+ "merge", "partition", "nth_element",
60
+ # IO
61
+ "cout", "cin", "cerr", "clog", "endl", "flush",
62
+ "getline", "put", "get",
63
+ # Math
64
+ "abs", "sqrt", "pow", "exp", "log", "log2", "log10",
65
+ "sin", "cos", "tan", "asin", "acos", "atan", "atan2",
66
+ "ceil", "floor", "round", "fmod",
67
+ # Memory
68
+ "make_unique", "make_shared", "make_pair", "make_tuple",
69
+ # String
70
+ "to_string", "stoi", "stol", "stof", "stod",
71
+ # Utility
72
+ "swap", "exchange", "forward", "move",
73
+ "static_cast", "dynamic_cast", "const_cast", "reinterpret_cast",
74
+ # C stdlib
75
+ "printf", "fprintf", "sprintf", "snprintf",
76
+ "malloc", "calloc", "realloc", "free",
77
+ "memcpy", "memset", "memmove", "memcmp",
78
+ "strlen", "strcmp", "strncmp", "strcpy", "strncpy",
79
+ "fopen", "fclose", "fread", "fwrite",
80
+ "assert",
81
+ }
82
+
83
+ # Combined C++ set for fast lookup
84
+ CPP_STDLIB_ALL = CPP_STL_NAMESPACES | CPP_STL_TYPES | CPP_STL_FUNCTIONS
85
+
86
+ # ── Python Standard Library ──────────────────────────────────────
87
+
88
+ PYTHON_STDLIB_MODULES = {
89
+ "os", "sys", "re", "json", "math", "random", "time", "datetime",
90
+ "collections", "itertools", "functools", "operator", "typing",
91
+ "pathlib", "shutil", "glob", "tempfile", "io",
92
+ "subprocess", "threading", "multiprocessing", "concurrent",
93
+ "socket", "http", "urllib", "email",
94
+ "hashlib", "hmac", "secrets",
95
+ "logging", "warnings", "traceback",
96
+ "unittest", "pytest", "doctest",
97
+ "abc", "enum", "dataclasses",
98
+ "copy", "pickle", "shelve", "csv",
99
+ "argparse", "configparser",
100
+ "contextlib", "inspect", "importlib",
101
+ "textwrap", "string",
102
+ "struct", "array", "queue",
103
+ "asyncio", "aiohttp",
104
+ }
105
+
106
+ # ── Framework Profiles ────────────────────────────────────────────
107
+
108
+ FRAMEWORK_PROFILES = {
109
+ "django": {
110
+ "base_classes": {
111
+ "Model", "Form", "ModelForm", "View", "TemplateView",
112
+ "ListView", "DetailView", "CreateView", "UpdateView",
113
+ "DeleteView", "APIView", "ViewSet", "ModelViewSet",
114
+ "Serializer", "ModelSerializer", "Admin", "ModelAdmin",
115
+ "TestCase", "TransactionTestCase", "SimpleTestCase",
116
+ "Command", "BaseCommand", "Middleware",
117
+ },
118
+ "safe_methods": {
119
+ "objects", "filter", "get", "create", "update",
120
+ "delete", "exclude", "order_by", "values", "annotate",
121
+ "aggregate", "select_related", "prefetch_related",
122
+ "save", "full_clean", "clean", "validate",
123
+ "render", "redirect", "reverse", "resolve",
124
+ },
125
+ "decorators": {
126
+ "login_required", "permission_required", "csrf_exempt",
127
+ "require_http_methods", "api_view",
128
+ },
129
+ },
130
+ "flask": {
131
+ "base_classes": {
132
+ "Flask", "Blueprint", "Resource", "MethodView",
133
+ },
134
+ "safe_methods": {
135
+ "route", "before_request", "after_request",
136
+ "errorhandler", "register_blueprint",
137
+ "render_template", "redirect", "url_for",
138
+ "jsonify", "abort", "make_response",
139
+ "send_file", "send_from_directory",
140
+ },
141
+ "objects": {
142
+ "request", "session", "g", "current_app",
143
+ },
144
+ },
145
+ "fastapi": {
146
+ "base_classes": {
147
+ "FastAPI", "APIRouter", "BaseModel",
148
+ },
149
+ "safe_methods": {
150
+ "get", "post", "put", "delete", "patch",
151
+ "Depends", "HTTPException", "Body", "Query",
152
+ "Path", "Header", "Cookie", "File", "Form",
153
+ "BackgroundTasks", "Response", "JSONResponse",
154
+ },
155
+ },
156
+ "sqlalchemy": {
157
+ "base_classes": {
158
+ "Base", "DeclarativeBase", "Session",
159
+ },
160
+ "safe_methods": {
161
+ "Column", "Integer", "String", "Float", "Boolean",
162
+ "DateTime", "Text", "ForeignKey", "Table",
163
+ "relationship", "backref", "mapped_column",
164
+ "create_engine", "sessionmaker",
165
+ "query", "add", "commit", "rollback", "flush",
166
+ },
167
+ },
168
+ "pydantic": {
169
+ "base_classes": {
170
+ "BaseModel", "BaseSettings",
171
+ },
172
+ "safe_methods": {
173
+ "Field", "validator", "root_validator",
174
+ "model_validator", "field_validator",
175
+ "ConfigDict", "model_dump", "model_validate",
176
+ },
177
+ },
178
+ "pytorch": {
179
+ "base_classes": {
180
+ "Module", "Dataset", "DataLoader", "Optimizer",
181
+ },
182
+ "safe_methods": {
183
+ "forward", "backward", "parameters", "named_parameters",
184
+ "state_dict", "load_state_dict", "train", "eval",
185
+ "zero_grad", "step", "cuda", "cpu", "to",
186
+ "tensor", "zeros", "ones", "randn", "rand",
187
+ "cat", "stack", "reshape", "view", "permute",
188
+ "Linear", "Conv2d", "BatchNorm2d", "ReLU", "Dropout",
189
+ "CrossEntropyLoss", "MSELoss", "Adam", "SGD",
190
+ },
191
+ "modules": {
192
+ "torch", "nn", "optim", "F",
193
+ "torchvision", "transforms",
194
+ },
195
+ },
196
+ }
197
+
198
+
199
+ def get_all_framework_symbols() -> set[str]:
200
+ """Return a flat set of all known framework symbols."""
201
+ symbols = set()
202
+ for profile in FRAMEWORK_PROFILES.values():
203
+ for category in profile.values():
204
+ if isinstance(category, set):
205
+ symbols |= category
206
+ return symbols
207
+
208
+
209
+ def is_framework_symbol(name: str) -> bool:
210
+ """Check if a name is a known framework symbol."""
211
+ return name in get_all_framework_symbols()
212
+
213
+
214
+ def is_cpp_stdlib(name: str) -> bool:
215
+ """Check if a name is a known C++ stdlib symbol."""
216
+ return name in CPP_STDLIB_ALL
217
+
218
+
219
+ def is_python_stdlib_module(name: str) -> bool:
220
+ """Check if a name is a known Python stdlib module."""
221
+ return name in PYTHON_STDLIB_MODULES
@@ -0,0 +1,92 @@
1
+ Metadata-Version: 2.4
2
+ Name: ghostcode
3
+ Version: 0.5.0
4
+ Summary: Privacy proxy for developers — hide business context before sharing code with AI
5
+ Author: Smit Vaishanav
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/smitvaishnav/anti-ai
8
+ Project-URL: Repository, https://github.com/smitvaishnav/anti-ai
9
+ Project-URL: Issues, https://github.com/smitvaishnav/anti-ai/issues
10
+ Keywords: privacy,security,ai,llm,code-anonymization,ghostcode
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
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 :: Security
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ Requires-Dist: click>=8.1.0
26
+ Requires-Dist: libclang>=16.0.0
27
+ Requires-Dist: cryptography>=41.0.0
28
+ Requires-Dist: pyyaml>=6.0
29
+ Dynamic: requires-python
30
+
31
+ # GhostCode — Privacy Proxy for Developers
32
+
33
+ **Hide your business logic before sharing code with LLMs. Local-first, open-source, zero telemetry.**
34
+
35
+ GhostCode replaces your private symbols (variable names, functions, strings, comments) with opaque ghost tokens before you share code with AI. The AI sees `gv_001` instead of `customer_revenue`. When you get your answer back, GhostCode restores everything.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install ghostcode
41
+ ```
42
+
43
+ ## Quick Start
44
+
45
+ ```bash
46
+ # Hide a file (Level 2: names + comments + literals)
47
+ ghost hide my_code.py --level 2
48
+
49
+ # Paste the ghost output into ChatGPT/Claude, get a response, save it
50
+
51
+ # Reveal — restore original names in the AI's response
52
+ ghost reveal ai_response.py --map-file .ghostcode/maps/my_code_*.json
53
+ ```
54
+
55
+ ## Privacy Levels
56
+
57
+ | Level | What it does |
58
+ |-------|-------------|
59
+ | 1 | Rename symbols + strip comments |
60
+ | 2 | + Scrub string/numeric literals |
61
+ | 3 | + Function isolation with stubs |
62
+ | 4 | + Dimension generalization |
63
+
64
+ ## Pre-Send Risk Report
65
+
66
+ Every `ghost hide` shows a risk assessment:
67
+ - Symbols and literals scrubbed/flagged/kept
68
+ - Structural patterns visible to the AI
69
+ - **Estimated domain exposure: LOW / MEDIUM / HIGH**
70
+
71
+ ## VS Code Extension
72
+
73
+ Install the [GhostCode VS Code extension](https://marketplace.visualstudio.com/items?itemName=SmitVaishanav.ghostcode) for one-click hide/reveal buttons in the editor toolbar.
74
+
75
+ ## Supported Languages
76
+
77
+ - Python (.py)
78
+ - C/C++ (.cpp, .cc, .c, .h, .hpp)
79
+
80
+ ## Features
81
+
82
+ - 🔒 **AST-based symbol renaming** — not regex, real parsing
83
+ - 📊 **Smart literal scrubbing** — keeps `0`, `1`, `pi`; scrubs URLs, API keys, business strings
84
+ - 🗺️ **Ghost Map** — bidirectional mapping stored as JSON
85
+ - 🔐 **Encrypted maps** — optional AES encryption for map files
86
+ - 📋 **Audit logging** — immutable JSON logs for compliance
87
+ - 🔄 **Round-trip reveal** — restores names in both code and AI explanations
88
+ - ⚡ **Zero cloud, zero telemetry** — everything runs locally
89
+
90
+ ## License
91
+
92
+ MIT
@@ -0,0 +1,33 @@
1
+ ghostcode/__init__.py,sha256=TmEm_brgzAZMwNJ1BNjj47CX1pF80aD1cpeM1rjJ00I,73
2
+ ghostcode/cli.py,sha256=ZxhPqj5sadrVtEUkCqPeSCH0wKh8EPbvmsDs-rEkDzY,39403
3
+ ghostcode/config.py,sha256=IgGW09u3p9T_YAojer5GQRct0OSkt9WbkDIgrcwpy-E,5920
4
+ ghostcode/risk_report.py,sha256=PHPGG1NjScg8oh9Lx2eYkXvEwPP0VjiJiplHSp-SzJk,15405
5
+ ghostcode/audit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ ghostcode/audit/logger.py,sha256=E21AKyRmrAPt_y-djTCvpHM4WeDyIaykKqvYCFYTB5w,5047
7
+ ghostcode/mapping/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ ghostcode/mapping/encryption.py,sha256=8YlYDKx7Nz2rbGXi4j6SKiuajQGSUhPjR3RnpFD0Nzs,4008
9
+ ghostcode/mapping/ghost_map.py,sha256=SVIMF9--htBUAM062LIoJc021hlGvnoEAAKvMKHs6PM,7607
10
+ ghostcode/mapping/token_generator.py,sha256=thYfMjsn6SBAzms1EZKlqr4Yh-xJtXGWko0MVpxY-D8,2317
11
+ ghostcode/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ ghostcode/parsers/base.py,sha256=oIjza8qpAygDwQ-qA1sycUpZDxJieSMtjLxRgNv_Xuo,1535
13
+ ghostcode/parsers/cpp_parser.py,sha256=3gwwZ4hpJ--t4JC99FfFEUIcLt7LbGK-lWwzLehiYmw,12567
14
+ ghostcode/parsers/python_parser.py,sha256=sXfFx1x57ifxsK0PiXeZRxJQ48IgIkF8c_uneadItbE,17046
15
+ ghostcode/reveal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ ghostcode/reveal/code_revealer.py,sha256=rfpWZbtW9QD_zjd0nSQbIo5EMC4O_LxoHYDMx8kYHaE,13693
17
+ ghostcode/reveal/diff_analyzer.py,sha256=YYd3GL85sswONRDLMY6sidTsQwtEI6yfZxPK8dd-xjc,16069
18
+ ghostcode/reveal/explanation_translator.py,sha256=bhY9Pr7zSwEJqUhVQzXXEnJQz7CmrPmz6w8TsE2J3Io,8672
19
+ ghostcode/transformers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ ghostcode/transformers/comment_anonymizer.py,sha256=yfFwbZ3e4SG1hZFlhXyLadsmIquWec7ULULk_Zssez8,3788
21
+ ghostcode/transformers/comment_stripper.py,sha256=QElkqFP4m3b12w1eDiJevjjWEFITiVsVjDOfGy0MV2M,2142
22
+ ghostcode/transformers/isolator.py,sha256=A1wvnhZ-ZmSP-MIH9oaBcsiLJ2SYD-etJJd_QBhAPlI,11439
23
+ ghostcode/transformers/literal_scrubber.py,sha256=y2vbZe4a8d3YGiBnjk0byZcZf3MfvZfkj9rz3VMcnqE,16384
24
+ ghostcode/transformers/multi_file.py,sha256=5ZY9_nADyNDvmpCAK0LTmr_Le7mYaOIypIc1GiVc2bw,3321
25
+ ghostcode/transformers/symbol_renamer.py,sha256=v0hIvxN4mLNC3yoCw6ZgQ4Tr7WpdX_RpqXwDOnJ4OcA,2321
26
+ ghostcode/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ ghostcode/utils/clipboard.py,sha256=tZAyn9-cKX1hqZd159cQ2weGtXz6IQhny-qB81gEDbE,1418
28
+ ghostcode/utils/stdlib_registry.py,sha256=vQkQvXeqtxbYxltFdIS5oYlq4fd_tVhBNnouRX278yg,7929
29
+ ghostcode-0.5.0.dist-info/METADATA,sha256=eqt6NHcBAcTul-XoseQL6R0PxFDNVDqlB0Skzxdirdo,3258
30
+ ghostcode-0.5.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
31
+ ghostcode-0.5.0.dist-info/entry_points.txt,sha256=xBSdDV1wZyedN74qgsZ7dEyK_tAnSjt7NMIUkAlQ9H4,45
32
+ ghostcode-0.5.0.dist-info/top_level.txt,sha256=5WfNBeBFY8IAUIShkCMoP17IJf_IVR9xGrHymOLEUOk,10
33
+ ghostcode-0.5.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ghost = ghostcode.cli:main
@@ -0,0 +1 @@
1
+ ghostcode