From 1b716d07eae31eb4cd97d4ecd8d44cf6ae28df2b Mon Sep 17 00:00:00 2001 From: Matteo Mara Date: Wed, 18 Oct 2023 15:26:00 +0200 Subject: [PATCH] SONAR-20579 Allow to fetch GitLab SAST report with analysis tokens --- .../java/org/sonar/server/issue/index/IssueQueryFactory.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java index 5386e7c302c..27562572a1a 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java @@ -53,6 +53,7 @@ import org.sonar.db.DbSession; import org.sonar.db.component.BranchDto; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.SnapshotDto; +import org.sonar.db.permission.GlobalPermission; import org.sonar.db.rule.RuleDto; import org.sonar.server.issue.SearchRequest; import org.sonar.server.issue.index.IssueQuery.PeriodStart; @@ -71,6 +72,7 @@ import static org.sonar.api.measures.CoreMetrics.ANALYSIS_FROM_SONARQUBE_9_4_KEY import static org.sonar.api.utils.DateUtils.longToDate; import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime; import static org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime; +import static org.sonar.api.web.UserRole.SCAN; import static org.sonar.api.web.UserRole.USER; import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH; import static org.sonarqube.ws.client.issue.IssuesWsParameters.PARAM_COMPONENTS; @@ -357,7 +359,7 @@ public class IssueQueryFactory { private void addViewsOrSubViews(IssueQuery.Builder builder, Collection viewOrSubViewUuids) { List filteredViewUuids = viewOrSubViewUuids.stream() - .filter(uuid -> userSession.hasComponentPermission(USER, uuid)) + .filter(uuid -> (userSession.hasComponentPermission(USER, uuid) || userSession.hasComponentPermission(SCAN, uuid) || userSession.hasPermission(GlobalPermission.SCAN))) .map(ComponentDto::uuid) .collect(Collectors.toCollection(ArrayList::new)); if (filteredViewUuids.isEmpty()) { -- 2.39.5