Ajuste salida si hay 'patch'
This commit is contained in:
parent
a1aeba27b5
commit
2c789e9d45
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
echo "Revisando vulnerabilidades de productos mediante ENISA"
|
||||
./check_EUVD.py
|
||||
echo "Transformando informe en formato Markdown en PDF"
|
||||
echo " Transformando informe en formato Markdown en PDF"
|
||||
pandoc -V lang=es -V geometry:a4paper -V geometry:margin=2cm --pdf-engine=xelatex -V monofont="DejaVu Sans Mono" --metadata author="Luis Gutiérrez López (Software Libre)" informe_vulnerabilidades.md -o informe_vulnerabilidades.pdf
|
||||
echo
|
||||
echo "Informe Finalizado"
|
||||
|
||||
@ -44,6 +44,32 @@ def matches_product_version(target_version_str, product_version_str):
|
||||
return True, "Versión indeterminada en la fuente (Revisar manualmente)"
|
||||
|
||||
t_ver = parse_single_version(target_version_str)
|
||||
|
||||
# Procesar si aparece como "parche" en ENISA
|
||||
if product_version_str.lower().startswith("patch:"):
|
||||
patch_version = product_version_str.split(":", 1)[1].strip()
|
||||
|
||||
target_version = parse_single_version(target_version_str)
|
||||
fixed_version = parse_single_version(patch_version)
|
||||
|
||||
if target_version and fixed_version:
|
||||
if target_version >= fixed_version:
|
||||
return (
|
||||
False,
|
||||
f"Versión ya corregida mediante parche {fixed_version}"
|
||||
)
|
||||
else:
|
||||
return (
|
||||
True,
|
||||
f"{target_version} anterior al parche {fixed_version}"
|
||||
)
|
||||
|
||||
return (
|
||||
False,
|
||||
f"Versión marcada como corregida mediante parche {patch_version}"
|
||||
)
|
||||
|
||||
|
||||
if not t_ver:
|
||||
if target_version_str.strip().lower() in product_version_str.lower():
|
||||
return True, f"Coincidencia directa por cadena '{product_version_str}'"
|
||||
@ -105,7 +131,7 @@ def matches_product_version(target_version_str, product_version_str):
|
||||
return False, f"No cumple condiciones: {rule_msg}"
|
||||
|
||||
|
||||
def fetch_fast_enisa_vulnerabilities(vendor, product, from_score=7.0, days_back=730):
|
||||
def fetch_fast_enisa_vulnerabilities(vendor, product, from_score=7.0, days_back=90):
|
||||
vulnerabilities = []
|
||||
from_date = (datetime.now(timezone.utc) - timedelta(days=days_back)).strftime("%Y-%m-%d")
|
||||
|
||||
@ -150,7 +176,7 @@ def fetch_fast_enisa_vulnerabilities(vendor, product, from_score=7.0, days_back=
|
||||
|
||||
except Exception as e:
|
||||
if attempt == max_retries - 1:
|
||||
print(f" ❌ Error final para {product}: {e}")
|
||||
print(f" Error final para {product}: {e}")
|
||||
time.sleep(2)
|
||||
|
||||
return vulnerabilities
|
||||
@ -235,7 +261,7 @@ def generate_markdown_report(total_consolidados, total_analizadas, total_aplicab
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
f.write(md_content)
|
||||
|
||||
print(f"📝 Informe Markdown generado exitosamente en '{output_file}'")
|
||||
print(f" Informe Markdown generado exitosamente en '{output_file}'")
|
||||
|
||||
|
||||
def process_targets(config_path="targets.yaml"):
|
||||
@ -243,7 +269,7 @@ def process_targets(config_path="targets.yaml"):
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
config = yaml.safe_load(f)
|
||||
except FileNotFoundError:
|
||||
print(f"❌ Archivo '{config_path}' no encontrado.")
|
||||
print(f" Archivo '{config_path}' no encontrado.")
|
||||
return
|
||||
|
||||
resumen_objetivos = []
|
||||
@ -255,7 +281,7 @@ def process_targets(config_path="targets.yaml"):
|
||||
total_no_aplicables = 0
|
||||
total_revision = 0
|
||||
|
||||
print("🚀 Iniciando análisis de precisión en ENISA EUVD...\n")
|
||||
print(" Iniciando análisis de precisión en ENISA EUVD...\n")
|
||||
|
||||
for target in config.get("targets", []):
|
||||
vendor = target.get("vendor", "")
|
||||
@ -263,9 +289,9 @@ def process_targets(config_path="targets.yaml"):
|
||||
version = target.get("version", "")
|
||||
|
||||
total_consolidados += 1
|
||||
print(f"👉 Analizando: {vendor}/{product} (v{version})")
|
||||
print(f" Analizando: {vendor}/{product} (v{version})")
|
||||
|
||||
items = fetch_fast_enisa_vulnerabilities(vendor=vendor, product=product, from_score=0.0, days_back=730)
|
||||
items = fetch_fast_enisa_vulnerabilities(vendor=vendor, product=product, from_score=0.0, days_back=90)
|
||||
|
||||
num_analizadas = len(items)
|
||||
num_aplicables = 0
|
||||
@ -332,7 +358,7 @@ def process_targets(config_path="targets.yaml"):
|
||||
"Revisión manual": num_revision
|
||||
})
|
||||
|
||||
print(f" 📊 Analizadas: {num_analizadas} | Aplicables: {num_aplicables} | Descartadas por versión: {num_no_aplicables}\n")
|
||||
print(f" Analizadas: {num_analizadas} | Aplicables: {num_aplicables} | Descartadas por versión: {num_no_aplicables}\n")
|
||||
time.sleep(0.5)
|
||||
|
||||
reporte_json = {
|
||||
@ -355,7 +381,7 @@ def process_targets(config_path="targets.yaml"):
|
||||
output_file="informe_vulnerabilidades.md"
|
||||
)
|
||||
|
||||
print("✅ Análisis finalizado y archivo 'informe_vulnerabilidades.md' actualizado con éxito.")
|
||||
print(" Análisis finalizado y archivo 'informe_vulnerabilidades.md' actualizado con éxito.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
process_targets()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user