aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.gradle2
-rw-r--r--gradle.properties2
-rw-r--r--server/sonar-telemetry/src/test/java/org/sonar/telemetry/TelemetryDaemonTest.java24
-rw-r--r--server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java51
4 files changed, 29 insertions, 50 deletions
diff --git a/build.gradle b/build.gradle
index 106008fef3a..237e9afccda 100644
--- a/build.gradle
+++ b/build.gradle
@@ -512,7 +512,7 @@ subprojects {
exclude 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
}
dependency 'com.sonarsource.pdfreport:security-report-pdf-generation:2.0.0.184'
- dependency 'org.sonarsource.update-center:sonar-update-center-common:1.34.0.2766'
+ dependency 'org.sonarsource.update-center:sonar-update-center-common:1.35.0.2835'
dependency 'org.sonarsource.classloader:sonar-classloader:1.1.0.1059'
dependency("org.springframework:spring-context:${springVersion}") {
exclude 'commons-logging:commons-logging'
diff --git a/gradle.properties b/gradle.properties
index d5c134a50b5..e7d79657e18 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -4,7 +4,7 @@ version=25.2
# 6 months from the release date for non LTA versions
# 30 months from the release date for LTA versions
# No change required for patch versions
-versionEOL=2026-07-01
+versionEOL=2025-07-01
pluginApiVersion=11.1.0.2693
description=Open source platform for continuous inspection of code quality
projectTitle=SonarQube
diff --git a/server/sonar-telemetry/src/test/java/org/sonar/telemetry/TelemetryDaemonTest.java b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/TelemetryDaemonTest.java
index c5b4044877f..816eaea18b7 100644
--- a/server/sonar-telemetry/src/test/java/org/sonar/telemetry/TelemetryDaemonTest.java
+++ b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/TelemetryDaemonTest.java
@@ -49,7 +49,6 @@ import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.after;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
@@ -113,29 +112,6 @@ class TelemetryDaemonTest {
}
@Test
- void start_shouldCheckIfDataSentPeriodically() throws IOException {
- initTelemetrySettingsToDefaultValues();
- when(lockManager.tryLock(any(), anyInt())).thenReturn(true);
- long now = system2.now();
- long twentyHoursAgo = now - (ONE_HOUR * 20L);
- long oneDayAgo = now - ONE_DAY;
- internalProperties.write("telemetry.lastPing", String.valueOf(twentyHoursAgo));
- settings.setProperty("sonar.telemetry.frequencyInSeconds", "1");
- when(dataLoader.load()).thenReturn(SOME_TELEMETRY_DATA);
- mockDataJsonWriterDoingSomething();
-
- underTest.start();
-
- verify(dataJsonWriter, after(2_000).never()).writeTelemetryData(any(JsonWriter.class), same(SOME_TELEMETRY_DATA));
- verify(client, never()).upload(anyString());
-
- internalProperties.write("telemetry.lastPing", String.valueOf(oneDayAgo));
-
- verify(client, timeout(2_000)).upload(anyString());
- verify(dataJsonWriter).writeTelemetryData(any(JsonWriter.class), same(SOME_TELEMETRY_DATA));
- }
-
- @Test
void start_whenLastPingEarlierThanOneDayAgo_shouldNotSendData() throws IOException {
initTelemetrySettingsToDefaultValues();
when(lockManager.tryLock(any(), anyInt())).thenReturn(true);
diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
index bd38aeb5aa4..d20f6b1ce23 100644
--- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
+++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/ServerUserSession.java
@@ -47,6 +47,7 @@ import org.sonar.db.user.UserDto;
import static java.util.Collections.singleton;
import static java.util.Optional.of;
import static java.util.Optional.ofNullable;
+import static java.util.stream.Collectors.toMap;
import static java.util.stream.Collectors.toSet;
import static org.sonar.api.web.UserRole.PUBLIC_PERMISSIONS;
import static org.sonar.db.component.ComponentQualifiers.SUBVIEW;
@@ -230,8 +231,8 @@ public class ServerUserSession extends AbstractUserSession {
return branchDto.map(BranchDto::getProjectUuid).orElseThrow(() -> new IllegalStateException("No branch found for component : " + componentDto));
}
- private Set<String> getProjectUuids(DbSession dbSession, Collection<ComponentDto> components) {
- Set<String> mainProjectUuids = new HashSet<>();
+ private Map<String, String> getEntityUuidsByComponentUuid(DbSession dbSession, Collection<ComponentDto> components) {
+ Map<String, String> entityUuidsByComponentUuid = new HashMap<>();
// the result of following stream could be project or application
Collection<String> componentsWithBranch = components.stream()
@@ -239,15 +240,22 @@ public class ServerUserSession extends AbstractUserSession {
.map(ComponentDto::branchUuid)
.toList();
- dbClient.branchDao().selectByUuids(dbSession, componentsWithBranch).stream()
- .map(BranchDto::getProjectUuid).forEach(mainProjectUuids::add);
+ Map<String, BranchDto> branchDtos = dbClient.branchDao().selectByUuids(dbSession, componentsWithBranch).stream()
+ .collect(toMap(BranchDto::getUuid, b -> b));
+ components.stream()
+ .filter(c -> !(isTechnicalProject(c) || isPortfolioOrSubPortfolio(c)))
+ .forEach(c -> {
+ BranchDto branchDto = branchDtos.get(c.branchUuid());
+ if (branchDto != null) {
+ entityUuidsByComponentUuid.put(c.uuid(), branchDto.getProjectUuid());
+ }
+ });
components.stream()
.filter(c -> isTechnicalProject(c) || isPortfolioOrSubPortfolio(c))
- .map(ComponentDto::branchUuid)
- .forEach(mainProjectUuids::add);
+ .forEach(c -> entityUuidsByComponentUuid.put(c.uuid(), c.branchUuid()));
- return mainProjectUuids;
+ return entityUuidsByComponentUuid;
}
private static boolean isTechnicalProject(ComponentDto componentDto) {
@@ -324,27 +332,22 @@ public class ServerUserSession extends AbstractUserSession {
@Override
protected List<ComponentDto> doKeepAuthorizedComponents(String permission, Collection<ComponentDto> components) {
try (DbSession dbSession = dbClient.openSession(false)) {
- Set<String> projectUuids = getProjectUuids(dbSession, components);
-
- Map<String, ComponentDto> originalComponents = findComponentsByCopyComponentUuid(components,
- dbSession);
+ Map<String, String> entityUuidsByComponentUuid = new HashMap<>(getEntityUuidsByComponentUuid(dbSession, components));
+ Map<String, ComponentDto> originalComponents = findComponentsByCopyComponentUuid(components, dbSession);
+ entityUuidsByComponentUuid.putAll(getEntityUuidsByComponentUuid(dbSession, originalComponents.values()));
- Set<String> originalComponentsProjectUuids = getProjectUuids(dbSession, originalComponents.values());
-
- Set<String> allProjectUuids = new HashSet<>(projectUuids);
- allProjectUuids.addAll(originalComponentsProjectUuids);
-
- Set<String> authorizedProjectUuids = keepAuthorizedProjectsUuids(dbSession, permission, allProjectUuids);
+ Set<String> authorizedEntityUuids = keepAuthorizedProjectsUuids(dbSession, permission, entityUuidsByComponentUuid.values());
return components.stream()
.filter(c -> {
if (c.getCopyComponentUuid() != null) {
- var componentDto = originalComponents.get(c.getCopyComponentUuid());
- return componentDto != null && authorizedProjectUuids.contains(getEntityUuid(dbSession, componentDto));
+ c = originalComponents.get(c.getCopyComponentUuid());
+ if (c == null) {
+ return false;
+ }
}
-
- return authorizedProjectUuids.contains(c.branchUuid()) || authorizedProjectUuids.contains(
- getEntityUuid(dbSession, c));
+ String entityUuid = entityUuidsByComponentUuid.get(c.uuid());
+ return entityUuid != null && authorizedEntityUuids.contains(entityUuid);
})
.toList();
}
@@ -355,11 +358,11 @@ public class ServerUserSession extends AbstractUserSession {
}
private Map<String, ComponentDto> findComponentsByCopyComponentUuid(Collection<ComponentDto> components, DbSession dbSession) {
- Set<String> copyComponentsUuid = components.stream()
+ Set<String> copyComponentsUuids = components.stream()
.map(ComponentDto::getCopyComponentUuid)
.filter(Objects::nonNull)
.collect(toSet());
- return dbClient.componentDao().selectByUuids(dbSession, copyComponentsUuid).stream()
+ return dbClient.componentDao().selectByUuids(dbSession, copyComponentsUuids).stream()
.collect(Collectors.toMap(ComponentDto::uuid, componentDto -> componentDto));
}