Skip to content

Commit 16214c1

Browse files
Feature/allow exact match search when searching for latest url analyses (#115)
* Add exact match option to from_latest_analysis in UrlAnalysis * Add change logs
1 parent 1c81b45 commit 16214c1

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGES

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.19.1
2+
------
3+
- Add "exact_match option" to UrlAnalysis.from_latest_analysis.
4+
15
1.19
26
------
37
- Change "received_by" label to "reported_by" in submit phishing alert.

intezer_sdk/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.19'
1+
__version__ = '1.19.1'

intezer_sdk/analysis.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,14 @@ def from_analysis_id(cls, analysis_id: str, api: IntezerApiClient = None) -> Opt
380380
def from_latest_analysis(cls,
381381
url: str,
382382
days_threshold_for_latest_analysis: int = 1,
383-
api: IntezerApiClient = None) -> Optional['UrlAnalysis']:
383+
api: IntezerApiClient = None,
384+
exact_match=False) -> Optional['UrlAnalysis']:
384385
"""
385386
Returns a UrlAnalysis instance with the latest analysis of the given URL.
386387
:param url: The URL to retrieve the latest analysis for.
387388
:param days_threshold_for_latest_analysis: The number of days to look back for the latest analysis.
388389
: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.
389391
:return: A UrlAnalysis instance with the latest analysis of the given URL.
390392
"""
391393
now = datetime.datetime.now()
@@ -398,7 +400,10 @@ def from_latest_analysis(cls,
398400
all_analyses_reports = analysis_history_url_result.all()
399401

400402
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']))]
402407

403408
if not analyses_ids:
404409
return None

0 commit comments

Comments
 (0)