chg: fixes

pull/912/head
Adrian Maraj 2024-04-30 16:50:48 +02:00
parent e824fea97d
commit 427c6ed465
4 changed files with 9 additions and 16 deletions

View File

@ -116,7 +116,7 @@ class AsyncCapture(AbstractManager):
if send_report:
self.lookyloo.send_mail(uuid, email=settings.get('email', ''),
comment=settings.get('comment'), email_prio= settings["email"] if settings["email"] else None)
comment=settings.get('comment'), recipient_mail= settings.get("recipient_mail"))
lazy_cleanup = self.lookyloo.redis.pipeline()
if queue and self.lookyloo.redis.zscore('queues', queue):

View File

@ -864,7 +864,7 @@ class Lookyloo():
return f"Malicious capture according to {len(modules)} module(s): {', '.join(modules)}"
def send_mail(self, capture_uuid: str, /, email: str='', comment: str | None=None, email_prio: str | None = None) -> bool | dict[str, Any]:
def send_mail(self, capture_uuid: str, /, email: str='', comment: str | None=None, recipient_mail: str | None = None) -> bool | dict[str, Any]:
'''Send an email notification regarding a specific capture'''
if not get_config('generic', 'enable_mail_notification'):
return {"error": "Unable to send mail: mail notification disabled"}
@ -913,7 +913,7 @@ class Lookyloo():
msg['From'] = email_config['from']
if email:
msg['Reply-To'] = email
msg['To'] = email_config['to'] if not email_prio else email_prio
msg['To'] = email_config['to'] if not recipient_mail else recipient_mail
msg['Subject'] = email_config['subject']
body = get_email_template()
body = body.format(

View File

@ -12,6 +12,7 @@ import json
import logging
import logging.config
import os
import re
import sys
import time
@ -1638,8 +1639,10 @@ def simple_capture() -> str | Response | WerkzeugResponse:
user = flask_login.current_user.get_id()
else:
user = src_request_ip(request)
if request.method == 'POST':
if not re.match("^[A-Za-z]+$", user):
flash('User is not permitted.', 'error')
return redirect(url_for('simple_capture'))
if not (request.form.get('url') or request.form.get('urls')):
flash('Invalid submission: please submit at least a URL.', 'error')
return render_template('simple_capture.html')
@ -1649,7 +1652,7 @@ def simple_capture() -> str | Response | WerkzeugResponse:
path = get_homedir() /'config'/ 'users' / (user + ".json")
if os.path.isfile(path):
email = get_config(user, 'email')
capture_query['auto_report'] = {"email": email}
capture_query['auto_report'] = {"recipient_mail": email}
else:
capture_query['auto_report'] = True
if request.form.get('url'):

View File

@ -63,20 +63,10 @@
</div>
</div>
<hr>
<!-- End of Submission type -->
<center>
<b>
{% if default_public %}
By default, the capture is private. If you do not want that, untick the box at the top of the form.
{% else %}
By default, the capture is private (not visible on the index page). If you want it to be public tick the box at the top of the form.
{% endif %}
</b>
</br>
</br>
<button type="submit" class="new-capture-button btn btn-primary" id="btn-looking">Start looking!</button>
<button type="submit" class="new-capture-button btn btn-primary" id="btn-looking">Submit!</button>
</center>
</form>
</div>