mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-15 21:51:43 +00:00
Merge branch 'csp-reports' into 'rails'
no generar errores si se envía el reporte incompleto Closes #5136 See merge request sutty/sutty!92
This commit is contained in:
commit
d869b99baa
1 changed files with 11 additions and 4 deletions
|
@ -6,19 +6,22 @@ module Api
|
|||
class CspReportsController < BaseController
|
||||
skip_forgery_protection
|
||||
|
||||
# No queremos indicar que algo salió mal
|
||||
rescue_from ActionController::ParameterMissing, with: :csp_report_created
|
||||
|
||||
# Crea un reporte de CSP intercambiando los guiones medios por
|
||||
# bajos
|
||||
#
|
||||
# TODO: Aplicar rate_limit
|
||||
def create
|
||||
csp = CspReport.new(csp_report_params.to_h.map do |k, v|
|
||||
[k.tr('-', '_'), v]
|
||||
end.to_h)
|
||||
csp = CspReport.new(csp_report_params.to_h.transform_keys do |k|
|
||||
k.tr('-', '_')
|
||||
end)
|
||||
|
||||
csp.id = SecureRandom.uuid
|
||||
csp.save
|
||||
|
||||
render json: {}, status: :created
|
||||
csp_report_created
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -39,6 +42,10 @@ module Api
|
|||
:'column-number',
|
||||
:'source-file')
|
||||
end
|
||||
|
||||
def csp_report_created
|
||||
render json: {}, status: :created
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue