import java.io.IOException;
import java.util.Set;
import org.sonar.api.config.Configuration;
+import org.sonar.api.impl.ws.StaticResources;
import org.sonar.api.server.http.HttpRequest;
import org.sonar.api.server.http.HttpResponse;
import org.sonar.api.web.FilterChain;
import org.sonar.api.web.UrlPattern;
import org.sonar.server.user.ThreadLocalUserSession;
-import static org.sonar.api.web.UrlPattern.Builder.staticResourcePatterns;
import static org.sonar.server.authentication.AuthenticationRedirection.redirectTo;
public class DefaultAdminCredentialsVerifierFilter extends HttpFilter {
public UrlPattern doGetPattern() {
return UrlPattern.builder()
.includes("/*")
- .excludes(staticResourcePatterns())
+ .excludes(StaticResources.patterns())
.excludes(SKIPPED_URLS)
.build();
}
import java.io.IOException;
import java.util.Set;
+import org.sonar.api.impl.ws.StaticResources;
import org.sonar.api.server.http.HttpRequest;
import org.sonar.api.server.http.HttpResponse;
import org.sonar.api.web.FilterChain;
import org.sonar.api.web.UrlPattern;
import org.sonar.server.user.ThreadLocalUserSession;
-import static org.sonar.api.web.UrlPattern.Builder.staticResourcePatterns;
import static org.sonar.server.authentication.AuthenticationRedirection.redirectTo;
public class ResetPasswordFilter extends HttpFilter {
public UrlPattern doGetPattern() {
return UrlPattern.builder()
.includes("/*")
- .excludes(staticResourcePatterns())
+ .excludes(StaticResources.patterns())
.excludes(SKIPPED_URLS)
.build();
}
import java.util.Optional;
import java.util.Set;
import org.sonar.api.config.Configuration;
+import org.sonar.api.impl.ws.StaticResources;
import org.sonar.api.server.ServerSide;
import org.sonar.api.server.http.HttpRequest;
import org.sonar.api.server.http.HttpResponse;
import static org.sonar.api.CoreProperties.CORE_FORCE_AUTHENTICATION_DEFAULT_VALUE;
import static org.sonar.api.CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY;
import static org.sonar.api.utils.DateUtils.formatDateTime;
-import static org.sonar.api.web.UrlPattern.Builder.staticResourcePatterns;
import static org.sonar.server.authentication.AuthenticationError.handleAuthenticationError;
@ServerSide
private static final UrlPattern URL_PATTERN = UrlPattern.builder()
.includes("/*")
- .excludes(staticResourcePatterns())
+ .excludes(StaticResources.patterns())
.excludes(SKIPPED_URLS)
.build();
.includes(URL_USING_PASSCODE)
.build();
-
private final Configuration config;
private final ThreadLocalUserSession threadLocalSession;
private final AuthenticationEvent authenticationEvent;
import java.io.IOException;
import java.util.Set;
import org.sonar.api.config.Configuration;
+import org.sonar.api.impl.ws.StaticResources;
import org.sonar.api.server.http.HttpRequest;
import org.sonar.api.server.http.HttpResponse;
import org.sonar.api.web.FilterChain;
import org.sonar.core.extension.PluginRiskConsent;
import org.sonar.server.user.ThreadLocalUserSession;
-import static org.sonar.api.web.UrlPattern.Builder.staticResourcePatterns;
import static org.sonar.core.config.CorePropertyDefinitions.PLUGINS_RISK_CONSENT;
import static org.sonar.core.extension.PluginRiskConsent.NOT_ACCEPTED;
import static org.sonar.core.extension.PluginRiskConsent.REQUIRED;
public UrlPattern doGetPattern() {
return UrlPattern.builder()
.includes("/*")
- .excludes(staticResourcePatterns())
+ .excludes(StaticResources.patterns())
.excludes(SKIPPED_URLS)
.build();
}
import static java.util.Locale.ENGLISH;
import static java.util.Objects.requireNonNull;
import static org.apache.commons.io.IOUtils.write;
-import static org.sonar.api.web.ServletFilter.UrlPattern.Builder.staticResourcePatterns;
+import static org.sonar.api.impl.ws.StaticResources.patterns;
import static org.sonarqube.ws.MediaTypes.HTML;
/**
private static final ServletFilter.UrlPattern URL_PATTERN = ServletFilter.UrlPattern
.builder()
- .excludes(staticResourcePatterns())
+ .excludes(patterns())
.excludes("/api/v2/*")
.build();
this(PlatformImpl.getInstance().getContainer().getComponentByType(WebPagesCache.class));
}
- @VisibleForTesting
- WebPagesFilter(WebPagesCache webPagesCache) {
+ @VisibleForTesting WebPagesFilter(WebPagesCache webPagesCache) {
this.webPagesCache = webPagesCache;
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.api.impl.ws;
+
+import java.util.Collection;
+import java.util.List;
+
+public class StaticResources {
+ private static final Collection<String> STATIC_RESOURCES = List.of("*.css", "*.css.map", "*.ico", "*.png",
+ "*.jpg", "*.jpeg", "*.gif", "*.svg", "*.js", "*.js.map", "*.pdf", "/json/*", "*.woff2", "/static/*",
+ "/robots.txt", "/favicon.ico", "/apple-touch-icon*", "/mstile*");
+
+ private StaticResources() {
+ // only static
+ }
+
+ public static Collection<String> patterns() {
+ return STATIC_RESOURCES;
+ }
+}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.api.impl.ws;
+
+import org.junit.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class StaticResourcesTest {
+ @Test
+ public void patterns_shouldNotBeEmpty() {
+ assertThat(StaticResources.patterns()).isNotEmpty();
+ }
+}
\ No newline at end of file