From 4973c9014b571dd7f49b834907906e21c17f08a0 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Mon, 18 Sep 2023 02:16:36 +0000 Subject: [PATCH] Set a strict CSP policy for downloaded attachments, thumbnails, and raw repository files(#38417). Patch by Holger Just. git-svn-id: https://svn.redmine.org/redmine/trunk@22295 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/attachments_controller.rb | 5 +++++ app/controllers/repositories_controller.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 06a236c2c..414ecfde0 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -321,4 +321,9 @@ class AttachmentsController < ApplicationController request.raw_post end end + + def send_file(path, options={}) + headers['content-security-policy'] = "default-src 'none'; style-src 'unsafe-inline'; sandbox" + super + end end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8ecb0022f..3fb69e8b2 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -431,6 +431,11 @@ class RepositoriesController < ApplicationController end end + def send_file(path, options={}) + headers['content-security-policy'] = "default-src 'none'; style-src 'unsafe-inline'; sandbox" + super + end + def valid_name?(rev) return true if rev.nil? return true if REV_PARAM_RE.match?(rev) -- 2.39.5