def email_subscriptions(xss_uid, url): """ Email all users who are subscribed to assessments. """ email_list = [] notify_jobs = Payload.query.filter_by(id=xss_uid).first() user_notify = User.query.all() # Loop through every User and intersect if the capture is associated with # an assessment they are subscribed to recieve notificaitons for. for i in xrange(len(user_notify)): user_subscriptions = [] for e in user_notify[i].assessments: user_subscriptions.append(e.id) if len(set(notify_jobs.show_assessment_ids()).intersection(user_subscriptions)) > 0: email_list.append(user_notify[i].email) # If there are people to email, email them that a capture was recieved if email_list: msg = Message("[Sleepy Puppy] - Capture Recieved From: " + url, sender=app.config['MAIL_SENDER'], recipients=email_list) msg.html = "<b>Associated Assessments: <b>" + notify_jobs.show_assessment_names() + "<br><br>" flask_mail.send(msg)
def email_subscriptions(xss_uid, url): """ Email all users who are subscribed to assessments. """ email_list = [] notify_jobs = Payload.query.filter_by(id=xss_uid).first() user_notify = User.query.all() # Loop through every User and intersect if the capture is associated with # an assessment they are subscribed to recieve notificaitons for. for i in xrange(len(user_notify)): user_subscriptions = [] for e in user_notify[i].assessments: user_subscriptions.append(e.id) if len(set(notify_jobs.show_assessment_ids()).intersection(user_subscriptions)) > 0: email_list.append(user_notify[i].email) # If there are people to email, email them that a capture was recieved if email_list: msg = Message( "[Sleepy Puppy] - Capture Recieved From: " + url, sender=app.config["MAIL_SENDER"], recipients=email_list ) msg.html = "<b>Associated Assessments: <b>" + notify_jobs.show_assessment_names() + "<br><br>" flask_mail.send(msg)
subject, html, email, format="html") app.logger.debug("Emailed {} - {} ".format(email, subject)) except Exception, e: m = "Failed to send failure message to {} from {} with subject: {}\n{} {}".format( email, app.config['MAIL_SENDER'], subject, Exception, e) app.logger.debug(m) else: msg = Message(subject, sender=app.config['MAIL_SENDER'], recipients=email_list) msg.html = html flask_mail.send(msg) # Disable CSRF protection on callback posts @csrf_protect.exempt @app.route('/callbacks', methods=['POST', 'GET']) def get_callbacks(): """ Method to handle Capture creation. """ response = Response() response.headers.add('Access-Control-Allow-Origin', request.headers.get("Origin", None)) response.headers.add('Access-Control-Allow-Methods', 'GET,POST') response.headers.add('Access-Control-Max-Age', '21600') response.headers.add('Access-Control-Allow-Credentials', 'true')
email, app.config['MAIL_SENDER'], subject, Exception, e ) app.logger.debug(m) else: msg = Message( subject, sender=app.config['MAIL_SENDER'], recipients=email_list ) msg.html = html try: flask_mail.send(msg) except Exception as err: app.logger.debug(Exception) app.logger.debug(err) @csrf_protect.exempt @app.route('/generic_callback', methods=['POST', 'GET']) def get_generic_callback(): """ Method to handle generic callbacks from arbitrary puppyscripts. Expects Method: POST Data: payload, puppyscript_name, data Optional Data: referrer, url