mirror of https://github.com/CIRCL/lookyloo
Merge branch 'AntoniaBK-Send_mail_api'
commit
9ffe9f23e9
|
@ -761,10 +761,10 @@ class Lookyloo():
|
||||||
result.append(self.takedown_details(rendered_hostnode))
|
result.append(self.takedown_details(rendered_hostnode))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def send_mail(self, capture_uuid: str, /, email: str='', comment: str | None=None) -> None:
|
def send_mail(self, capture_uuid: str, /, email: str='', comment: str | None=None) -> bool | dict[str, Any]:
|
||||||
'''Send an email notification regarding a specific capture'''
|
'''Send an email notification regarding a specific capture'''
|
||||||
if not get_config('generic', 'enable_mail_notification'):
|
if not get_config('generic', 'enable_mail_notification'):
|
||||||
return
|
return {"error": "Unable to send mail: mail notification disabled"}
|
||||||
|
|
||||||
email_config = get_config('generic', 'email')
|
email_config = get_config('generic', 'email')
|
||||||
smtp_auth = get_config('generic', 'email_smtp_auth')
|
smtp_auth = get_config('generic', 'email_smtp_auth')
|
||||||
|
@ -828,6 +828,8 @@ class Lookyloo():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.exception(e)
|
self.logger.exception(e)
|
||||||
self.logger.warning(msg.as_string())
|
self.logger.warning(msg.as_string())
|
||||||
|
return {"error": "Unable to send mail"}
|
||||||
|
return True
|
||||||
|
|
||||||
def _get_raw(self, capture_uuid: str, /, extension: str='*', all_files: bool=True) -> BytesIO:
|
def _get_raw(self, capture_uuid: str, /, extension: str='*', all_files: bool=True) -> BytesIO:
|
||||||
'''Get file(s) from the capture directory'''
|
'''Get file(s) from the capture directory'''
|
||||||
|
|
|
@ -381,7 +381,16 @@ class CaptureCookies(Resource): # type: ignore[misc]
|
||||||
return json.loads(lookyloo.get_cookies(capture_uuid).read())
|
return json.loads(lookyloo.get_cookies(capture_uuid).read())
|
||||||
|
|
||||||
|
|
||||||
# Just text
|
@api.route('/json/<string:capture_uuid>/report')
|
||||||
|
@api.doc(description='Reports the url by sending an email to the investigation team',
|
||||||
|
params={'capture_uuid': 'The UUID of the capture'})
|
||||||
|
class CaptureReport(Resource): # type: ignore[misc]
|
||||||
|
@api.param('email', 'Email of the reporter, used by the analyst to get in touch.') # type: ignore[misc]
|
||||||
|
@api.param('comment', 'Description of the URL, will be given to the analyst.') # type: ignore[misc]
|
||||||
|
def post(self, capture_uuid: str) -> bool | dict[str, Any]:
|
||||||
|
parameters: dict[str, Any] = request.get_json(force=True)
|
||||||
|
return lookyloo.send_mail(capture_uuid, parameters.get('email', ''), parameters.get('comment'))
|
||||||
|
|
||||||
|
|
||||||
auto_report_model = api.model('AutoReportModel', {
|
auto_report_model = api.model('AutoReportModel', {
|
||||||
'email': fields.String(description="Email of the reporter, used by the analyst to get in touch.", example=''),
|
'email': fields.String(description="Email of the reporter, used by the analyst to get in touch.", example=''),
|
||||||
|
|
Loading…
Reference in New Issue