private LogLevelConfig createLogLevelConfiguration(ProcessId processId) {
LogLevelConfig.Builder builder = LogLevelConfig.newBuilder();
builder.rootLevelFor(processId);
- builder.immutableLevel("rails", Level.WARN);
builder.immutableLevel("org.apache.ibatis", Level.WARN);
builder.immutableLevel("java.sql", Level.WARN);
builder.immutableLevel("java.sql.ResultSet", Level.WARN);
private static final Set<String> UPDATE_METHODS = ImmutableSet.of("POST", "PUT", "DELETE");
private static final String API_URL = "/api";
- private static final Set<String> RAILS_UPDATE_API_URLS = ImmutableSet.of("/api/projects/create", "/api/user_properties");
public String generateState(HttpServletRequest request, HttpServletResponse response, int timeoutInSeconds) {
// Create a state token to prevent request forgery.
private static boolean shouldRequestBeChecked(HttpServletRequest request) {
if (UPDATE_METHODS.contains(request.getMethod())) {
String path = request.getRequestURI().replaceFirst(request.getContextPath(), "");
- return path.startsWith(API_URL)
- && !isRailsWsUrl(path);
+ return path.startsWith(API_URL);
}
return false;
}
- private static boolean isRailsWsUrl(String uri) {
- return RAILS_UPDATE_API_URLS.stream().filter(uri::startsWith).findFirst().isPresent();
- }
-
}
// SONAR-6546 these urls should be get from WebService
private static final Set<String> SKIPPED_URLS = ImmutableSet.of(
"/batch/index", "/batch/file",
- "/maintenance/*",
- "/setup/*",
+ "/maintenance/*", "/setup/*",
"/sessions/*", "/oauth2/callback/*",
"/api/system/db_migration_status", "/api/system/status", "/api/system/migrate_db",
"/api/server/version",
handleAuthenticationError(e, response, request.getContextPath());
return false;
}
- // Rails will redirect to login page
+ // Web pages should redirect to the index.html file
return true;
}
}
throw new NotFoundException("Unknown quality profile exporter: " + exporterKey);
}
- /**
- * Used by rails
- */
- public List<ProfileImporter> findProfileImportersForLanguage(String language) {
- List<ProfileImporter> result = new ArrayList<>();
- for (ProfileImporter importer : importers) {
- if (importer.getSupportedLanguages() == null || importer.getSupportedLanguages().length == 0 || ArrayUtils.contains(importer.getSupportedLanguages(), language)) {
- result.add(importer);
- }
- }
- return result;
- }
-
public QProfileResult importXml(QualityProfileDto profileDto, String importerKey, InputStream xml, DbSession dbSession) {
return importXml(profileDto, importerKey, new InputStreamReader(xml, StandardCharsets.UTF_8), dbSession);
}
- public QProfileResult importXml(QualityProfileDto profileDto, String importerKey, Reader xml, DbSession dbSession) {
+ private QProfileResult importXml(QualityProfileDto profileDto, String importerKey, Reader xml, DbSession dbSession) {
QProfileResult result = new QProfileResult();
ValidationMessages messages = ValidationMessages.create();
ProfileImporter importer = getProfileImporter(importerKey);
}
private void verifyImmutableLogLevels(LoggerContext ctx) {
- assertThat(ctx.getLogger("rails").getLevel()).isEqualTo(Level.WARN);
assertThat(ctx.getLogger("org.apache.ibatis").getLevel()).isEqualTo(Level.WARN);
assertThat(ctx.getLogger("java.sql").getLevel()).isEqualTo(Level.WARN);
assertThat(ctx.getLogger("java.sql.ResultSet").getLevel()).isEqualTo(Level.WARN);
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
-import org.sonar.process.logging.LogbackHelper;
import org.sonar.process.ProcessProperties;
import org.sonar.process.Props;
+import org.sonar.process.logging.LogbackHelper;
import static org.assertj.core.api.Assertions.assertThat;
import static org.slf4j.Logger.ROOT_LOGGER_NAME;
}
private void verifyImmutableLogLevels(LoggerContext ctx) {
- assertThat(ctx.getLogger("rails").getLevel()).isEqualTo(Level.WARN);
assertThat(ctx.getLogger("org.apache.ibatis").getLevel()).isEqualTo(Level.WARN);
assertThat(ctx.getLogger("java.sql").getLevel()).isEqualTo(Level.WARN);
assertThat(ctx.getLogger("java.sql.ResultSet").getLevel()).isEqualTo(Level.WARN);
underTest.verifyState(request, null, LOGIN);
}
- @Test
- public void ignore_rails_ws_requests() throws Exception {
- executeVerifyStateDoesNotFailOnRequest("/api/projects/create?key=ABCD", "POST");
- executeVerifyStateDoesNotFailOnRequest("/api/user_properties", "POST");
- }
-
@Test
public void ignore_not_api_requests() throws Exception {
executeVerifyStateDoesNotFailOnRequest("/events", "POST");
assertPathIsIgnored("/setup/index");
assertPathIsIgnored("/sessions/new");
assertPathIsIgnored("/sessions/logout");
+ assertPathIsIgnored("/sessions/unauthorized");
assertPathIsIgnored("/oauth2/callback/github");
assertPathIsIgnored("/oauth2/callback/foo");
assertPathIsIgnored("/api/system/db_migration_status");
assertThat(exporters.mimeType("standard")).isEqualTo("text/plain");
}
- @Test
- public void profile_importers_for_language() {
- assertThat(exporters.findProfileImportersForLanguage("xoo")).hasSize(3);
- }
-
@Test
public void import_xml() {
QualityProfileDto profileDto = QProfileTesting.newQProfileDto(QProfileName.createFor("xoo", "import_xml"), "import_xml");