v1.0 - Version stable: multi-PC, détection UI-DETR-1, 3 modes exécution
- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
99
test_server_decryption.py
Normal file
99
test_server_decryption.py
Normal file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test de déchiffrement côté serveur pour diagnostiquer le problème "Padding invalide".
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
# Ajouter les chemins nécessaires
|
||||
sys.path.insert(0, str(Path(__file__).parent))
|
||||
sys.path.insert(0, str(Path(__file__).parent / "agent_v0"))
|
||||
|
||||
def test_server_decryption():
|
||||
"""Test du déchiffrement côté serveur."""
|
||||
print("=== Test de déchiffrement côté serveur ===")
|
||||
|
||||
# Charger .env.local comme le fait le serveur
|
||||
env_local_path = Path(".env.local")
|
||||
if env_local_path.exists():
|
||||
with open(env_local_path, 'r') as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#') and '=' in line:
|
||||
key, value = line.split('=', 1)
|
||||
os.environ[key.strip()] = value.strip()
|
||||
|
||||
server_encryption_password = os.getenv("ENCRYPTION_PASSWORD")
|
||||
print(f"ENCRYPTION_PASSWORD: {server_encryption_password[:16]}..." if server_encryption_password else "ENCRYPTION_PASSWORD: NON DÉFINI")
|
||||
|
||||
try:
|
||||
from agent_v0.raw_session import RawSession
|
||||
from agent_v0.storage_encrypted import create_session_zip_encrypted
|
||||
from agent_v0.user_config import load_user_config
|
||||
|
||||
# Charger la config agent
|
||||
agent_config = load_user_config()
|
||||
agent_encryption_password = agent_config.get("encryption_password")
|
||||
|
||||
# Créer une session de test
|
||||
test_session = RawSession.create(
|
||||
user_id="test_server_decryption",
|
||||
platform="linux",
|
||||
hostname="test_host",
|
||||
screen_resolution=[1920, 1080]
|
||||
)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
# Sauvegarder la session
|
||||
test_session.save_json(tmpdir)
|
||||
|
||||
# Chiffrer avec la config agent
|
||||
encrypted_path = create_session_zip_encrypted(
|
||||
test_session,
|
||||
agent_encryption_password,
|
||||
tmpdir,
|
||||
delete_unencrypted=False
|
||||
)
|
||||
print(f"Fichier chiffré: {encrypted_path}")
|
||||
|
||||
# Tenter le déchiffrement côté serveur
|
||||
try:
|
||||
from storage_encrypted import decrypt_session_file as decrypt_file
|
||||
print("Module storage_encrypted importé")
|
||||
except ImportError:
|
||||
try:
|
||||
from agent_v0.storage_encrypted import decrypt_session_file as decrypt_file
|
||||
print("Module agent_v0.storage_encrypted importé")
|
||||
except ImportError:
|
||||
print("❌ Impossible d'importer storage_encrypted")
|
||||
return False
|
||||
|
||||
# Déchiffrer avec la clé serveur
|
||||
try:
|
||||
decrypted_path = decrypt_file(
|
||||
encrypted_path,
|
||||
server_encryption_password,
|
||||
os.path.join(tmpdir, "server_decrypted.zip")
|
||||
)
|
||||
print(f"✅ Déchiffrement réussi: {decrypted_path}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur de déchiffrement: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Erreur: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_server_decryption()
|
||||
sys.exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user