fix /csp_violations

pull/110/head
Aevann 2023-02-02 19:33:47 +02:00
parent 24ba5a6663
commit ae83aa15ed
1 changed files with 5 additions and 10 deletions

View File

@ -356,17 +356,12 @@ def donate(v):
return render_template(f'donate_{SITE_NAME}.html', v=v)
items_we_want = ('blocked-uri', 'document-uri', 'effective-directive', 'source-file', 'violated-directive')
@app.post('/csp_violations')
@limiter.limit("10/minute;50/day")
def csp_violations():
content = json.dumps(request.get_json())
try:
if content["source-file"].startswith(SITE_FULL):
print('--------', flush=True)
for i in items_we_want:
print(f"{i}: {content['i']}", flush=True)
except:
print(content, flush=True)
content = request.get_json(force=True)['csp-report']
print('--------', flush=True)
for k, val in content.items():
print(f"{k}: {val}", flush=True)
print('--------', flush=True)
return ''