fix csp violation

master
Aevann 2022-12-28 12:25:52 +02:00
parent 98f262e640
commit c326c999f2
3 changed files with 9 additions and 20 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -335,11 +335,14 @@ def donate(v):
return render_template(f'donate_{SITE_NAME}.html', v=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') @app.post('/csp_violations')
@limiter.limit("10/minute;50/day") @limiter.limit("10/minute;50/day")
def csp_violations(): def csp_violations():
content = request.get_json(force=True) content = json.dumps(request.get_json())
content = str(json.dumps(content, indent=4, sort_keys=True)) if content["source-file"].startswith(SITE_FULL):
if f'"source-file": "{SITE_FULL}' in content: print('--------', flush=True)
print(content, flush=True) for i in items_we_want:
print(f"{i}: {content['i']}")
return '' return ''