Class: CspViolationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/rockstart/security/templates/csp_violations_controller.rb

Overview

Handle violations from the Content Security Policy

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/rockstart/security/templates/csp_violations_controller.rb', line 7

def create
  report_base = JSON.parse(request.body.read)
  if report_base.key? "csp-report"
    report = report_base["csp-report"]
    message = build_content_security_message(report)

    # Post message using Lograge formatter
    Rails.logger.error(message.to_json)
  end
  head :ok
end