@@ -31,8 +31,12 @@ def _format_vulnerability(self, vuln_dict):
3131 """Format a vulnerability dictionary as a string"""
3232 vuln_id = vuln_dict .get ('id' , 'VULN' )
3333 description = vuln_dict .get ('description' , '' )
34- severity = vuln_dict .get ('severity' , '' ).upper ()
35- formatted = f"[{ vuln_id } ] { description } ({ severity } )"
34+ sev_colored = vuln_dict .get ('severity_colored' )
35+ if sev_colored :
36+ formatted = f"[{ vuln_id } ] { description } ({ sev_colored } )"
37+ else :
38+ severity = vuln_dict .get ('severity' , '' ).upper ()
39+ formatted = f"[{ vuln_id } ] { description } ({ severity } )"
3640 if 'details' in vuln_dict :
3741 formatted += f" - { vuln_dict ['details' ]} "
3842 return formatted
@@ -60,7 +64,6 @@ def paged_search(self,
6064 no_vuln_check = no_vuln_check or self .no_vuln_check
6165 raw = raw or self .raw
6266
63- # Save the original formatter
6467 original_formatter = None
6568 if raw and self .server and hasattr (self .server , 'custom_formatter' ):
6669 logging .debug ("[CustomStandardExtendedOperations] Unsetting custom formatter" )
@@ -73,18 +76,15 @@ def paged_search(self,
7376 if cached_results is not None :
7477 logging .debug ("[CustomStandardExtendedOperations] Returning cached results for query" )
7578
76- # Mark results as coming from cache
7779 for entry in cached_results :
7880 if 'attributes' in entry :
7981 entry ['from_cache' ] = True
8082
81- # Process vulnerabilities for all objects
8283 if not no_vuln_check :
8384 for entry in cached_results :
8485 if 'attributes' in entry :
8586 vulnerabilities = self .vulnerability_detector .detect_vulnerabilities (entry ['attributes' ])
8687 if vulnerabilities :
87- # Convert dictionary vulnerabilities to formatted strings
8888 entry ['attributes' ]['vulnerabilities' ] = [self ._format_vulnerability (v ) for v in vulnerabilities ]
8989
9090 return cached_results
@@ -131,7 +131,6 @@ def paged_search(self,
131131 if self .use_adws :
132132 results = list (adws_paged_search_generator (self ._connection , modified_dn , modified_filter , search_scope , attributes , size_limit , time_limit , types_only , get_operational_attributes , controls , paged_size , paged_criticality ))
133133 else :
134- # Get all results first so we can post-process them
135134 results = list (paged_search_generator (self ._connection ,
136135 modified_dn ,
137136 modified_filter ,
@@ -146,29 +145,24 @@ def paged_search(self,
146145 paged_size ,
147146 paged_criticality ))
148147
149- # Filter out non-search results
150148 filtered_results = []
151149 for entry in results :
152150 if entry ['type' ] != 'searchResEntry' :
153151 continue
154152
155- # Strip entries if requested
156153 if strip_entries :
157154 strip_entry (entry )
158155
159156 filtered_results .append (entry )
160157
161- # Process vulnerabilities for all objects
162158 if not no_vuln_check :
163159 for entry in filtered_results :
164160 if 'attributes' in entry :
165161 vulnerabilities = self .vulnerability_detector .detect_vulnerabilities (entry ['attributes' ])
166162 if vulnerabilities :
167- # Convert dictionary vulnerabilities to formatted strings
168163 entry ['attributes' ]['vulnerabilities' ] = [self ._format_vulnerability (v ) for v in vulnerabilities ]
169164
170165 if not no_cache :
171- # Remove from_cache attribute before caching if it exists
172166 for entry in filtered_results :
173167 if 'attributes' in entry and 'from_cache' in entry ['attributes' ]:
174168 del entry ['attributes' ]['from_cache' ]
@@ -208,37 +202,31 @@ def paged_search(self,
208202 paged_criticality
209203 ))
210204
211- # Filter out non-search results and strip entries if requested
212205 filtered_results = []
213206 for entry in results :
214207 if hasattr (entry , 'type' ) and entry ['type' ] != 'searchResEntry' :
215208 continue
216209
217- # Strip entries if requested
218210 if strip_entries :
219211 strip_entry (entry )
220212
221213 filtered_results .append (entry )
222214
223- # Process vulnerabilities for all objects
224215 if not no_vuln_check :
225216 for entry in filtered_results :
226217 if 'attributes' in entry :
227218 vulnerabilities = self .vulnerability_detector .detect_vulnerabilities (entry ['attributes' ])
228219 if vulnerabilities :
229- # Convert dictionary vulnerabilities to formatted strings
230220 entry ['attributes' ]['vulnerabilities' ] = [self ._format_vulnerability (v ) for v in vulnerabilities ]
231221
232222 if not no_cache :
233- # Remove from_cache attribute before caching if it exists
234223 for entry in filtered_results :
235224 if 'attributes' in entry and 'from_cache' in entry ['attributes' ]:
236225 del entry ['attributes' ]['from_cache' ]
237226
238227 self .storage .cache_results (search_base , search_filter , search_scope , attributes , host = self .server .host , results = filtered_results , raw = raw )
239228 return filtered_results
240229 finally :
241- # Restore the original formatter
242230 if raw and original_formatter is not None and self .server :
243231 self .server .custom_formatter = original_formatter
244232
0 commit comments