new: Allow API user to force re-caching the captures on URL/Hostname request

pull/585/head
Raphaël Vinot 2023-01-20 11:15:33 +01:00
parent 621bea6896
commit d449edeb23
2 changed files with 6 additions and 4 deletions

View File

@ -757,9 +757,9 @@ class Lookyloo():
return captures[0]
return None
def get_url_occurrences(self, url: str, /, limit: int=20) -> List[Dict]:
def get_url_occurrences(self, url: str, /, limit: int=20, cached_captures_only: bool=True) -> List[Dict]:
'''Get the most recent captures and URL nodes where the URL has been seen.'''
captures = self.sorted_capture_cache(self.indexing.get_captures_url(url))
captures = self.sorted_capture_cache(self.indexing.get_captures_url(url), cached_captures_only=cached_captures_only)
to_return: List[Dict] = []
for capture in captures[:limit]:
@ -777,9 +777,9 @@ class Lookyloo():
to_return.append(to_append)
return to_return
def get_hostname_occurrences(self, hostname: str, /, with_urls_occurrences: bool=False, limit: int=20) -> List[Dict]:
def get_hostname_occurrences(self, hostname: str, /, with_urls_occurrences: bool=False, limit: int=20, cached_captures_only: bool=True) -> List[Dict]:
'''Get the most recent captures and URL nodes where the hostname has been seen.'''
captures = self.sorted_capture_cache(self.indexing.get_captures_hostname(hostname))
captures = self.sorted_capture_cache(self.indexing.get_captures_hostname(hostname), cached_captures_only=cached_captures_only)
to_return: List[Dict] = []
for capture in captures[:limit]:

View File

@ -280,6 +280,7 @@ class HashInfo(Resource):
url_info_fields = api.model('URLInfoFields', {
'url': fields.String(description="The URL to search", required=True),
'limit': fields.Integer(description="The maximal amount of captures to return", example=20),
'cached_captures_only': fields.Boolean(description="If false, re-cache the missing captures (can take a while)", default=True),
})
@ -297,6 +298,7 @@ class URLInfo(Resource):
hostname_info_fields = api.model('HostnameInfoFields', {
'hostname': fields.String(description="The hostname to search", required=True),
'limit': fields.Integer(description="The maximal amount of captures to return", example=20),
'cached_captures_only': fields.Boolean(description="If false, re-cache the missing captures (can take a while)", default=True),
})