Skip to content

Commit 75b2380

Browse files
SLCORE-1525 Rename SCA issues to dependency risks
1 parent 4678d69 commit 75b2380

File tree

37 files changed

+673
-745
lines changed

37 files changed

+673
-745
lines changed

API_CHANGES.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
# 10.27
22

3+
## Breaking changes
4+
5+
* Merge `org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.DependencyRiskTrackingRpcService` into `org.sonarsource.sonarlint.core.rpc.protocol.backend.sca.DependencyRiskRpcService`.
6+
* Rename `org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcClient.didChangeScaIssues` to `org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcClient.didChangeDependencyRisks`.
7+
38
## New features
49

5-
* Allow changing status of SCA issues via `org.sonarsource.sonarlint.core.rpc.protocol.backend.sca.ScaRpcService.changeStatus`.
6-
* Required parameters are `configScopeId`, `issueId` and `transition`.
10+
* Allow changing status of dependency risks (SCA issues) via `org.sonarsource.sonarlint.core.rpc.protocol.backend.sca.DependencyRiskRpcService.changeStatus`.
11+
* Required parameters are `configScopeId`, `dependencyRiskKey` and `transition`.
712
* If transition is `ACCEPT`, `FIXED`, or `SAFE`, a `comment` field is mandatory
8-
* Allow clients to open dependency risk (SCA issues) in browser
9-
* Introduce `org.sonarsource.sonarlint.core.rpc.protocol.backend.sca.ScaRpcService.openDependencyRiskInBrowser` that accepts `configScopeId` and `dependencyRiskKey` (UUID) parameters
10-
* Allow clients to record interactions with dependency risks (SCA issues) in telemetry
13+
* Allow clients to open dependency risk in browser
14+
* Introduce `org.sonarsource.sonarlint.core.rpc.protocol.backend.sca.DependencyRiskRpcService.openDependencyRiskInBrowser` that accepts `configScopeId` and `dependencyRiskKey` (UUID) parameters
15+
* Allow clients to record interactions with dependency risks in telemetry
1116
* Introduce `org.sonarsource.sonarlint.core.rpc.protocol.backend.telemetry.TelemetryRpcService.dependencyRiskInvestigatedLocally` method
12-
* Add a new `org.sonarsource.sonarlint.core.rpc.protocol.backend.sca.ScaRpcService.getDependencyRiskDetails`.
17+
* Add a new `org.sonarsource.sonarlint.core.rpc.protocol.backend.sca.DependencyRiskRpcService.getDependencyRiskDetails`.
1318

1419
# 10.26
1520

1621
## New features
1722

1823
* Add a new `SCA_SYNCHRONIZATION` value in `org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.BackendCapability`. Clients using the feature need to declare it at initialization time.
1924
* Introduce a new `org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.ScaIssueTrackingRpcService` service and a `listAll` method
25+
* Introduce a new `org.sonarsource.sonarlint.core.rpc.protocol.SonarLintRpcClient.didChangeScaIssues` notification.
2026

2127
# 10.25
2228

backend/core/src/main/java/org/sonarsource/sonarlint/core/event/ScaIssuesSynchronizedEvent.java renamed to backend/core/src/main/java/org/sonarsource/sonarlint/core/event/DependencyRisksSynchronizedEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
*/
2020
package org.sonarsource.sonarlint.core.event;
2121

22-
import org.sonarsource.sonarlint.core.serverconnection.issues.ServerScaIssue;
22+
import org.sonarsource.sonarlint.core.serverconnection.issues.ServerDependencyRisk;
2323
import org.sonarsource.sonarlint.core.serverconnection.storage.UpdateSummary;
2424

25-
public record ScaIssuesSynchronizedEvent(String connectionId, String sonarProjectKey, String sonarBranch, UpdateSummary<ServerScaIssue> summary) {
25+
public record DependencyRisksSynchronizedEvent(String connectionId, String sonarProjectKey, String sonarBranch, UpdateSummary<ServerDependencyRisk> summary) {
2626
}

backend/core/src/main/java/org/sonarsource/sonarlint/core/sca/ScaService.java renamed to backend/core/src/main/java/org/sonarsource/sonarlint/core/sca/DependencyRiskService.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@
3434
import org.sonarsource.sonarlint.core.rpc.protocol.backend.sca.DependencyRiskTransition;
3535
import org.sonarsource.sonarlint.core.rpc.protocol.backend.sca.GetDependencyRiskDetailsResponse;
3636
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.AffectedPackageDto;
37-
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.ScaIssueDto;
37+
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.DependencyRiskDto;
3838
import org.sonarsource.sonarlint.core.rpc.protocol.client.OpenUrlInBrowserParams;
3939
import org.sonarsource.sonarlint.core.serverapi.EndpointParams;
4040
import org.sonarsource.sonarlint.core.serverapi.ServerApiHelper;
4141
import org.sonarsource.sonarlint.core.serverapi.UrlUtils;
4242
import org.sonarsource.sonarlint.core.serverapi.sca.GetIssueReleaseResponse;
43-
import org.sonarsource.sonarlint.core.serverconnection.issues.ServerScaIssue;
43+
import org.sonarsource.sonarlint.core.serverconnection.issues.ServerDependencyRisk;
4444
import org.sonarsource.sonarlint.core.storage.StorageService;
4545
import org.sonarsource.sonarlint.core.telemetry.TelemetryService;
4646

47-
public class ScaService {
47+
public class DependencyRiskService {
4848
private static final SonarLintLogger LOG = SonarLintLogger.get();
4949

5050
private final ConfigurationRepository configurationRepository;
@@ -55,7 +55,7 @@ public class ScaService {
5555
private final SonarLintRpcClient client;
5656
private final TelemetryService telemetryService;
5757

58-
public ScaService(ConfigurationRepository configurationRepository, ConnectionConfigurationRepository connectionRepository, StorageService storageService,
58+
public DependencyRiskService(ConfigurationRepository configurationRepository, ConnectionConfigurationRepository connectionRepository, StorageService storageService,
5959
SonarQubeClientManager sonarQubeClientManager, SonarProjectBranchTrackingService branchTrackingService, SonarLintRpcClient client, TelemetryService telemetryService) {
6060
this.configurationRepository = configurationRepository;
6161
this.connectionRepository = connectionRepository;
@@ -66,7 +66,7 @@ public ScaService(ConfigurationRepository configurationRepository, ConnectionCon
6666
this.telemetryService = telemetryService;
6767
}
6868

69-
public void changeStatus(String configurationScopeId, UUID issueReleaseKey, DependencyRiskTransition transition, @CheckForNull String comment,
69+
public void changeStatus(String configurationScopeId, UUID dependencyRiskKey, DependencyRiskTransition transition, @CheckForNull String comment,
7070
SonarLintCancelMonitor cancelMonitor) {
7171
var binding = configurationRepository.getEffectiveBindingOrThrow(configurationScopeId);
7272
var serverConnection = sonarQubeClientManager.getClientOrThrow(binding.connectionId());
@@ -77,27 +77,27 @@ public void changeStatus(String configurationScopeId, UUID issueReleaseKey, Depe
7777
throw new IllegalArgumentException("Could not determine matched branch for configuration scope " + configurationScopeId);
7878
}
7979

80-
var scaIssues = projectServerIssueStore.loadScaIssues(branchName.get());
81-
var dependencyRiskOpt = scaIssues.stream().filter(issue -> issue.key().equals(issueReleaseKey)).findFirst();
80+
var dependencyRisks = projectServerIssueStore.loadDependencyRisks(branchName.get());
81+
var dependencyRiskOpt = dependencyRisks.stream().filter(risk -> risk.key().equals(dependencyRiskKey)).findFirst();
8282

8383
if (dependencyRiskOpt.isEmpty()) {
84-
throw new ScaIssueNotFoundException("Dependency Risk with key " + issueReleaseKey.toString() + " was not found", issueReleaseKey.toString());
84+
throw new DependencyRiskNotFoundException("Dependency Risk with key " + dependencyRiskKey + " was not found", dependencyRiskKey.toString());
8585
}
8686

8787
var dependencyRisk = dependencyRiskOpt.get();
8888

8989
if (!dependencyRisk.transitions().contains(adaptTransition(transition))) {
90-
throw new IllegalArgumentException("Transition " + transition + " is not allowed for this SCA issue");
90+
throw new IllegalArgumentException("Transition " + transition + " is not allowed for this dependency risk");
9191
}
9292

9393
if ((transition == DependencyRiskTransition.ACCEPT || transition == DependencyRiskTransition.SAFE || transition == DependencyRiskTransition.FIXED)
9494
&& (comment == null || comment.isBlank())) {
9595
throw new IllegalArgumentException("Comment is required for ACCEPT, FIXED, and SAFE transitions");
9696
}
9797

98-
LOG.info("Changing SCA issue status for issue {} to {} with comment: {}", issueReleaseKey, transition, comment);
98+
LOG.info("Changing status for dependency risk {} to {} with comment: {}", dependencyRiskKey, transition, comment);
9999

100-
serverConnection.withClientApi(serverApi -> serverApi.sca().changeStatus(issueReleaseKey, transition.name(), comment, cancelMonitor));
100+
serverConnection.withClientApi(serverApi -> serverApi.sca().changeStatus(dependencyRiskKey, transition.name(), comment, cancelMonitor));
101101
}
102102

103103
public GetDependencyRiskDetailsResponse getDependencyRiskDetails(String configurationScopeId, String dependencyRiskKey, SonarLintCancelMonitor cancelMonitor) {
@@ -117,13 +117,13 @@ public GetDependencyRiskDetailsResponse getDependencyRiskDetails(String configur
117117
return convertToRpcResponse(serverResponse);
118118
}
119119

120-
private static ServerScaIssue.Transition adaptTransition(DependencyRiskTransition transition) {
120+
private static ServerDependencyRisk.Transition adaptTransition(DependencyRiskTransition transition) {
121121
return switch (transition) {
122-
case REOPEN -> ServerScaIssue.Transition.REOPEN;
123-
case CONFIRM -> ServerScaIssue.Transition.CONFIRM;
124-
case ACCEPT -> ServerScaIssue.Transition.ACCEPT;
125-
case SAFE -> ServerScaIssue.Transition.SAFE;
126-
case FIXED -> ServerScaIssue.Transition.FIXED;
122+
case REOPEN -> ServerDependencyRisk.Transition.REOPEN;
123+
case CONFIRM -> ServerDependencyRisk.Transition.CONFIRM;
124+
case ACCEPT -> ServerDependencyRisk.Transition.ACCEPT;
125+
case SAFE -> ServerDependencyRisk.Transition.SAFE;
126+
case FIXED -> ServerDependencyRisk.Transition.FIXED;
127127
};
128128
}
129129

@@ -147,8 +147,8 @@ private static GetDependencyRiskDetailsResponse convertToRpcResponse(GetIssueRel
147147
.build())
148148
.toList();
149149

150-
return new GetDependencyRiskDetailsResponse(serverResponse.key(), ScaIssueDto.Severity.valueOf(serverResponse.severity().name()), serverResponse.release().packageName(),
151-
serverResponse.release().version(), ScaIssueDto.Type.valueOf(serverResponse.type().name()), serverResponse.vulnerability().vulnerabilityId(),
150+
return new GetDependencyRiskDetailsResponse(serverResponse.key(), DependencyRiskDto.Severity.valueOf(serverResponse.severity().name()), serverResponse.release().packageName(),
151+
serverResponse.release().version(), DependencyRiskDto.Type.valueOf(serverResponse.type().name()), serverResponse.vulnerability().vulnerabilityId(),
152152
serverResponse.vulnerability().description(), affectedPackages);
153153
}
154154

@@ -163,14 +163,14 @@ public void openDependencyRiskInBrowser(String configurationScopeId, UUID depend
163163
throw new IllegalArgumentException(String.format("Configuration scope %s has no matching branch, unable to open dependency risk", configurationScopeId));
164164
}
165165

166-
var url = buildScaBrowseUrl(effectiveBinding.get().sonarProjectKey(), branchName.get(), dependencyKey, endpointParams.get());
166+
var url = buildDependencyRiskBrowseUrl(effectiveBinding.get().sonarProjectKey(), branchName.get(), dependencyKey, endpointParams.get());
167167

168168
client.openUrlInBrowser(new OpenUrlInBrowserParams(url));
169169

170170
telemetryService.dependencyRiskInvestigatedRemotely();
171171
}
172172

173-
static String buildScaBrowseUrl(String projectKey, String branch, UUID dependencyKey, EndpointParams endpointParams) {
173+
static String buildDependencyRiskBrowseUrl(String projectKey, String branch, UUID dependencyKey, EndpointParams endpointParams) {
174174
var relativePath = new StringBuilder("/dependency-risks/")
175175
.append(UrlUtils.urlEncode(dependencyKey.toString()))
176176
.append("/what?id=")
@@ -182,16 +182,16 @@ static String buildScaBrowseUrl(String projectKey, String branch, UUID dependenc
182182
return ServerApiHelper.concat(endpointParams.getBaseUrl(), relativePath);
183183
}
184184

185-
public static class ScaIssueNotFoundException extends RuntimeException {
186-
private final String issueKey;
185+
public static class DependencyRiskNotFoundException extends RuntimeException {
186+
private final String key;
187187

188-
public ScaIssueNotFoundException(String message, String issueKey) {
188+
public DependencyRiskNotFoundException(String message, String key) {
189189
super(message);
190-
this.issueKey = issueKey;
190+
this.key = key;
191191
}
192192

193-
public String getIssueKey() {
194-
return issueKey;
193+
public String getKey() {
194+
return key;
195195
}
196196
}
197197
}

backend/core/src/main/java/org/sonarsource/sonarlint/core/spring/SonarLintSpringAppConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@
9999
import org.sonarsource.sonarlint.core.sync.HotspotSynchronizationService;
100100
import org.sonarsource.sonarlint.core.sync.IssueSynchronizationService;
101101
import org.sonarsource.sonarlint.core.sync.ScaSynchronizationService;
102-
import org.sonarsource.sonarlint.core.sca.ScaService;
102+
import org.sonarsource.sonarlint.core.sca.DependencyRiskService;
103103
import org.sonarsource.sonarlint.core.sync.SonarProjectBranchesSynchronizationService;
104104
import org.sonarsource.sonarlint.core.sync.SynchronizationService;
105105
import org.sonarsource.sonarlint.core.sync.TaintSynchronizationService;
106106
import org.sonarsource.sonarlint.core.tracking.KnownFindingsStorageService;
107107
import org.sonarsource.sonarlint.core.tracking.LocalOnlyIssueRepository;
108-
import org.sonarsource.sonarlint.core.tracking.ScaIssueTrackingService;
108+
import org.sonarsource.sonarlint.core.tracking.DependencyRiskTrackingService;
109109
import org.sonarsource.sonarlint.core.tracking.TaintVulnerabilityTrackingService;
110110
import org.sonarsource.sonarlint.core.tracking.TrackingService;
111111
import org.sonarsource.sonarlint.core.websocket.WebSocketService;
@@ -169,7 +169,7 @@
169169
NewCodeService.class,
170170
RequestHandlerBindingAssistant.class,
171171
TaintVulnerabilityTrackingService.class,
172-
ScaIssueTrackingService.class,
172+
DependencyRiskTrackingService.class,
173173
SonarProjectBranchesSynchronizationService.class,
174174
TaintSynchronizationService.class,
175175
IssueSynchronizationService.class,
@@ -196,7 +196,7 @@
196196
AiCodeFixService.class,
197197
ClientAwareTaskManager.class,
198198
ScaSynchronizationService.class,
199-
ScaService.class,
199+
DependencyRiskService.class,
200200
})
201201
public class SonarLintSpringAppConfig {
202202

backend/core/src/main/java/org/sonarsource/sonarlint/core/sync/ScaSynchronizationService.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121

2222
import org.sonarsource.sonarlint.core.commons.log.SonarLintLogger;
2323
import org.sonarsource.sonarlint.core.commons.progress.SonarLintCancelMonitor;
24-
import org.sonarsource.sonarlint.core.event.ScaIssuesSynchronizedEvent;
24+
import org.sonarsource.sonarlint.core.event.DependencyRisksSynchronizedEvent;
2525
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.BackendCapability;
2626
import org.sonarsource.sonarlint.core.rpc.protocol.backend.initialize.InitializeParams;
2727
import org.sonarsource.sonarlint.core.serverapi.ServerApi;
28-
import org.sonarsource.sonarlint.core.serverconnection.issues.ServerScaIssue;
28+
import org.sonarsource.sonarlint.core.serverconnection.issues.ServerDependencyRisk;
2929
import org.sonarsource.sonarlint.core.serverconnection.storage.UpdateSummary;
3030
import org.sonarsource.sonarlint.core.storage.StorageService;
3131
import org.springframework.context.ApplicationEventPublisher;
@@ -53,48 +53,48 @@ public void synchronize(ServerApi serverApi, String connectionId, String sonarPr
5353
if (!isScaSupported(serverApi, connectionId)) {
5454
return;
5555
}
56-
LOG.info("[SYNC] Synchronizing SCA issues for project '{}' on branch '{}'", sonarProjectKey, branchName);
56+
LOG.info("[SYNC] Synchronizing dependency risks for project '{}' on branch '{}'", sonarProjectKey, branchName);
5757

58-
var summary = updateServerScaIssuesForProject(serverApi, connectionId, sonarProjectKey, branchName, cancelMonitor);
58+
var summary = updateServerDependencyRisksForProject(serverApi, connectionId, sonarProjectKey, branchName, cancelMonitor);
5959
if (summary.hasAnythingChanged()) {
60-
eventPublisher.publishEvent(new ScaIssuesSynchronizedEvent(connectionId, sonarProjectKey, branchName, summary));
60+
eventPublisher.publishEvent(new DependencyRisksSynchronizedEvent(connectionId, sonarProjectKey, branchName, summary));
6161
}
6262
}
6363

64-
private UpdateSummary<ServerScaIssue> updateServerScaIssuesForProject(ServerApi serverApi, String connectionId, String sonarProjectKey, String branchName,
64+
private UpdateSummary<ServerDependencyRisk> updateServerDependencyRisksForProject(ServerApi serverApi, String connectionId, String sonarProjectKey, String branchName,
6565
SonarLintCancelMonitor cancelMonitor) {
6666
var issuesReleases = serverApi.sca().getIssuesReleases(sonarProjectKey, branchName, cancelMonitor);
6767
var findingsStore = storageService.connection(connectionId).project(sonarProjectKey).findings();
6868

69-
var previousScaIssues = findingsStore.loadScaIssues(branchName);
70-
var previousScaIssueKeys = previousScaIssues.stream().map(ServerScaIssue::key).collect(toSet());
69+
var previousDependencyRisks = findingsStore.loadDependencyRisks(branchName);
70+
var previousDependencyRiskKeys = previousDependencyRisks.stream().map(ServerDependencyRisk::key).collect(toSet());
7171

72-
var scaIssues = issuesReleases.issuesReleases().stream()
73-
.map(issueRelease -> new ServerScaIssue(
72+
var serverDependencyRisks = issuesReleases.issuesReleases().stream()
73+
.map(issueRelease -> new ServerDependencyRisk(
7474
issueRelease.key(),
75-
ServerScaIssue.Type.valueOf(issueRelease.type().name()),
76-
ServerScaIssue.Severity.valueOf(issueRelease.severity().name()),
77-
ServerScaIssue.Status.valueOf(issueRelease.status().name()),
75+
ServerDependencyRisk.Type.valueOf(issueRelease.type().name()),
76+
ServerDependencyRisk.Severity.valueOf(issueRelease.severity().name()),
77+
ServerDependencyRisk.Status.valueOf(issueRelease.status().name()),
7878
issueRelease.release().packageName(),
7979
issueRelease.release().version(),
80-
issueRelease.transitions().stream().map(Enum::name).map(ServerScaIssue.Transition::valueOf).toList()))
80+
issueRelease.transitions().stream().map(Enum::name).map(ServerDependencyRisk.Transition::valueOf).toList()))
8181
.toList();
8282

83-
findingsStore.replaceAllScaIssuesOfBranch(branchName, scaIssues);
83+
findingsStore.replaceAllDependencyRisksOfBranch(branchName, serverDependencyRisks);
8484

85-
var newScaIssueKeys = scaIssues.stream().map(ServerScaIssue::key).collect(toSet());
86-
var deletedScaIssueIds = previousScaIssues.stream()
87-
.map(ServerScaIssue::key)
88-
.filter(key -> !newScaIssueKeys.contains(key))
85+
var newDependencyRiskKeys = serverDependencyRisks.stream().map(ServerDependencyRisk::key).collect(toSet());
86+
var deletedDependencyRiskIds = previousDependencyRisks.stream()
87+
.map(ServerDependencyRisk::key)
88+
.filter(key -> !newDependencyRiskKeys.contains(key))
8989
.collect(toSet());
90-
var addedScaIssues = scaIssues.stream()
91-
.filter(issue -> !previousScaIssueKeys.contains(issue.key()))
90+
var addedDependencyRisks = serverDependencyRisks.stream()
91+
.filter(issue -> !previousDependencyRiskKeys.contains(issue.key()))
9292
.toList();
93-
var updatedScaIssues = scaIssues.stream()
94-
.filter(issue -> previousScaIssueKeys.contains(issue.key()))
93+
var updatedDependencyRisks = serverDependencyRisks.stream()
94+
.filter(issue -> previousDependencyRiskKeys.contains(issue.key()))
9595
.toList();
9696

97-
return new UpdateSummary<>(deletedScaIssueIds, addedScaIssues, updatedScaIssues);
97+
return new UpdateSummary<>(deletedDependencyRiskIds, addedDependencyRisks, updatedDependencyRisks);
9898
}
9999

100100
private boolean isScaSupported(ServerApi serverApi, String connectionId) {

0 commit comments

Comments
 (0)