Skip to content

task/WI-472: Created view for collecting reports on content-security-policy violations. - #1349

Draft
fnets wants to merge 3 commits into
mainfrom
task/WI-472
Draft

task/WI-472: Created view for collecting reports on content-security-policy violations.#1349
fnets wants to merge 3 commits into
mainfrom
task/WI-472

Conversation

@fnets

@fnets fnets commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Overview

Adds a view to receive and log Content-Security-Policy violation reports sent by browsers, in support of the report-only CSP rollout (see companion nginx PR below).

Related

Changes

Created view for collecting reports on content-security-policy violations. Accepts POST only, and logs it via a dedicated csp_reports logger, and always returns 204. Malformed requests are logged and still return 204.

Testing

  1. Confirm curl -X POST /csp-report/ returns 204 and the payload appears in container logs.
  2. Confirm via django.urls.resolve('/csp-report/') that this view (not the CMS catch-all) is what's actually served.
  3. Confirm in browser that real CSP violations trigger both a console warning and a successful report POST.

Notes

The csp-report/ pattern must stay above cms.urls in the include order. During testing, having it below the catch-all caused requests to silently forward to cms.views.details instead of this view.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 43.75000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.17%. Comparing base (caf8ebb) to head (f28e11d).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
server/portal/views/views.py 40.00% 9 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1349      +/-   ##
==========================================
+ Coverage   64.09%   64.17%   +0.08%     
==========================================
  Files         461      464       +3     
  Lines       13793    13880      +87     
  Branches     2750     2771      +21     
==========================================
+ Hits         8841     8908      +67     
- Misses       4603     4618      +15     
- Partials      349      354       +5     
Flag Coverage Δ
javascript 67.25% <ø> (+0.14%) ⬆️
unittests 60.92% <43.75%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
server/portal/settings/settings.py 0.00% <ø> (ø)
server/portal/urls.py 72.22% <100.00%> (-1.47%) ⬇️
server/portal/views/views.py 40.42% <40.00%> (-0.20%) ⬇️

... and 14 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant