mirror of
https://0xacab.org/sutty/sutty
synced 2025-01-19 10:13:39 +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
|
class CspReportsController < BaseController
|
||||||
skip_forgery_protection
|
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
|
# Crea un reporte de CSP intercambiando los guiones medios por
|
||||||
# bajos
|
# bajos
|
||||||
#
|
#
|
||||||
# TODO: Aplicar rate_limit
|
# TODO: Aplicar rate_limit
|
||||||
def create
|
def create
|
||||||
csp = CspReport.new(csp_report_params.to_h.map do |k, v|
|
csp = CspReport.new(csp_report_params.to_h.transform_keys do |k|
|
||||||
[k.tr('-', '_'), v]
|
k.tr('-', '_')
|
||||||
end.to_h)
|
end)
|
||||||
|
|
||||||
csp.id = SecureRandom.uuid
|
csp.id = SecureRandom.uuid
|
||||||
csp.save
|
csp.save
|
||||||
|
|
||||||
render json: {}, status: :created
|
csp_report_created
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -39,6 +42,10 @@ module Api
|
||||||
:'column-number',
|
:'column-number',
|
||||||
:'source-file')
|
:'source-file')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def csp_report_created
|
||||||
|
render json: {}, status: :created
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue