@@ -380,12 +380,14 @@ def from_analysis_id(cls, analysis_id: str, api: IntezerApiClient = None) -> Opt
380
380
def from_latest_analysis (cls ,
381
381
url : str ,
382
382
days_threshold_for_latest_analysis : int = 1 ,
383
- api : IntezerApiClient = None ) -> Optional ['UrlAnalysis' ]:
383
+ api : IntezerApiClient = None ,
384
+ exact_match = False ) -> Optional ['UrlAnalysis' ]:
384
385
"""
385
386
Returns a UrlAnalysis instance with the latest analysis of the given URL.
386
387
:param url: The URL to retrieve the latest analysis for.
387
388
:param days_threshold_for_latest_analysis: The number of days to look back for the latest analysis.
388
389
:param api: The API connection to Intezer.
390
+ :param exact_match: If True, the URL must match exactly. Otherwise, try to find similar URLs which were analyzed.
389
391
:return: A UrlAnalysis instance with the latest analysis of the given URL.
390
392
"""
391
393
now = datetime .datetime .now ()
@@ -398,7 +400,10 @@ def from_latest_analysis(cls,
398
400
all_analyses_reports = analysis_history_url_result .all ()
399
401
400
402
analyses_ids = [report ['analysis_id' ] for report in all_analyses_reports
401
- if _clean_url (url ) in (_clean_url (report ['scanned_url' ]), _clean_url (report ['submitted_url' ]))]
403
+ if url in (report ['scanned_url' ], report ['submitted_url' ])]
404
+ if not analyses_ids and not exact_match :
405
+ analyses_ids = [report ['analysis_id' ] for report in all_analyses_reports
406
+ if _clean_url (url ) in (_clean_url (report ['scanned_url' ]), _clean_url (report ['submitted_url' ]))]
402
407
403
408
if not analyses_ids :
404
409
return None
0 commit comments