@@ -155,7 +155,8 @@ async def search_vulnerabilities(
155155 search_text = " with " + ", " .join (search_desc ) if search_desc else ""
156156 return [
157157 types .TextContent (
158- type = "text" , text = f"No vulnerabilities found{ search_text } ."
158+ type = "text" ,
159+ text = f"No vulnerabilities found{ search_text } ." ,
159160 )
160161 ]
161162
@@ -180,7 +181,7 @@ async def search_vulnerabilities(
180181 cve = vuln_data .get ("cve" , {})
181182 cve_id = cve .get ("id" , "Unknown" )
182183 published = cve .get ("published" , "Unknown" )
183- last_modified = cve .get ("lastModified" , "Unknown" )
184+ cve .get ("lastModified" , "Unknown" )
184185
185186 # Get description
186187 descriptions = cve .get ("descriptions" , [])
@@ -200,7 +201,11 @@ async def search_vulnerabilities(
200201 severity_emoji = "⚪"
201202
202203 # Try CVSS 3.1 first, then 3.0, then 2.0
203- for version in ["cvssMetricV31" , "cvssMetricV30" , "cvssMetricV2" ]:
204+ for version in [
205+ "cvssMetricV31" ,
206+ "cvssMetricV30" ,
207+ "cvssMetricV2" ,
208+ ]:
204209 if version in metrics and metrics [version ]:
205210 metric = metrics [version ][0 ] # Take first metric
206211 cvss_data = metric .get ("cvssData" , {})
@@ -224,7 +229,7 @@ async def search_vulnerabilities(
224229 try :
225230 pub_date = datetime .fromisoformat (published .replace ("Z" , "+00:00" ))
226231 pub_formatted = pub_date .strftime ("%Y-%m-%d" )
227- except :
232+ except ( ValueError , TypeError , AttributeError ) :
228233 pub_formatted = (
229234 published [:10 ] if len (published ) >= 10 else published
230235 )
@@ -281,6 +286,7 @@ async def search_vulnerabilities(
281286 except Exception as e :
282287 return [
283288 types .TextContent (
284- type = "text" , text = f"Error: Failed to search vulnerabilities: { str (e )} "
289+ type = "text" ,
290+ text = f"Error: Failed to search vulnerabilities: { str (e )} " ,
285291 )
286292 ]
0 commit comments