From cd482e1b3189a3183e57833a9acb347a602b1e9f Mon Sep 17 00:00:00 2001 From: Yume05-dev <266928269+Yume05-dev@users.noreply.github.com> Date: Wed, 11 Mar 2026 12:20:16 -0400 Subject: [PATCH 1/3] add robust validation logic for schema integritya --- schema_validator.py | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 schema_validator.py diff --git a/schema_validator.py b/schema_validator.py new file mode 100644 index 000000000..4e10363e6 --- /dev/null +++ b/schema_validator.py @@ -0,0 +1,68 @@ +import json +import os +import sys +import xml.etree.ElementTree as ET + +# Intentamos importar yaml para soporte extendido +try: + import yaml + HAS_YAML = True +except ImportError: + HAS_YAML = False + +def validar_archivo(ruta): + if not os.path.exists(ruta): + print(f"Error: El archivo {ruta} no existe.") + sys.exit(1) + + extension = os.path.splitext(ruta)[1].lower() + + # Validacion de JSON + if extension == ".json": + try: + with open(ruta, "r", encoding="utf-8") as f: + json.load(f) + print("Confirmado: Archivo JSON valido.") + except json.JSONDecodeError as e: + print(f"Error en JSON: {e}") + sys.exit(1) + + # Validacion de YAML + elif extension in [".yaml", ".yml"]: + if not HAS_YAML: + print("Error: Libreria PyYAML no instalada.") + sys.exit(1) + try: + with open(ruta, "r", encoding="utf-8") as f: + yaml.safe_load(f) + print("Confirmado: Archivo YAML valido.") + except Exception as e: + print(f"Error en YAML: {e}") + sys.exit(1) + + # Validacion de XML (Especifico para el Bounty de ZIO) + elif extension == ".xml": + try: + tree = ET.parse(ruta) + # Verificacion basica de estructura + root = tree.getroot() + if root is None: + raise ValueError("El archivo XML esta vacio o no tiene nodo raiz.") + print(f"Confirmado: Archivo XML valido. Nodo raiz detectado: {root.tag}") + except ET.ParseError as e: + print(f"Error de sintaxis en XML: {e}") + sys.exit(1) + except Exception as e: + print(f"Error inesperado en XML: {e}") + sys.exit(1) + + else: + print("Error: Formato no soportado. Use .json, .yaml o .xml") + sys.exit(1) + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Uso: python validator.py ") + else: + validar_archivo(sys.argv[1]) + From c37de72a3b0bb12ecd6ca1ffac8d9a5ebb75cced Mon Sep 17 00:00:00 2001 From: Yume05-dev <266928269+Yume05-dev@users.noreply.github.com> Date: Wed, 11 Mar 2026 12:32:01 -0400 Subject: [PATCH 2/3] add multi-format validator --- vigilancia_pendiente.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 vigilancia_pendiente.json diff --git a/vigilancia_pendiente.json b/vigilancia_pendiente.json new file mode 100644 index 000000000..bc85abeb9 --- /dev/null +++ b/vigilancia_pendiente.json @@ -0,0 +1 @@ +{"monto": "500", "wallet": "0xD9D9300003b141D825cB7f217162be01F5fe3871", "fecha": "Wed Mar 11 12:20:37 2026", "repo": "D:\\Blue_Dragon\\Kin\\projects\\yume\\yume_works\\trabajos\\zio-schema"} \ No newline at end of file From 84d2352f65222a9b26274f2d6f53a079ce271a83 Mon Sep 17 00:00:00 2001 From: Yume05-dev <266928269+Yume05-dev@users.noreply.github.com> Date: Wed, 11 Mar 2026 12:37:19 -0400 Subject: [PATCH 3/3] add multi-format validator --- vigilancia_pendiente.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vigilancia_pendiente.json b/vigilancia_pendiente.json index bc85abeb9..bd7b6eae5 100644 --- a/vigilancia_pendiente.json +++ b/vigilancia_pendiente.json @@ -1 +1 @@ -{"monto": "500", "wallet": "0xD9D9300003b141D825cB7f217162be01F5fe3871", "fecha": "Wed Mar 11 12:20:37 2026", "repo": "D:\\Blue_Dragon\\Kin\\projects\\yume\\yume_works\\trabajos\\zio-schema"} \ No newline at end of file +{"monto": "500", "wallet": "0xD9D9300003b141D825cB7f217162be01F5fe3871", "fecha": "Wed Mar 11 12:32:18 2026", "repo": "D:\\Blue_Dragon\\Kin\\projects\\yume\\yume_works\\trabajos\\zio-schema"} \ No newline at end of file