Repository navigation
Pyjoyment.Plugin.SecurityHeaders: reports, the route of the reports of CSP - #639
Merged
Merged
Conversation
…f CSP The option reports adds a route that takes the reports of report-uri and of report-to, logs each violation and emits the hook csp_report, and puts report-uri and report-to into the policies of a dict without them, with Reporting-Endpoints, with the prefix of an application that is mounted. max_report_size limits the body. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Docker Smoke Test
|
Contributor
Tests
|
6 of 7 tasks
7 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #634, its fourth step, stacked on #638.
Changes
reports, the path of a route namedcsp_reports:cspandcsp_report_onlygiven as dicts, which have noreport-uriorreport-toof their own, getreport-uri(for browsers without the Reporting API) andreport-to csp. Responses getReporting-Endpoints: csp="…". A policy with its own endpoint, or one given as a string, is kept as it is.url_for('csp_reports')for each response, so it carries the prefix of an application mounted withMount.csp-reportofreport-uriand the array of the Reporting API, of which onlytype: csp-violationis used. It turns both into the body of a report of the Reporting API (documentURL,blockedURL,effectiveDirective,disposition, …), logs each violation withwarn, emits the hookcsp_report(c, report), and answers204. A body that is not a report gets400.max_report_size, 64 KiB by default; a larger body gets413.Validation
t/Pyjoyment/security_headers_lite_app.py, subtestReports:report-uriand its renamed fields; the reports ofreport-to, without the other types400for bodies that are not reports,404for GET,413over the limit/appt/docs/Pyjoyment_Plugin_SecurityHeaders.py: the examples ofreports,max_report_sizeand the hookcsp_reportPYTHONDEVMODE=1 python -m Pyjo.Prove -l -j 4 -r ton asyncio and onPyjo.Reactor.Poll: all tests passsphinx-build -Wpassestrunk check: no issues🤖 Generated with Claude Code