<commit_before># -*- coding: utf-8 -*-

import falcon, util, json, sys, traceback

# Content-security policy reports of frontend
# Every CSP report is forwarded to <EMAIL>.
# This is testing solution, if a lot of spam occurs, some intelligence should
# be added to this endpoint.

class CSP(object):

    def on_post(self, req, resp):
        data = json.loads(req.stream.read())
        text = "<p>" + util.config.ksi_web() + \
            "<br><pre>" + json.dumps(data, indent=4) + "</pre></p>" + \
            util.mail.easteregg()

        try:
            util.mail.send("<EMAIL>", "[KSI-WEB] CSP report", text.decode('utf-8'), )
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()<commit_msg>Send CSP reports right to apophis.<commit_after># -*- coding: utf-8 -*-

import falcon, util, json, sys, traceback

# Content-security policy reports of frontend
# Every CSP report is forwarded to <EMAIL>.
# This is testing solution, if a lot of spam occurs, some intelligence should
# be added to this endpoint.

class CSP(object):

    def on_post(self, req, resp):
        data = json.loads(req.stream.read())
        text = "<p>" + util.config.ksi_web() + \
            "<br><pre>" + json.dumps(data, indent=4) + "</pre></p>" + \
            util.mail.easteregg()

        try:
            util.mail.send("<EMAIL>", "[KSI-WEB] CSP report", text.decode('utf-8'), )
        except:
            exc_type, exc_value, exc_traceback = sys.exc_info()
{'fraction_non_alphanumeric': 0.15274949083503056, 'fraction_numerical': 0.004073319755600814, 'mean_word_length': 2.6758104738154613, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6489371', 'n_tokens_mistral': 479, 'n_tokens_neox': 472, 'n_words': 136}