Class: Brut::FrontEnd::Handlers::CspReportingHandler
- Inherits:
-
Brut::FrontEnd::Handler
- Object
- Brut::FrontEnd::Handler
- Brut::FrontEnd::Handlers::CspReportingHandler
- Defined in:
- lib/brut/front_end/handlers/csp_reporting_handler.rb
Overview
Receives content security policy violations and logs them. This is set up in Brut::Framework::MCP, however CSP reporting is configured in RouteHooks::CSPNoInlineStylesOrScripts::ReportOnly.
Instance Method Summary collapse
-
#handle ⇒ Object
-
#initialize(body:) ⇒ CspReportingHandler
constructor
A new instance of CspReportingHandler.
Methods inherited from Brut::FrontEnd::Handler
Methods included from Brut::Framework::Errors
Methods included from Brut::FrontEnd::HandlingResults
Constructor Details
#initialize(body:) ⇒ CspReportingHandler
Returns a new instance of CspReportingHandler.
4 5 6 |
# File 'lib/brut/front_end/handlers/csp_reporting_handler.rb', line 4 def initialize(body:) @body = body end |
Instance Method Details
#handle ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/brut/front_end/handlers/csp_reporting_handler.rb', line 7 def handle begin parsed = JSON.parse(@body.read) Brut.container.instrumentation.add_attributes(parsed.merge(prefix: "brut.csp-reporting")) rescue => ex Brut.container.instrumentation.record_exception(ex) end http_status(200) end |