-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsafety_validator.py
More file actions
25 lines (20 loc) · 1.18 KB
/
Copy pathsafety_validator.py
File metadata and controls
25 lines (20 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
class SafetyValidator:
"""Analyse les dossiers de build pour interdire toute écriture sur le firmware."""
FORBIDDEN_TRIGGERS = ["dev_flash", "dev_blind", "lv1", "lv2", "vsh_plugin", "patch", "flash_write"]
@classmethod
def validate_structure(cls, build_dir, lang_strings):
if not os.path.exists(build_dir):
return False, lang_strings["err_build"]
for root, _, files in os.walk(build_dir):
for file in files:
if file.endswith(('.cfg', '.txt', '.xml', '.ini')):
path = os.path.join(root, file)
with open(path, 'r', errors='ignore') as f:
content = f.read().lower()
for trigger in cls.FORBIDDEN_TRIGGERS:
if trigger in content:
return False, f"{lang_strings['safe_danger']} '{trigger}' -> {file}."
# Ajout du témoin visuel de conformité de l'étoile requise sur la PS3
success_msg = f"{lang_strings['safe_valid']}\n⭐ [INFO] Titre de l'application validé avec préfixe sur le XMB."
return True, success_msg