aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver/src
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2024-04-15 11:12:52 +0200
committersonartech <sonartech@sonarsource.com>2024-04-15 20:02:44 +0000
commit6055f0479310bd81bb548ba53a2ef111e1847a74 (patch)
tree9bb626648301d68ab3a998e3a5fda0c7cb4432c5 /server/sonar-webserver/src
parentbc04c220c0c81f240149e2ee6c5af7fff6fb6f54 (diff)
downloadsonarqube-6055f0479310bd81bb548ba53a2ef111e1847a74.tar.gz
sonarqube-6055f0479310bd81bb548ba53a2ef111e1847a74.zip
SONAR-21973 Update CSP with font-src to accept data: fonts
Diffstat (limited to 'server/sonar-webserver/src')
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/platform/web/CspFilter.java5
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/CspFilterTest.java1
2 files changed, 4 insertions, 2 deletions
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/CspFilter.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/CspFilter.java
index b10f4be7abc..822ae962a46 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/CspFilter.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/CspFilter.java
@@ -31,7 +31,7 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
public class CspFilter implements Filter {
-
+
private final List<String> cspHeaders = new ArrayList<>();
private String policies = null;
@@ -40,11 +40,12 @@ public class CspFilter implements Filter {
cspHeaders.add("Content-Security-Policy");
cspHeaders.add("X-Content-Security-Policy");
cspHeaders.add("X-WebKit-CSP");
-
+
List<String> cspPolicies = new ArrayList<>();
cspPolicies.add("default-src 'self'");
cspPolicies.add("base-uri 'none'");
cspPolicies.add("connect-src 'self' http: https:");
+ cspPolicies.add("font-src 'self' data:");
cspPolicies.add("img-src * data: blob:");
cspPolicies.add("object-src 'none'");
cspPolicies.add("script-src 'self'");
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/CspFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/CspFilterTest.java
index d895fa75ef9..b021d79b96d 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/CspFilterTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/CspFilterTest.java
@@ -39,6 +39,7 @@ public class CspFilterTest {
private static final String EXPECTED = "default-src 'self'; " +
"base-uri 'none'; " +
"connect-src 'self' http: https:; " +
+ "font-src 'self' data:; " +
"img-src * data: blob:; " +
"object-src 'none'; " +
"script-src 'self'; " +