74 lines
1.8 KiB
Python
74 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Script pour générer un rapport factorisé des vulnérabilités critiques
|
|
suivant la structure définie dans Remarques.md.
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
import streamlit as st
|
|
|
|
from utils.config import (
|
|
TEMP_SECTIONS,
|
|
TEMPLATE_PATH, session_uuid,
|
|
load_config
|
|
)
|
|
|
|
from utils.files import (
|
|
write_report
|
|
)
|
|
|
|
from utils.graphs import (
|
|
parse_graphs,
|
|
extract_data_from_graph,
|
|
calculate_vulnerabilities
|
|
)
|
|
|
|
from utils.sections import (
|
|
generate_report
|
|
)
|
|
|
|
from utils.sections_utils import (
|
|
nettoyer_texte_fr
|
|
)
|
|
|
|
from utils.ia import (
|
|
ingest_document,
|
|
ia_analyse,
|
|
supprimer_fichiers,
|
|
generer_rapport_final
|
|
)
|
|
|
|
|
|
def main(dot_path, output_path):
|
|
"""Fonction principale du script."""
|
|
# Charger la configuration
|
|
config = load_config()
|
|
|
|
# Analyser les graphes
|
|
graph, ref_graph = parse_graphs(dot_path)
|
|
# Extraire les données
|
|
data = extract_data_from_graph(graph, ref_graph)
|
|
# Calculer les vulnérabilités
|
|
results = calculate_vulnerabilities(data, config)
|
|
if "step" not in st.session_state:
|
|
st.session_state["step"] = 1
|
|
# Générer le rapport
|
|
report, file_names = generate_report(data, results, config)
|
|
# Écrire le rapport
|
|
write_report(report, TEMPLATE_PATH)
|
|
ingest_document(TEMPLATE_PATH)
|
|
# Générer l'analyse par l'IA du rapport complet
|
|
analyse_finale = nettoyer_texte_fr(ia_analyse(file_names))
|
|
analyse_fichier = TEMP_SECTIONS / TEMPLATE_PATH.name.replace(".md", " - analyse.md")
|
|
write_report(analyse_finale, analyse_fichier)
|
|
|
|
if generer_rapport_final(TEMPLATE_PATH, analyse_fichier, output_path):
|
|
supprimer_fichiers(session_uuid)
|
|
|
|
if __name__ == "__main__":
|
|
dot_path = Path(sys.argv[1])
|
|
output_path = Path(sys.argv[2])
|
|
main(dot_path, output_path)
|