Files
Geniusia_v2/archive/old_scripts/diagnostic_whitelist.py
2026-03-05 00:20:25 +01:00

87 lines
2.5 KiB
Python
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
Diagnostic de la liste blanche
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent / "geniusia2"))
from core.config import get_config
from core.logger import Logger
from core.whitelist_manager import WhitelistManager
def main():
print("\n" + "="*60)
print(" 🔍 DIAGNOSTIC LISTE BLANCHE")
print("="*60 + "\n")
# Charger la config
config = get_config()
logger = Logger()
print("📋 Configuration:")
print(f" enforce_whitelist: {config['security'].get('enforce_whitelist')}")
print(f" ask_before_new_window: {config['security'].get('ask_before_new_window')}")
print()
# Créer le whitelist manager
whitelist_manager = WhitelistManager(logger=logger)
print("🛡️ Liste Blanche:")
whitelist = whitelist_manager.get_whitelist()
if whitelist:
print(f" {len(whitelist)} fenêtre(s) autorisée(s):")
for window in whitelist:
print(f" - {window}")
else:
print(" ❌ Liste vide (aucune fenêtre autorisée)")
print()
# Tester quelques fenêtres
test_windows = [
"Kiro",
"Firefox",
"Chrome",
"Terminal",
"Code",
"Unknown Window"
]
print("🧪 Test de fenêtres:")
for window in test_windows:
allowed = whitelist_manager.is_window_allowed(window)
status = "✅ Autorisée" if allowed else "❌ Bloquée"
print(f" {window:20} : {status}")
print()
print("="*60)
print(" 💡 SOLUTION")
print("="*60 + "\n")
if not whitelist:
print("La liste blanche est vide !")
print()
print("Options :")
print()
print("1⃣ Mode Permissif (Recommandé pour les tests)")
print(" - Dans l'app, le bouton 'Mode: Tout Autoriser' devrait être activé")
print(" - Vérifie que enforce_whitelist = False dans la config")
print()
print("2⃣ Ajouter des fenêtres à la liste blanche")
print(" - Dans l'app, clique sur 'Gérer la Liste Blanche'")
print(" - Ajoute 'Kiro', 'Firefox', etc.")
print()
else:
print("La liste blanche contient des fenêtres.")
print("Si tu veux observer d'autres fenêtres :")
print(" - Ajoute-les via le bouton 'Gérer la Liste Blanche'")
print(" - Ou active le 'Mode: Tout Autoriser'")
print()
if __name__ == "__main__":
main()