1- from typing import (
2- List ,
3- Dict ,
4- Any ,
5- )
6- import logging
71import hashlib
2+ import logging
3+ from typing import Any
84
95# any line after FIX_START and before FIX_END
106# will be rewritten when copy to the dev machine
117# commented lines will be uncommented
128# and uncommented lines will be commented
13-
9+ # //
1410# FIX_START
1511from dojo .models import Finding
1612from dojo .tools .reversinglabs_spectraassure .rlJsonInfo import RlJsonInfo
1713from dojo .tools .reversinglabs_spectraassure .rlJsonInfo .cve_info_node import CveInfoNode
1814# from finding import Finding
15+ #
1916# from .rlJsonInfo import RlJsonInfo
2017# from .rlJsonInfo.cve_info_node import CveInfoNode
2118#
5249 We have components with the same name and version but different hash value.
5350 This is typical for windows installers with multi language support.
5451 A good example is: HxDSetup_2.5.0.exe
55- """
5652
57-
58- class ReversinglabsSpectraassureParser (object ):
59- """
6053 Parser for Spectra Assure rl-json files
6154
6255 This class MUST implement 3 methods:
@@ -78,7 +71,10 @@ class ReversinglabsSpectraassureParser(object):
7871
7972 If your parser has more than 1 scan_type (for detailed mode) you MUST implement:
8073 - def set_mode(self, mode) method
81- """
74+ """
75+
76+
77+ class ReversinglabsSpectraassureParser :
8278
8379 # --------------------------------------------
8480 # This class MUST have an empty constructor or no constructor
@@ -113,23 +109,17 @@ def _one_finding(
113109 date = node .scan_date ,
114110 title = node .title ,
115111 description = node .title + " " + node .description + "\n " ,
116- #
117112 cve = cve ,
118113 cvssv3_score = node .score ,
119114 severity = node .score_severity ,
120- #
121115 vuln_id_from_tool = node .vuln_id_from_tool ,
122116 unique_id_from_tool = node .unique_id_from_tool , # purl if we have one ?
123- #
124117 file_path = node .component_file_path ,
125118 component_name = node .component_name ,
126119 component_version = node .component_version ,
127- #
128120 nb_occurences = 1 ,
129121 hash_code = key , # sha256 on title
130- #
131122 references = None , # future urls
132- #
133123 active = True , # this is the DefectDojo active field, nothing to do with node.active field
134124 test = test ,
135125 static_finding = True ,
@@ -143,7 +133,7 @@ def _one_finding(
143133
144134 # --------------------------------------------
145135 # PUBLIC
146- def get_scan_types (self ) -> List [str ]:
136+ def get_scan_types (self ) -> list [str ]:
147137 return [WHAT ]
148138
149139 def get_label_for_scan_types (self , scan_type : str ) -> str :
@@ -158,15 +148,15 @@ def get_findings(
158148 self ,
159149 file : Any ,
160150 test : Any ,
161- ) -> List [Finding ]:
151+ ) -> list [Finding ]:
162152 # ------------------------------------
163153 rji = RlJsonInfo (file_handle = file )
164154 rji .get_cve_active_all ()
165155
166- self ._findings : List [Finding ] = []
167- self ._duplicates : Dict [str , Finding ] = {}
156+ self ._findings : list [Finding ] = []
157+ self ._duplicates : dict [str , Finding ] = {}
168158
169- for cin in rji .iter_results ():
159+ for cin in rji .get_results_list ():
170160 finding = self ._one_finding (
171161 node = cin ,
172162 test = test ,
@@ -181,9 +171,9 @@ def get_findings(
181171 continue
182172
183173 dup = self ._duplicates [key ] # but that may be on a different component file, name, version
184- assert dup is not None
185- dup .description += finding .description
186- dup .nb_occurences += 1
174+ if dup :
175+ dup .description += finding .description
176+ dup .nb_occurences += 1
187177
188178 # ------------------------------------
189179 return self ._findings
0 commit comments