@@ -594,10 +594,51 @@ def output_pdf(
594
594
exploits : bool = False ,
595
595
all_product_data = None ,
596
596
):
597
+ """Output a PDF of CVEs
598
+ Required module: Reportlab not found"""
597
599
LOGGER .warning ("PDF output requires install of reportlab" )
598
600
599
601
600
602
class OutputEngine :
603
+ """
604
+ Class represention of OutputEngine
605
+ Attributes:
606
+ all_cve_data (dict[ProductInfo, CVEData])
607
+ scanned_dir (str)
608
+ filename (str)
609
+ themes_dir (str)
610
+ time_of_last_update
611
+ tag (str)
612
+ logger
613
+ products_with_cve (int)
614
+ products_without_cve (int)
615
+ total_files (int)
616
+ is_report (bool)
617
+ no_zero_cve_report (bool)
618
+ append
619
+ merge_report
620
+ affected_versions (int)
621
+ all_cve_version_info
622
+ detailed (bool)
623
+ vex_filename (str)
624
+ exploits (bool)
625
+ all_product_data
626
+ sbom_filename (str)
627
+ sbom_type (str)
628
+ sbom_format (str)
629
+ sbom_root (str)
630
+ offline (bool)
631
+
632
+ Methods:
633
+ output_cves: Output a list of CVEs to other formats like CSV or JSON.
634
+ generate_vex: Generate a vex file and create vulnerability entry.
635
+ generate_sbom: Create SBOM package and generate SBOM file.
636
+ output_file_wrapper:
637
+ output_file: Generate a file for list of CVE
638
+ check_file_path: Generate a new filename if file already exists.
639
+ check_dir_path: Generate a new filename if filepath is a directory.
640
+ """
641
+
601
642
def __init__ (
602
643
self ,
603
644
all_cve_data : dict [ProductInfo , CVEData ],
@@ -626,6 +667,7 @@ def __init__(
626
667
sbom_root : str = "CVE_SBOM" ,
627
668
offline : bool = False ,
628
669
):
670
+ """Constructor for OutputEngine class."""
629
671
self .logger = logger or LOGGER .getChild (self .__class__ .__name__ )
630
672
self .all_cve_version_info = all_cve_version_info
631
673
self .scanned_dir = scanned_dir
@@ -735,6 +777,7 @@ def output_cves(self, outfile, output_type="console"):
735
777
)
736
778
737
779
def generate_vex (self , all_cve_data : dict [ProductInfo , CVEData ], filename : str ):
780
+ """Generate a vex file and create vulnerability entry."""
738
781
analysis_state = {
739
782
Remarks .NewFound : "in_triage" ,
740
783
Remarks .Unexplored : "in_triage" ,
@@ -840,6 +883,7 @@ def generate_sbom(
840
883
sbom_format = "tag" ,
841
884
sbom_root = "CVE-SCAN" ,
842
885
):
886
+ """Create SBOM package and generate SBOM file."""
843
887
# Create SBOM
844
888
sbom_packages = {}
845
889
sbom_relationships = []
@@ -895,6 +939,7 @@ def generate_sbom(
895
939
my_generator .generate (parent , my_sbom .get_sbom (), filename = filename )
896
940
897
941
def output_file_wrapper (self , output_types = ["console" ]):
942
+ """Call output_file method for all output types."""
898
943
for output_type in output_types :
899
944
self .output_file (output_type )
900
945
@@ -959,6 +1004,7 @@ def output_file(self, output_type="console"):
959
1004
self .output_cves (f , output_type )
960
1005
961
1006
def check_file_path (self , filepath : str , output_type : str , prefix : str = "output" ):
1007
+ """Generate a new filename if file already exists."""
962
1008
# check if the file already exists
963
1009
if Path (filepath ).is_file ():
964
1010
self .logger .warning (f"Failed to write at '{ filepath } '. File already exists" )
@@ -970,6 +1016,7 @@ def check_file_path(self, filepath: str, output_type: str, prefix: str = "output
970
1016
def check_dir_path (
971
1017
self , filepath : str , output_type : str , prefix : str = "intermediate"
972
1018
):
1019
+ """Generate a new filename if filepath is a directory."""
973
1020
if Path (filepath ).is_dir ():
974
1021
self .logger .info (
975
1022
f"Generating a new filename with Default Naming Convention in directory path { filepath } "
0 commit comments