sitrtech 1.2.4__tar.gz → 1.2.5__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sitrtech
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: SitrTech Python code encryption CLI — protect Odoo, Django, Flask, FastAPI and Tornado projects
5
5
  Author-email: SitrTech <info@sitrtech.com>
6
6
  License: Proprietary
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sitrtech"
7
- version = "1.2.4"
7
+ version = "1.2.5"
8
8
  description = "SitrTech Python code encryption CLI — protect Odoo, Django, Flask, FastAPI and Tornado projects"
9
9
  readme = "README.md"
10
10
  license = { text = "Proprietary" }
@@ -1,5 +1,5 @@
1
1
  """SitrTech — Python code encryption SDK."""
2
- __version__ = "1.2.4"
2
+ __version__ = "1.2.5"
3
3
  __all__ = ["encrypt", "balance", "encrypt_local", "encrypt_dir_local"]
4
4
 
5
5
  try: # optional: local-mode API (needs cryptography + bundled loaders)
@@ -1,5 +1,5 @@
1
1
  """
2
- sitrtech — Python code encryption CLI v1.2.4
2
+ sitrtech — Python code encryption CLI v1.2.5
3
3
  ==============================================
4
4
 
5
5
  Encrypt Odoo, Frappe, Django, Flask, FastAPI, Tornado (and WordPress, Laravel, PHP) projects with AES-256-GCM
@@ -44,7 +44,7 @@ from rich.table import Table
44
44
  # Constants
45
45
  # ─────────────────────────────────────────────────────────────────────────────
46
46
 
47
- __version__ = "1.2.4"
47
+ __version__ = "1.2.5"
48
48
  API_BASE_DEFAULT = "https://sitrtech.com"
49
49
  MANIFEST_SUFFIX = ".sitr_manifest.json"
50
50
 
@@ -54,6 +54,30 @@ FRAMEWORK_SKIP_ENCRYPT: Dict[str, set] = {
54
54
  "frappe": {"hooks.py", "modules.txt", "patches.txt"},
55
55
  }
56
56
 
57
+ # Runnable entry files (kept in plaintext) that a framework executes first. We
58
+ # prepend the loader bootstrap here so the encrypted importer is installed before
59
+ # any .pye is imported — essential for frameworks launched as a script / WSGI /
60
+ # ASGI target (Django, gunicorn), which never import the project-root package and
61
+ # so would never trigger the root __init__.py bootstrap. Odoo/Frappe are imported
62
+ # as packages, so their __init__.py bootstrap is enough (and __manifest__.py must
63
+ # stay a pure dict literal — never touched here).
64
+ FRAMEWORK_ENTRY_BOOTSTRAP: Dict[str, set] = {
65
+ "django": {"manage.py", "wsgi.py", "asgi.py"},
66
+ "flask": {"app.py", "application.py", "wsgi.py"},
67
+ "fastapi": {"main.py", "asgi.py"},
68
+ "tornado": {"main.py", "server.py"},
69
+ }
70
+
71
+
72
+ def _entry_boot(framework: str) -> str:
73
+ return (
74
+ "try:\n"
75
+ " import sitr as _sitr_boot\n"
76
+ f" _sitr_boot.install_encrypted_importer(__file__, framework=\"{framework}\")\n"
77
+ "except Exception:\n"
78
+ " pass\n"
79
+ )
80
+
57
81
 
58
82
  def _b64e(b: bytes) -> str:
59
83
  return base64.urlsafe_b64encode(b).decode("ascii").rstrip("=")
@@ -285,4 +309,30 @@ def encrypt_project(
285
309
  with open(root_init, "w", encoding="utf-8") as f:
286
310
  f.write(_root_init(original_root_init, framework))
287
311
 
312
+ # prepend the bootstrap to runnable entry files (Django/gunicorn/etc.)
313
+ entry_names = FRAMEWORK_ENTRY_BOOTSTRAP.get(framework, set())
314
+ if entry_names:
315
+ boot = _entry_boot(framework)
316
+ for root, _dirs, files in os.walk(project_root):
317
+ for fname in files:
318
+ if fname not in entry_names:
319
+ continue
320
+ fp = os.path.join(root, fname)
321
+ try:
322
+ with open(fp, "r", encoding="utf-8", errors="ignore") as f:
323
+ orig = f.read()
324
+ # keep a shebang on line 1 if present
325
+ if orig.startswith("#!"):
326
+ nl = orig.find("\n") + 1
327
+ new = orig[:nl] + boot + orig[nl:]
328
+ else:
329
+ new = boot + orig
330
+ # never emit a file that no longer compiles (e.g. leading
331
+ # __future__ import) — fall back to the original untouched.
332
+ compile(new, fp, "exec")
333
+ with open(fp, "w", encoding="utf-8") as f:
334
+ f.write(new)
335
+ except Exception:
336
+ pass
337
+
288
338
  return {"lines": total_lines, "files": file_count}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sitrtech
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: SitrTech Python code encryption CLI — protect Odoo, Django, Flask, FastAPI and Tornado projects
5
5
  Author-email: SitrTech <info@sitrtech.com>
6
6
  License: Proprietary
File without changes
File without changes
File without changes
File without changes