mirror of https://github.com/CIRCL/lookyloo
new: get uuids by category via API
parent
b20ddb4788
commit
e4268554b9
|
@ -794,3 +794,31 @@ class CaptureHide(Resource): # type: ignore[misc]
|
|||
class RecentCaptures(Resource): # type: ignore[misc]
|
||||
def get(self, timestamp: str | float | None=None) -> list[str]:
|
||||
return lookyloo.get_recent_captures(since=timestamp)
|
||||
|
||||
|
||||
@api.route('/json/categories')
|
||||
@api.route('/json/categories/<string:category>')
|
||||
@api.doc(description='Get uuids for a specific category.',
|
||||
params={'category': 'The category according to which the uuids are to be returned.'},
|
||||
required=False)
|
||||
class CategoriesCaptures(Resource): # type: ignore[misc]
|
||||
def get(self, category: str | None=None) -> list[str] | dict[str, list[str]] | None:
|
||||
categories = ['legitimate', 'parking-page', 'default-page', 'insti_usertution', 'captcha',
|
||||
'authentication-form', 'adult-content', 'shop', 'malicious', 'clone', 'phishing', 'unclear']
|
||||
if not category:
|
||||
all_categorized_uuids: dict[str, set[str]] = {}
|
||||
for c in categories:
|
||||
one_categorie = get_indexing(flask_login.current_user).get_captures_category(c)
|
||||
if not one_categorie:
|
||||
continue
|
||||
for uuid in one_categorie:
|
||||
if uuid not in all_categorized_uuids:
|
||||
all_categorized_uuids[uuid] = {c}
|
||||
else:
|
||||
all_categorized_uuids[uuid].add(c)
|
||||
all_categorized_uuids = {uuid: list(categories) for uuid, categories in all_categorized_uuids.items()}
|
||||
return all_categorized_uuids
|
||||
if not category in categories:
|
||||
return {'error': f'Invalid category: {category}'}
|
||||
return list(get_indexing(flask_login.current_user).get_captures_category(category))
|
||||
|
||||
|
|
Loading…
Reference in New Issue