tzero-mcp 12.3.3 → 12.3.5
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.
- package/CONTRIBUTING.md +1 -1
- package/README.md +4 -0
- package/package.json +3 -4
- package/src/addmcp.py +2 -2
- package/src/app.py +1 -1
- package/src/main.py +4 -0
- package/src/tzero/__init__.py +1 -1
- package/src/tzero/desktop_updater.py +6 -0
- package/src/tzero/tzero_benchmark.py +1 -1
- package/src/tzero/tzero_budget.py +1 -1
- package/src/tzero/tzero_ci.py +1 -1
- package/src/tzero/tzero_contracts.py +2 -2
- package/src/tzero/tzero_dashboard.py +3 -3
- package/src/tzero/tzero_debt.py +1 -1
- package/src/tzero/tzero_deps.py +1 -0
- package/src/tzero/tzero_explain.py +1 -1
- package/src/tzero/tzero_features.py +31 -74
- package/src/tzero/tzero_golden.py +2 -2
- package/src/tzero/tzero_growth.py +1 -1
- package/src/tzero/tzero_jarvis/orchestrator.py +1 -1
- package/src/tzero/tzero_jarvis/workspace_orchestrator.py +10 -21
- package/src/tzero/tzero_lsp.py +1 -1
- package/src/tzero/tzero_mcp.py +19 -120
- package/src/tzero/tzero_promo.py +1 -1
- package/src/tzero/tzero_security.py +3 -3
- package/src/tzero/tzero_sync.py +73 -148
- package/src/tzero/tzero_task_benchmark.py +2 -2
- package/src/tzero/tzero_traffic.py +1 -1
- package/src/tzero/tzero_tui.py +2 -13
- package/src/tzero/tzero_v3.py +56 -187
- package/src/tzero/tzero_welcome.py +1 -1
- package/src/tzero/anti_rea/__init__.py +0 -84
- package/src/tzero/anti_rea/algebraic_mutator.py +0 -107
- package/src/tzero/anti_rea/anti_agent_guard.py +0 -96
- package/src/tzero/anti_rea/anti_debugger.py +0 -272
- package/src/tzero/anti_rea/anti_vm.py +0 -160
- package/src/tzero/anti_rea/asar_shield.py +0 -122
- package/src/tzero/anti_rea/auditor.py +0 -208
- package/src/tzero/anti_rea/bpe_disrupter.py +0 -48
- package/src/tzero/anti_rea/bytecode_trap.py +0 -85
- package/src/tzero/anti_rea/canary_beacon.py +0 -167
- package/src/tzero/anti_rea/cli.py +0 -134
- package/src/tzero/anti_rea/confusables.py +0 -130
- package/src/tzero/anti_rea/crypto_loader.py +0 -132
- package/src/tzero/anti_rea/engine.py +0 -304
- package/src/tzero/anti_rea/extractor_shield.py +0 -180
- package/src/tzero/anti_rea/flattener.py +0 -136
- package/src/tzero/anti_rea/gui.py +0 -264
- package/src/tzero/anti_rea/honeypot.py +0 -58
- package/src/tzero/anti_rea/integrity_guard.py +0 -78
- package/src/tzero/anti_rea/jailbreak_decoy.py +0 -77
- package/src/tzero/anti_rea/mcp_poison.py +0 -41
- package/src/tzero/anti_rea/native_bridge.py +0 -169
- package/src/tzero/anti_rea/rdtsc_guard.py +0 -77
- package/src/tzero/anti_rea/string_vault.py +0 -97
- package/src/tzero/anti_rea/sybil_network.py +0 -53
- package/src/tzero/anti_rea/tier_catalog.py +0 -388
- package/src/tzero/anti_rea/timing_guard.py +0 -46
- package/src/tzero/anti_rea/token_bomb.py +0 -65
- package/src/tzero/anti_rea/traps.py +0 -76
- package/src/tzero/anti_rea/vm_obfuscator.py +0 -182
- package/src/tzero/tzero_armor.py +0 -187
package/src/tzero/tzero_v3.py
CHANGED
|
@@ -493,7 +493,7 @@ def calculate_token_cost(token_count: int, provider_name: str) -> float:
|
|
|
493
493
|
# i18n Translations
|
|
494
494
|
TRANSLATIONS: Dict[str, Dict[str, str]] = {
|
|
495
495
|
"en": {
|
|
496
|
-
"title": "T-Zero Developer Console & Context Architect v12.3.
|
|
496
|
+
"title": "T-Zero Developer Console & Context Architect v12.3.5",
|
|
497
497
|
"subtitle": f"Developer: {DEV_NAME} | {DEV_URL_MAIN} | {DEV_URL_BIO}",
|
|
498
498
|
"overview_tab": "🏠 Overview Dashboard",
|
|
499
499
|
"setup_tab": "⚡ Setup & AI Models",
|
|
@@ -530,7 +530,7 @@ TRANSLATIONS: Dict[str, Dict[str, str]] = {
|
|
|
530
530
|
"audit_btn": "🛡️ SECURITY AUDIT"
|
|
531
531
|
},
|
|
532
532
|
"tr": {
|
|
533
|
-
"title": "T-Zero Developer Console & Context Architect v12.3.
|
|
533
|
+
"title": "T-Zero Developer Console & Context Architect v12.3.5",
|
|
534
534
|
"subtitle": f"Developer: {DEV_NAME} | {DEV_URL_MAIN} | {DEV_URL_BIO}",
|
|
535
535
|
"overview_tab": "🏠 Overview Dashboard",
|
|
536
536
|
"setup_tab": "⚡ Setup & AI Models",
|
|
@@ -1986,9 +1986,10 @@ class KeyringSecretsEditor:
|
|
|
1986
1986
|
|
|
1987
1987
|
|
|
1988
1988
|
class KeyringSecretsBackupManager:
|
|
1989
|
-
"""Backs up and restores credentials securely using
|
|
1989
|
+
"""Backs up and restores credentials securely using AES-GCM and reads older authenticated backups."""
|
|
1990
1990
|
|
|
1991
|
-
MAGIC_HEADER = b"
|
|
1991
|
+
MAGIC_HEADER = b"TZB3"
|
|
1992
|
+
LEGACY_AUTH_HEADER = b"TZB2"
|
|
1992
1993
|
PBKDF2_ROUNDS = 600_000
|
|
1993
1994
|
|
|
1994
1995
|
@classmethod
|
|
@@ -2011,7 +2012,10 @@ class KeyringSecretsBackupManager:
|
|
|
2011
2012
|
def backup_credentials(cls, filepath: str, cipher_key: str) -> bool:
|
|
2012
2013
|
try:
|
|
2013
2014
|
import hashlib
|
|
2014
|
-
import
|
|
2015
|
+
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
|
|
2016
|
+
|
|
2017
|
+
if not cipher_key:
|
|
2018
|
+
return False
|
|
2015
2019
|
creds = {}
|
|
2016
2020
|
for provider in PROVIDERS.keys():
|
|
2017
2021
|
secret = keyring.get_password(SERVICE_NAME, provider)
|
|
@@ -2020,12 +2024,10 @@ class KeyringSecretsBackupManager:
|
|
|
2020
2024
|
|
|
2021
2025
|
raw_data = json.dumps(creds).encode("utf-8")
|
|
2022
2026
|
salt = os.urandom(16)
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
payload = cls.MAGIC_HEADER + salt + tag + cipher_bytes
|
|
2027
|
+
nonce = os.urandom(12)
|
|
2028
|
+
header = cls.MAGIC_HEADER + salt + nonce
|
|
2029
|
+
key = hashlib.pbkdf2_hmac("sha256", cipher_key.encode("utf-8"), salt, cls.PBKDF2_ROUNDS)
|
|
2030
|
+
payload = header + AESGCM(key).encrypt(nonce, raw_data, header)
|
|
2029
2031
|
with open(filepath, "wb") as f:
|
|
2030
2032
|
f.write(payload)
|
|
2031
2033
|
return True
|
|
@@ -2062,7 +2064,7 @@ class KeyringSecretsBackupManager:
|
|
|
2062
2064
|
try:
|
|
2063
2065
|
with open(filepath, "rb") as f:
|
|
2064
2066
|
data = f.read()
|
|
2065
|
-
if not data or data.startswith(cls.MAGIC_HEADER):
|
|
2067
|
+
if not data or data.startswith((cls.MAGIC_HEADER, cls.LEGACY_AUTH_HEADER)):
|
|
2066
2068
|
return False
|
|
2067
2069
|
encrypted = bytearray(data)
|
|
2068
2070
|
key_bytes = cipher_key.encode("utf-8")
|
|
@@ -2074,7 +2076,7 @@ class KeyringSecretsBackupManager:
|
|
|
2074
2076
|
if not validated:
|
|
2075
2077
|
logger.error("Legacy backup rejected: invalid provider/credential schema")
|
|
2076
2078
|
return False
|
|
2077
|
-
logger.warning("Imported legacy unauthenticated backup; please re-export to
|
|
2079
|
+
logger.warning("Imported legacy unauthenticated backup; please re-export to authenticated AES-GCM TZB3 format.")
|
|
2078
2080
|
for provider, secret in validated.items():
|
|
2079
2081
|
keyring.set_password(SERVICE_NAME, provider, secret)
|
|
2080
2082
|
return True
|
|
@@ -2083,36 +2085,45 @@ class KeyringSecretsBackupManager:
|
|
|
2083
2085
|
return False
|
|
2084
2086
|
|
|
2085
2087
|
@classmethod
|
|
2086
|
-
def restore_credentials(cls, filepath: str, cipher_key: str, allow_legacy: bool =
|
|
2088
|
+
def restore_credentials(cls, filepath: str, cipher_key: str, allow_legacy: bool = False) -> bool:
|
|
2087
2089
|
try:
|
|
2088
2090
|
import hashlib
|
|
2089
2091
|
import hmac
|
|
2090
2092
|
with open(filepath, "rb") as f:
|
|
2091
2093
|
data = f.read()
|
|
2092
2094
|
|
|
2093
|
-
if data.startswith(cls.MAGIC_HEADER)
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2095
|
+
if data.startswith(cls.MAGIC_HEADER):
|
|
2096
|
+
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
|
|
2097
|
+
|
|
2098
|
+
if len(data) < 48:
|
|
2099
|
+
return False
|
|
2100
|
+
header = data[:32]
|
|
2101
|
+
salt, nonce = header[4:20], header[20:32]
|
|
2102
|
+
key = hashlib.pbkdf2_hmac("sha256", cipher_key.encode("utf-8"), salt, cls.PBKDF2_ROUNDS)
|
|
2103
|
+
raw_data = AESGCM(key).decrypt(nonce, data[32:], header)
|
|
2104
|
+
elif data.startswith(cls.LEGACY_AUTH_HEADER):
|
|
2105
|
+
if len(data) < 52:
|
|
2106
|
+
return False
|
|
2107
|
+
salt, tag, cipher_bytes = data[4:20], data[20:52], data[52:]
|
|
2097
2108
|
enc_key, mac_key = cls._derive_keys(cipher_key, salt)
|
|
2098
|
-
expected_tag = hmac.new(mac_key, cls.
|
|
2109
|
+
expected_tag = hmac.new(mac_key, cls.LEGACY_AUTH_HEADER + salt + cipher_bytes, hashlib.sha256).digest()
|
|
2099
2110
|
if not hmac.compare_digest(tag, expected_tag):
|
|
2100
2111
|
logger.error("Authentication failed: invalid passphrase or corrupted backup")
|
|
2101
2112
|
return False
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
validated = cls._validate_credential_map(json.loads(raw_data.decode("utf-8")))
|
|
2105
|
-
if not validated:
|
|
2106
|
-
logger.error("Backup payload failed schema validation")
|
|
2107
|
-
return False
|
|
2108
|
-
for provider, secret in validated.items():
|
|
2109
|
-
keyring.set_password(SERVICE_NAME, provider, secret)
|
|
2110
|
-
return True
|
|
2111
|
-
|
|
2112
|
-
if allow_legacy:
|
|
2113
|
+
raw_data = bytes(b ^ k for b, k in zip(cipher_bytes, cls._keystream(enc_key, len(cipher_bytes))))
|
|
2114
|
+
elif allow_legacy:
|
|
2113
2115
|
return cls.import_legacy_credentials(filepath, cipher_key)
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
+
else:
|
|
2117
|
+
logger.error("Rejected unauthenticated legacy backup (allow_legacy=False)")
|
|
2118
|
+
return False
|
|
2119
|
+
|
|
2120
|
+
validated = cls._validate_credential_map(json.loads(raw_data.decode("utf-8")))
|
|
2121
|
+
if not validated:
|
|
2122
|
+
logger.error("Backup payload failed schema validation")
|
|
2123
|
+
return False
|
|
2124
|
+
for provider, secret in validated.items():
|
|
2125
|
+
keyring.set_password(SERVICE_NAME, provider, secret)
|
|
2126
|
+
return True
|
|
2116
2127
|
except Exception as e:
|
|
2117
2128
|
logger.error(f"Restore keyring credentials failed: {e}")
|
|
2118
2129
|
return False
|
|
@@ -3603,18 +3614,16 @@ HorizontalProgressBarGroup = MonthlyStackedBarCard
|
|
|
3603
3614
|
|
|
3604
3615
|
|
|
3605
3616
|
class SecurityHubCard(LuxuryCard):
|
|
3606
|
-
"""Siber Akademi security badge & quick audit
|
|
3607
|
-
def __init__(self, parent, action_cmd=None,
|
|
3617
|
+
"""Siber Akademi security badge & quick audit card."""
|
|
3618
|
+
def __init__(self, parent, action_cmd=None, **kwargs):
|
|
3608
3619
|
super().__init__(parent, radius=18, padding=12, **kwargs)
|
|
3609
3620
|
tk.Label(self.inner, text="🛡 SİBER AKADEMİ SECURITY", font=("Segoe UI", 9, "bold"), fg=PALETTE.get("accent_cyan", "#3843a0"), bg=self.card_bg).pack(anchor=tk.W)
|
|
3610
|
-
tk.Label(self.inner, text="
|
|
3621
|
+
tk.Label(self.inner, text="Local source and secret checks", font=("Segoe UI", 7), fg=PALETTE.get("accent_green", "#10b981"), bg=self.card_bg).pack(anchor=tk.W, pady=(1, 6))
|
|
3611
3622
|
btn_row = tk.Frame(self.inner, bg=self.card_bg)
|
|
3612
3623
|
btn_row.pack(fill=tk.X)
|
|
3613
3624
|
self.btn = CanvasPillButton(btn_row, text="VIEW REPORT", command=action_cmd, height=28, radius=14, font=("Segoe UI", 7, "bold"), bg_color=PALETTE.get("card_hover", "#e0e7ff"), text_color=PALETTE.get("accent_cyan", "#3843a0"))
|
|
3614
3625
|
self.btn.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=(0, 3))
|
|
3615
|
-
|
|
3616
|
-
self.armor_btn = CanvasPillButton(btn_row, text="🛡️ ANTI-REA", command=armor_cmd, height=28, radius=14, font=("Segoe UI", 7, "bold"), bg_color="#064e3b", text_color="#34d399")
|
|
3617
|
-
self.armor_btn.pack(side=tk.RIGHT, fill=tk.X, expand=True, padx=(3, 0))
|
|
3626
|
+
|
|
3618
3627
|
|
|
3619
3628
|
class GlowingStatusDot(tk.Canvas):
|
|
3620
3629
|
def __init__(self, parent, size: int = 16, **kwargs):
|
|
@@ -5106,23 +5115,6 @@ class AutoReadmeGUI:
|
|
|
5106
5115
|
def run_quick_security_audit(self):
|
|
5107
5116
|
self.open_security_audit_dialog()
|
|
5108
5117
|
|
|
5109
|
-
def run_quick_anti_rea_armor(self):
|
|
5110
|
-
"""Executes 180-Tier Anti-REA Resistance audit & protection from GUI Security Hub."""
|
|
5111
|
-
target = (self.dir_entry.get().strip() if hasattr(self, "dir_entry") else "") or os.getcwd()
|
|
5112
|
-
try:
|
|
5113
|
-
from tzero.tzero_armor import audit_path_rea_resistance
|
|
5114
|
-
audit = audit_path_rea_resistance(target)
|
|
5115
|
-
score = audit.get("score", 0)
|
|
5116
|
-
rating = audit.get("rating", "UNKNOWN")
|
|
5117
|
-
self.log(f"[ANTI-REA AUDIT] Target: {target} | Score: {score}/100 ({rating})")
|
|
5118
|
-
messagebox.showinfo(
|
|
5119
|
-
"T-Zero 180-Tier Anti-REA Armor",
|
|
5120
|
-
f"Target: {target}\nAI Resistance Score: {score}/100 ({rating})\n"
|
|
5121
|
-
f"Active Defense Matrix: 12 Domains x 15 Sub-Tiers (Crypto Capsule, Opaque CFF, PolyVM, Anti-Debug, Anti-VM, RDTSC).",
|
|
5122
|
-
)
|
|
5123
|
-
except Exception as exc:
|
|
5124
|
-
self.log(f"[ANTI-REA ERROR] {exc}")
|
|
5125
|
-
|
|
5126
5118
|
def open_security_audit_dialog(self, target_dir: Optional[str] = None):
|
|
5127
5119
|
"""Runs a complete T-Zero 4-Tier Security & AST Architecture Audit (T-001 to T-004)
|
|
5128
5120
|
and displays an interactive luxury report dialog with filtering and export capabilities."""
|
|
@@ -5708,7 +5700,7 @@ class AutoReadmeGUI:
|
|
|
5708
5700
|
self.daily_card.grid(row=2, column=1, sticky="nsew", padx=4, pady=4)
|
|
5709
5701
|
|
|
5710
5702
|
# Card 9: Siber Akademi Security Hub Card
|
|
5711
|
-
self.security_card = SecurityHubCard(f, action_cmd=self.run_quick_security_audit
|
|
5703
|
+
self.security_card = SecurityHubCard(f, action_cmd=self.run_quick_security_audit)
|
|
5712
5704
|
self.security_card.grid(row=2, column=2, columnspan=2, sticky="nsew", padx=4, pady=4)
|
|
5713
5705
|
|
|
5714
5706
|
# --- TAB 7: SETTINGS & SECRETS MANAGEMENT ---
|
|
@@ -9569,105 +9561,6 @@ def main():
|
|
|
9569
9561
|
run_system_disk_doctor(clean=True, workspace_dir=target_dir)
|
|
9570
9562
|
sys.exit(0)
|
|
9571
9563
|
|
|
9572
|
-
# Fast path for Anti-REA armor / protection
|
|
9573
|
-
if len(sys.argv) > 1 and sys.argv[1].lower() in ("armor", "anti-rea", "--armor", "--anti-rea"):
|
|
9574
|
-
extra_args = sys.argv[2:]
|
|
9575
|
-
if any(flag in ("-h", "--help") for flag in extra_args):
|
|
9576
|
-
print("Usage: tzero armor [TARGET_PATH] [--audit]")
|
|
9577
|
-
print(" Protect source files against AI reverse engineering (180-Tier TDQS-REA Armor).")
|
|
9578
|
-
print(" --audit, -a Audit AI decompilation resistance without modifying files.")
|
|
9579
|
-
sys.exit(0)
|
|
9580
|
-
target_path = next((a for a in extra_args if not a.startswith("-")), ".")
|
|
9581
|
-
out_path = None
|
|
9582
|
-
for idx_a, a in enumerate(extra_args):
|
|
9583
|
-
if a in ("-o", "--output", "--out") and idx_a + 1 < len(extra_args):
|
|
9584
|
-
out_path = extra_args[idx_a + 1]
|
|
9585
|
-
break
|
|
9586
|
-
if any(flag in ("--audit", "-a") for flag in extra_args):
|
|
9587
|
-
from tzero.tzero_armor import audit_path_rea_resistance
|
|
9588
|
-
audit = audit_path_rea_resistance(target_path)
|
|
9589
|
-
print(json.dumps(audit, indent=2))
|
|
9590
|
-
sys.exit(0 if "error" not in audit else 1)
|
|
9591
|
-
from tzero.tzero_armor import protect_path_with_armor
|
|
9592
|
-
res = protect_path_with_armor(target_path, output_path=out_path)
|
|
9593
|
-
if res.get("success"):
|
|
9594
|
-
print(f"[OK] Applied Anti-REA Armor to: {target_path}")
|
|
9595
|
-
if "score_after" in res:
|
|
9596
|
-
print(f" AI Resistance Score: {res.get('score_before')}/100 -> {res.get('score_after')}/100 [{res.get('tier_rating', res.get('rating'))}]")
|
|
9597
|
-
print(f" Verified Tiers Active: {res.get('tiers_active', 0)}/{res.get('tiers_total', 180)} ({res.get('domains_active', 0)}/{res.get('domains_total', 12)} domains)")
|
|
9598
|
-
elif "files_protected" in res:
|
|
9599
|
-
print(f" Protected {res['files_protected']} files in directory.")
|
|
9600
|
-
else:
|
|
9601
|
-
print(f"[FAIL] Armor protection failed: {res.get('error', 'Unknown error')}", file=sys.stderr)
|
|
9602
|
-
sys.exit(0 if res.get("success") else 1)
|
|
9603
|
-
|
|
9604
|
-
# Fast path for Anti-REA audit
|
|
9605
|
-
if len(sys.argv) > 1 and sys.argv[1].lower() in ("audit-rea", "--audit-rea"):
|
|
9606
|
-
from tzero.tzero_armor import audit_path_rea_resistance
|
|
9607
|
-
target_path = sys.argv[2] if len(sys.argv) > 2 and not sys.argv[2].startswith("-") else "."
|
|
9608
|
-
audit = audit_path_rea_resistance(target_path)
|
|
9609
|
-
if audit.get("error"):
|
|
9610
|
-
print(f"[ERROR] {audit['error']}", file=sys.stderr)
|
|
9611
|
-
sys.exit(1)
|
|
9612
|
-
print("================================================================================")
|
|
9613
|
-
print(" SHIELD AUDIT REPORT: AI REVERSE-ENGINEERING RESISTANCE (TDQS-REA)")
|
|
9614
|
-
print("================================================================================")
|
|
9615
|
-
print(f"Target: {target_path}")
|
|
9616
|
-
print(f"AI Score: {audit.get('score', 0)} / 100 [{audit.get('tier_rating', audit.get('rating', 'UNVERIFIED'))}]")
|
|
9617
|
-
if "tiers_total" in audit:
|
|
9618
|
-
print(f"Tier Matrix: {audit.get('tiers_active', 0)} / {audit.get('tiers_total', 180)} Tiers ({audit.get('domains_active', 0)}/{audit.get('domains_total', 12)} Domains)")
|
|
9619
|
-
print(f"Score Basis: {audit.get('score_kind', 'static_textual_indicator')}")
|
|
9620
|
-
print(f"Status: {audit.get('status', 'N/A')}")
|
|
9621
|
-
if audit.get("defenses_active"):
|
|
9622
|
-
print("\nActive Defenses:")
|
|
9623
|
-
for k, v in audit["defenses_active"].items():
|
|
9624
|
-
print(f" [{'✔' if v else ' '}] {k}")
|
|
9625
|
-
if audit.get("unverified_layers"):
|
|
9626
|
-
print(f"\nUnverified Layers (not measured statically): {', '.join(audit['unverified_layers'])}")
|
|
9627
|
-
recs = audit.get("sample_findings") or audit.get("findings", [])
|
|
9628
|
-
if recs:
|
|
9629
|
-
print("\nRecommendations:")
|
|
9630
|
-
for f in recs:
|
|
9631
|
-
print(f" • {f}")
|
|
9632
|
-
print("================================================================================")
|
|
9633
|
-
sys.exit(0)
|
|
9634
|
-
|
|
9635
|
-
# Fast path for Anti-REA shield-exe
|
|
9636
|
-
if len(sys.argv) > 1 and sys.argv[1].lower() in ("shield-exe", "--shield-exe"):
|
|
9637
|
-
from tzero.tzero_armor import shield_executable
|
|
9638
|
-
target_path = sys.argv[2] if len(sys.argv) > 2 and not sys.argv[2].startswith("-") else ""
|
|
9639
|
-
if not target_path:
|
|
9640
|
-
print("Usage: tzero shield-exe <path_to_binary.exe>", file=sys.stderr)
|
|
9641
|
-
sys.exit(1)
|
|
9642
|
-
res = shield_executable(target_path)
|
|
9643
|
-
if res.get("shielded"):
|
|
9644
|
-
print(f"[OK] Shielded executable against pyinstxtractor: {res.get('output_path', target_path)}")
|
|
9645
|
-
print(f" Decoy archive traps injected: {res.get('decoy_traps_injected', 0)}")
|
|
9646
|
-
else:
|
|
9647
|
-
print(f"[INFO] {res.get('reason', 'Already shielded or not a PyInstaller binary.')}")
|
|
9648
|
-
sys.exit(0 if res.get("shielded") else 1)
|
|
9649
|
-
|
|
9650
|
-
# Fast path for Anti-REA radar / gui
|
|
9651
|
-
if len(sys.argv) > 1 and sys.argv[1].lower() in ("radar", "--radar", "anti-rea-gui"):
|
|
9652
|
-
radar_args = sys.argv[2:]
|
|
9653
|
-
if any(a in ("-h", "--help") for a in radar_args):
|
|
9654
|
-
print("Usage: tzero radar [PATH | --audit PATH | --armor PATH]\n"
|
|
9655
|
-
"Launch Anti-REA Radar GUI or run headless Anti-REA audit/armor on a target path.")
|
|
9656
|
-
sys.exit(0)
|
|
9657
|
-
if radar_args:
|
|
9658
|
-
from tzero.tzero_armor import audit_path_rea_resistance, protect_path_with_armor
|
|
9659
|
-
mode_armor = "--armor" in radar_args
|
|
9660
|
-
target = next((a for a in radar_args if not a.startswith("-")), ".")
|
|
9661
|
-
res = protect_path_with_armor(target) if mode_armor else audit_path_rea_resistance(target)
|
|
9662
|
-
print(json.dumps(res, indent=2))
|
|
9663
|
-
sys.exit(0 if res.get("success", True) else 1)
|
|
9664
|
-
try:
|
|
9665
|
-
from tzero.anti_rea.gui import main as gui_main
|
|
9666
|
-
gui_main()
|
|
9667
|
-
except Exception as e:
|
|
9668
|
-
print(f"Error launching Anti-REA GUI: {e}", file=sys.stderr)
|
|
9669
|
-
sys.exit(0)
|
|
9670
|
-
|
|
9671
9564
|
parser = argparse.ArgumentParser(
|
|
9672
9565
|
description="Siber Akademi T-Zero Context Architect - Enterprise Codebase Context Builder & Token Reducer",
|
|
9673
9566
|
epilog="""
|
|
@@ -9723,7 +9616,8 @@ def main():
|
|
|
9723
9616
|
parser.add_argument("--deep", action="store_true", help="Run deep offline subsystem self-check with all 9 v11 subsystems (use with --doctor)")
|
|
9724
9617
|
parser.add_argument("--pipe", nargs="?", const="", default=None, metavar="FILENAME_HINT", help="Read code/diff/schema from stdin, compress tokens, and output to stdout")
|
|
9725
9618
|
parser.add_argument("--clip", "--copy", nargs="?", const="", default=None, metavar="FILE", help="Prune file AST signatures and copy directly to system clipboard")
|
|
9726
|
-
parser.add_argument("--sync", nargs="?", const=".", default=None, metavar="DIR", help="
|
|
9619
|
+
parser.add_argument("--sync", nargs="?", const=".", default=None, metavar="DIR", help="Preview workspace rules for Cursor, Claude Code and Windsurf")
|
|
9620
|
+
parser.add_argument("--apply-sync", action="store_true", help="With --sync, create missing rule files without replacing existing ones")
|
|
9727
9621
|
parser.add_argument("--cost", nargs="?", const=".", default=None, metavar="DIR", help="Calculate real-time token cost and ROI financial cockpit")
|
|
9728
9622
|
parser.add_argument("--drift", nargs="?", const=".", default=None, metavar="DIR", help="Analyze quantitative instruction adherence and architectural rule drift")
|
|
9729
9623
|
parser.add_argument("--init-hooks", nargs="?", const=".", default=None, metavar="REPO_DIR", dest="init_hooks", help="Install zero-leak & token security pre-commit hook into .git/hooks")
|
|
@@ -9742,8 +9636,6 @@ def main():
|
|
|
9742
9636
|
parser.add_argument("--patch", "--apply-patch", dest="apply_patch", metavar="DIFF_FILE_OR_STR", help="Apply patch with AST-tolerant fuzzy matching (whitespace & line drift agnostic)")
|
|
9743
9637
|
parser.add_argument("--target", default=None, metavar="TARGET_FILE", help="Target file for --patch (optional if patch specifies file header)")
|
|
9744
9638
|
parser.add_argument("--fuzzy", action="store_true", default=True, help="Enable fuzzy AST and whitespace matching for patch application (default: True)")
|
|
9745
|
-
parser.add_argument("--armor", "--anti-rea", nargs="?", const=".", default=None, metavar="PATH", dest="armor", help="Apply military-grade Anti-REA armor against AI reverse engineering (morluto/rea)")
|
|
9746
|
-
parser.add_argument("--audit-rea", nargs="?", const=".", default=None, metavar="PATH", dest="audit_rea", help="Audit code or binary for resistance against AI reverse engineering (0-100)")
|
|
9747
9639
|
parser.add_argument("--telemetry", nargs="?", const=".", default=None, metavar="DIR", help="Show offline SQLite token savings & ROI telemetry report")
|
|
9748
9640
|
parser.add_argument("--no-fuzzy", dest="fuzzy", action="store_false", help="Disable fuzzy matching and enforce exact line matches only")
|
|
9749
9641
|
parser.add_argument("--dry-run-patch", action="store_true", help="Validate patch applicability without modifying files on disk")
|
|
@@ -9764,7 +9656,7 @@ def main():
|
|
|
9764
9656
|
default="o200k_base", help="BPE encoding for --symbol-context")
|
|
9765
9657
|
parser.add_argument("--cache-aligned", action="store_true", help="Order context for KV-cache prefix stability (immutable static prefix before dynamic query suffix)")
|
|
9766
9658
|
parser.add_argument("--commit-msg", action="store_true", help="Generate Conventional Commit message from local AST git diff ($0 local engine)")
|
|
9767
|
-
parser.add_argument("--changelog", nargs="?", const="v12.3.
|
|
9659
|
+
parser.add_argument("--changelog", nargs="?", const="v12.3.5", default=None, metavar="VERSION", help="Generate release CHANGELOG markdown from git history")
|
|
9768
9660
|
parser.add_argument("--ci", choices=["github", "gitlab", "pre-commit", "local", "all"], default=None, help="Install CI/CD workflow or run local verification suite")
|
|
9769
9661
|
parser.add_argument("--local-ci", action="store_true", help="Run comprehensive Local CI & Pre-Push verification battery ($0 quota burn)")
|
|
9770
9662
|
parser.add_argument("--quick-ci", action="store_true", help="Run fast Local CI smoke checks in seconds")
|
|
@@ -9828,7 +9720,7 @@ def main():
|
|
|
9828
9720
|
parser.add_argument("--card", "--badge", nargs="?", const="assets/tzero_badge_card.svg", default=None, metavar="FILE", help="Generate viral dark-mode SVG banner card and GitHub README badges")
|
|
9829
9721
|
parser.add_argument("--showcase", nargs="?", const="tzero_showcase.html", default=None, metavar="FILE", help="Generate interactive split-screen HTML5 comparison showcase slider")
|
|
9830
9722
|
parser.add_argument("--marketing", "--growth", action="store_true", help="Launch $0-budget viral growth engine and export campaign materials for Reddit, HN, X, and Product Hunt")
|
|
9831
|
-
parser.add_argument("--version", "-v", action="version", version="T-Zero Context Architect v12.3.
|
|
9723
|
+
parser.add_argument("--version", "-v", action="version", version="T-Zero Context Architect v12.3.5 Master Edition (engine v4.1.0)")
|
|
9832
9724
|
|
|
9833
9725
|
|
|
9834
9726
|
def print_master_tutorial():
|
|
@@ -9937,7 +9829,7 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
9937
9829
|
def print_quickstart_guide():
|
|
9938
9830
|
print("""
|
|
9939
9831
|
================================================================================
|
|
9940
|
-
⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & MCP v12.3.
|
|
9832
|
+
⚡ SİBER AKADEMİ — T-ZERO CONTEXT ARCHITECT & MCP v12.3.5 MASTER (engine v4.1.0)
|
|
9941
9833
|
================================================================================
|
|
9942
9834
|
🎯 %95'e Varan Token Tasarrufu & Otonom Yapay Zeka Mimari Bağlam Motoru
|
|
9943
9835
|
|
|
@@ -10147,29 +10039,6 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
10147
10039
|
from tzero.tzero_traffic import run_system_disk_doctor
|
|
10148
10040
|
run_system_disk_doctor(clean=True, workspace_dir=args.dir)
|
|
10149
10041
|
return
|
|
10150
|
-
elif getattr(args, "armor", None):
|
|
10151
|
-
if getattr(args, "audit", None) is not None:
|
|
10152
|
-
from tzero.tzero_armor import audit_path_rea_resistance
|
|
10153
|
-
audit = audit_path_rea_resistance(args.armor)
|
|
10154
|
-
print(json.dumps(audit, indent=2))
|
|
10155
|
-
return
|
|
10156
|
-
from tzero.tzero_armor import protect_path_with_armor
|
|
10157
|
-
res = protect_path_with_armor(args.armor, output_path=getattr(args, "output", None))
|
|
10158
|
-
if res.get("success"):
|
|
10159
|
-
print(f"[OK] Applied Anti-REA Armor to: {args.armor}")
|
|
10160
|
-
if "score_after" in res:
|
|
10161
|
-
print(f" AI Resistance Score: {res.get('score_before')}/100 -> {res.get('score_after')}/100 [{res.get('rating')}]")
|
|
10162
|
-
elif "files_protected" in res:
|
|
10163
|
-
print(f" Protected {res['files_protected']} files in directory.")
|
|
10164
|
-
else:
|
|
10165
|
-
print(f"[FAIL] Armor protection failed: {res.get('error', 'Unknown error')}", file=sys.stderr)
|
|
10166
|
-
sys.exit(1)
|
|
10167
|
-
return
|
|
10168
|
-
elif getattr(args, "audit_rea", None):
|
|
10169
|
-
from tzero.tzero_armor import audit_path_rea_resistance
|
|
10170
|
-
audit = audit_path_rea_resistance(args.audit_rea)
|
|
10171
|
-
print(json.dumps(audit, indent=2))
|
|
10172
|
-
sys.exit(1 if audit.get("error") else 0)
|
|
10173
10042
|
elif getattr(args, "telemetry", None) is not None:
|
|
10174
10043
|
from tzero.tzero_telemetry import get_summary, render_report
|
|
10175
10044
|
ws_dir = args.telemetry if args.telemetry != "." else (getattr(args, "dir", ".") or ".")
|
|
@@ -10266,9 +10135,9 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
10266
10135
|
elif args.sync is not None:
|
|
10267
10136
|
from tzero.tzero_sync import WorkspaceSyncManager
|
|
10268
10137
|
target = args.sync or args.dir
|
|
10269
|
-
res = WorkspaceSyncManager.sync(target)
|
|
10138
|
+
res = WorkspaceSyncManager.sync(target, apply=args.apply_sync)
|
|
10270
10139
|
WorkspaceSyncManager.render_cli(res)
|
|
10271
|
-
sys.exit(0)
|
|
10140
|
+
sys.exit(0 if res.success else 1)
|
|
10272
10141
|
elif args.cost is not None:
|
|
10273
10142
|
from tzero.tzero_cost import TokenCostCalculator
|
|
10274
10143
|
target = args.cost or args.dir
|
|
@@ -10916,7 +10785,7 @@ If this open-source tool helped you, please consider giving us a ⭐ on GitHub:
|
|
|
10916
10785
|
if not os.path.exists(app_path):
|
|
10917
10786
|
app_path = os.path.join(os.getcwd(), "huggingface-space", "app.py")
|
|
10918
10787
|
print("\033[36m" + "=" * 80)
|
|
10919
|
-
print("🤗 SİBER AKADEMİ — T-ZERO HUGGING FACE SPACE & GRADIO COCKPIT (v12.3.
|
|
10788
|
+
print("🤗 SİBER AKADEMİ — T-ZERO HUGGING FACE SPACE & GRADIO COCKPIT (v12.3.5)")
|
|
10920
10789
|
print("=" * 80 + "\033[0m")
|
|
10921
10790
|
print("🌐 Official Live Space : https://huggingface.co/spaces/toprakke4/tzero-token-reducer")
|
|
10922
10791
|
print(f"📁 Local Application : {app_path}")
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""Anti-REA: Military-Grade AI Reverse Engineering & Anti-Debugger Defense Engine.
|
|
3
|
-
|
|
4
|
-
World-class, 24-tier anti-reverse-engineering defense matrix against autonomous
|
|
5
|
-
AI agents (morluto/rea, Ghidra MCP, pyinstxtractor, IDA LLM) and uncensored/jailbroken LLMs.
|
|
6
|
-
Includes native Ring-3 anti-debugging against x64dbg, IDA Pro, WinDbg, and Cheat Engine,
|
|
7
|
-
opt-in tamper alert webhook, in-flight string vault, and Electron asar shielding.
|
|
8
|
-
|
|
9
|
-
Developer: Toprak Ahmet Aydoğmuş (Siber Akademi)
|
|
10
|
-
Part of Siber Akademi T-Zero Security Suite.
|
|
11
|
-
License: MIT
|
|
12
|
-
"""
|
|
13
|
-
|
|
14
|
-
__version__ = "5.0.0"
|
|
15
|
-
__author__ = "Toprak Ahmet Aydoğmuş"
|
|
16
|
-
__license__ = "MIT"
|
|
17
|
-
|
|
18
|
-
from .engine import AntiREAEngine
|
|
19
|
-
from .traps import AdversarialTrapGenerator
|
|
20
|
-
from .extractor_shield import ExtractorShield
|
|
21
|
-
from .flattener import ControlFlowFlattener
|
|
22
|
-
from .token_bomb import TokenBombGenerator
|
|
23
|
-
from .confusables import HomoglyphDesynchronizer
|
|
24
|
-
from .honeypot import HoneypotGenerator
|
|
25
|
-
from .mcp_poison import MCPProtocolPoisoner
|
|
26
|
-
from .sybil_network import SybilNetworkGenerator
|
|
27
|
-
from .timing_guard import TimingGuard
|
|
28
|
-
from .auditor import AIResistanceAuditor
|
|
29
|
-
from .vm_obfuscator import DynamicVMObfuscator
|
|
30
|
-
from .bytecode_trap import BytecodeTrap
|
|
31
|
-
from .jailbreak_decoy import CognitiveJailbreakDecoy
|
|
32
|
-
from .anti_agent_guard import AntiAgentGuard
|
|
33
|
-
from .algebraic_mutator import AlgebraicMutator
|
|
34
|
-
from .integrity_guard import MemoryIntegrityGuard
|
|
35
|
-
from .bpe_disrupter import BPETokenDisrupter
|
|
36
|
-
from .native_bridge import NativeBridge
|
|
37
|
-
from .anti_debugger import AntiDebugger
|
|
38
|
-
from .canary_beacon import CanaryBeacon
|
|
39
|
-
from .string_vault import StringVault
|
|
40
|
-
from .asar_shield import AsarShield
|
|
41
|
-
from .anti_vm import AntiVMGuard
|
|
42
|
-
from .rdtsc_guard import RDTSCTimingGuard
|
|
43
|
-
from .crypto_loader import CryptoBytecodeEnvelope
|
|
44
|
-
from .tier_catalog import (
|
|
45
|
-
ANTI_REA_DOMAINS,
|
|
46
|
-
ANTI_REA_TIERS,
|
|
47
|
-
TOTAL_TIER_COUNT,
|
|
48
|
-
get_tier_catalog,
|
|
49
|
-
evaluate_static_tier_coverage,
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
__all__ = [
|
|
53
|
-
"AntiREAEngine",
|
|
54
|
-
"AdversarialTrapGenerator",
|
|
55
|
-
"ExtractorShield",
|
|
56
|
-
"ControlFlowFlattener",
|
|
57
|
-
"TokenBombGenerator",
|
|
58
|
-
"HomoglyphDesynchronizer",
|
|
59
|
-
"HoneypotGenerator",
|
|
60
|
-
"MCPProtocolPoisoner",
|
|
61
|
-
"SybilNetworkGenerator",
|
|
62
|
-
"TimingGuard",
|
|
63
|
-
"AIResistanceAuditor",
|
|
64
|
-
"DynamicVMObfuscator",
|
|
65
|
-
"BytecodeTrap",
|
|
66
|
-
"CognitiveJailbreakDecoy",
|
|
67
|
-
"AntiAgentGuard",
|
|
68
|
-
"AlgebraicMutator",
|
|
69
|
-
"MemoryIntegrityGuard",
|
|
70
|
-
"BPETokenDisrupter",
|
|
71
|
-
"NativeBridge",
|
|
72
|
-
"AntiDebugger",
|
|
73
|
-
"CanaryBeacon",
|
|
74
|
-
"StringVault",
|
|
75
|
-
"AsarShield",
|
|
76
|
-
"AntiVMGuard",
|
|
77
|
-
"RDTSCTimingGuard",
|
|
78
|
-
"CryptoBytecodeEnvelope",
|
|
79
|
-
"ANTI_REA_DOMAINS",
|
|
80
|
-
"ANTI_REA_TIERS",
|
|
81
|
-
"TOTAL_TIER_COUNT",
|
|
82
|
-
"get_tier_catalog",
|
|
83
|
-
"evaluate_static_tier_coverage",
|
|
84
|
-
]
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""Tier 76-90 (Domain D06): Type-Safe AST Algebraic Identity & MBA Mutator.
|
|
3
|
-
|
|
4
|
-
Transforms integer arithmetic expressions (+, -, *) into Mixed Boolean-Arithmetic
|
|
5
|
-
(MBA) equivalents while guaranteeing 100% runtime compatibility for strings, floats,
|
|
6
|
-
lists, booleans, and custom objects via strict runtime type guards:
|
|
7
|
-
int + int ==> (x ^ y) + ((x & y) << 1)
|
|
8
|
-
int - int ==> (x ^ y) - (((~x) & y) << 1)
|
|
9
|
-
int * 2 ==> (x << 1)
|
|
10
|
-
|
|
11
|
-
Developer: Toprak Ahmet Aydogmus (Siber Akademi)
|
|
12
|
-
Part of Siber Akademi T-Zero Security Suite.
|
|
13
|
-
License: MIT
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
import ast
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
_MBA_RUNTIME_HEADER = '''# --- SIBER AKADEMI TYPE-SAFE MBA ARITHMETIC ENGINE (D06: REA-076..090) ---
|
|
20
|
-
def _tzero_mba_add(_a, _b):
|
|
21
|
-
if type(_a) is int and type(_b) is int:
|
|
22
|
-
return (_a ^ _b) + ((_a & _b) << 1)
|
|
23
|
-
return _a + _b
|
|
24
|
-
|
|
25
|
-
def _tzero_mba_sub(_a, _b):
|
|
26
|
-
if type(_a) is int and type(_b) is int:
|
|
27
|
-
return (_a ^ _b) - (((~_a) & _b) << 1)
|
|
28
|
-
return _a - _b
|
|
29
|
-
'''
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class AlgebraicIdentityTransformer(ast.NodeTransformer):
|
|
33
|
-
"""AST transformer converting pure/typed arithmetic into MBA representations safely."""
|
|
34
|
-
|
|
35
|
-
@staticmethod
|
|
36
|
-
def _is_pure_int_const(node: ast.AST) -> bool:
|
|
37
|
-
return isinstance(node, ast.Constant) and type(node.value) is int
|
|
38
|
-
|
|
39
|
-
@staticmethod
|
|
40
|
-
def _is_eligible_operand(node: ast.AST) -> bool:
|
|
41
|
-
return isinstance(node, (ast.Name, ast.BinOp, ast.Call)) or (
|
|
42
|
-
isinstance(node, ast.Constant) and type(node.value) is int
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
def visit_BinOp(self, node: ast.BinOp) -> ast.AST:
|
|
46
|
-
self.generic_visit(node)
|
|
47
|
-
|
|
48
|
-
if isinstance(node.op, ast.Add):
|
|
49
|
-
if self._is_pure_int_const(node.left) and self._is_pure_int_const(node.right):
|
|
50
|
-
xor_part = ast.BinOp(left=node.left, op=ast.BitXor(), right=node.right)
|
|
51
|
-
and_part = ast.BinOp(left=node.left, op=ast.BitAnd(), right=node.right)
|
|
52
|
-
shifted = ast.BinOp(left=and_part, op=ast.LShift(), right=ast.Constant(value=1))
|
|
53
|
-
return ast.copy_location(ast.BinOp(left=xor_part, op=ast.Add(), right=shifted), node)
|
|
54
|
-
if self._is_eligible_operand(node.left) and self._is_eligible_operand(node.right):
|
|
55
|
-
return ast.copy_location(
|
|
56
|
-
ast.Call(
|
|
57
|
-
func=ast.Name(id="_tzero_mba_add", ctx=ast.Load()),
|
|
58
|
-
args=[node.left, node.right],
|
|
59
|
-
keywords=[],
|
|
60
|
-
),
|
|
61
|
-
node,
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
elif isinstance(node.op, ast.Sub):
|
|
65
|
-
if self._is_pure_int_const(node.left) and self._is_pure_int_const(node.right):
|
|
66
|
-
xor_part = ast.BinOp(left=node.left, op=ast.BitXor(), right=node.right)
|
|
67
|
-
inv_left = ast.UnaryOp(op=ast.Invert(), operand=node.left)
|
|
68
|
-
and_part = ast.BinOp(left=inv_left, op=ast.BitAnd(), right=node.right)
|
|
69
|
-
shifted = ast.BinOp(left=and_part, op=ast.LShift(), right=ast.Constant(value=1))
|
|
70
|
-
return ast.copy_location(ast.BinOp(left=xor_part, op=ast.Sub(), right=shifted), node)
|
|
71
|
-
if self._is_eligible_operand(node.left) and self._is_eligible_operand(node.right):
|
|
72
|
-
return ast.copy_location(
|
|
73
|
-
ast.Call(
|
|
74
|
-
func=ast.Name(id="_tzero_mba_sub", ctx=ast.Load()),
|
|
75
|
-
args=[node.left, node.right],
|
|
76
|
-
keywords=[],
|
|
77
|
-
),
|
|
78
|
-
node,
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
elif isinstance(node.op, ast.Mult):
|
|
82
|
-
# Shift optimization ONLY when one operand is 2/4/8 AND the other is provably an int literal
|
|
83
|
-
if self._is_pure_int_const(node.right) and node.right.value in (2, 4, 8) and self._is_pure_int_const(node.left):
|
|
84
|
-
shift = {2: 1, 4: 2, 8: 3}[node.right.value]
|
|
85
|
-
return ast.copy_location(ast.BinOp(left=node.left, op=ast.LShift(), right=ast.Constant(value=shift)), node)
|
|
86
|
-
if self._is_pure_int_const(node.left) and node.left.value in (2, 4, 8) and self._is_pure_int_const(node.right):
|
|
87
|
-
shift = {2: 1, 4: 2, 8: 3}[node.left.value]
|
|
88
|
-
return ast.copy_location(ast.BinOp(left=node.right, op=ast.LShift(), right=ast.Constant(value=shift)), node)
|
|
89
|
-
|
|
90
|
-
return node
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
class AlgebraicMutator:
|
|
94
|
-
"""Public interface for applying type-safe Mixed Boolean-Arithmetic (MBA) AST mutations."""
|
|
95
|
-
|
|
96
|
-
@classmethod
|
|
97
|
-
def mutate_source_code(cls, source_code: str) -> str:
|
|
98
|
-
"""Applies type-safe algebraic identity mutation across expressions cleanly."""
|
|
99
|
-
try:
|
|
100
|
-
tree = ast.parse(source_code)
|
|
101
|
-
transformer = AlgebraicIdentityTransformer()
|
|
102
|
-
mutated_tree = transformer.visit(tree)
|
|
103
|
-
ast.fix_missing_locations(mutated_tree)
|
|
104
|
-
mutated = ast.unparse(mutated_tree)
|
|
105
|
-
return f"{_MBA_RUNTIME_HEADER}\n{mutated}"
|
|
106
|
-
except Exception:
|
|
107
|
-
return source_code
|