diff --git a/src/SLCore.Listeners.UnitTests/Implementation/Analysis/AnalysisListenerTests.cs b/src/SLCore.Listeners.UnitTests/Implementation/Analysis/AnalysisListenerTests.cs index 1ac1fec547..9edee5224e 100644 --- a/src/SLCore.Listeners.UnitTests/Implementation/Analysis/AnalysisListenerTests.cs +++ b/src/SLCore.Listeners.UnitTests/Implementation/Analysis/AnalysisListenerTests.cs @@ -98,7 +98,7 @@ public void RaiseIssues_RaisesFinding() [TestMethod] public void RaiseHotspots_RaisesFinding() { - var raiseIssueParams = new RaiseFindingParams(default, default, default, default); + var raiseIssueParams = new RaiseHotspotParams(default, default, default, default); var raisedFindingProcessor = Substitute.For(); var testSubject = CreateTestSubject(raisedFindingProcessor: raisedFindingProcessor); diff --git a/src/SLCore.Listeners/Implementation/Analysis/AnalysisListener.cs b/src/SLCore.Listeners/Implementation/Analysis/AnalysisListener.cs index 802a9f5ed8..9d914928a3 100644 --- a/src/SLCore.Listeners/Implementation/Analysis/AnalysisListener.cs +++ b/src/SLCore.Listeners/Implementation/Analysis/AnalysisListener.cs @@ -72,6 +72,6 @@ public void DidChangeAnalysisReadiness(DidChangeAnalysisReadinessParams paramete public void RaiseIssues(RaiseFindingParams parameters) => raisedFindingProcessor.RaiseFinding(parameters); - public void RaiseHotspots(RaiseFindingParams parameters) + public void RaiseHotspots(RaiseHotspotParams parameters) => raisedFindingProcessor.RaiseFinding(parameters); } diff --git a/src/SLCore.UnitTests/Listener/Analysis/RaiseIssuesParamsTests.cs b/src/SLCore.UnitTests/Listener/Analysis/RaiseIssuesParamsTests.cs index 08ec5ff7cf..6ff693ff29 100644 --- a/src/SLCore.UnitTests/Listener/Analysis/RaiseIssuesParamsTests.cs +++ b/src/SLCore.UnitTests/Listener/Analysis/RaiseIssuesParamsTests.cs @@ -102,4 +102,82 @@ [new ImpactDto(SoftwareQuality.SECURITY, ImpactSeverity.HIGH)], deserialized.Should().BeEquivalentTo(expected, options => options.ComparingByMembers>().ComparingByMembers()); } + + [TestMethod] + public void RaiseHotspotParams_DeserializedCorrectly() + { + var expected = new RaiseHotspotParams("SLVS_Bound_VS2019", + new Dictionary> + { + { + new FileUri("file:///C:/Users/developer/Documents/Repos/sonarlint-visualstudio-sampleprojects%20AAA%20ЖЖЖЖ/bound/sonarcloud/SLVS_Samples_Bound_VS2019/Secrets/ShouldExclude/Excluded.yml"), + [new RaisedHotspotDto(Guid.Parse("10bd4422-7d55-402f-889c-e080dbe4c781"), + null, + "secrets:S6336", + "Make sure this Alibaba Cloud Access Key Secret gets revoked, changed, and removed from the code.", + IssueSeverity.BLOCKER, + RuleType.VULNERABILITY, + CleanCodeAttribute.TRUSTWORTHY, + [new ImpactDto(SoftwareQuality.SECURITY, ImpactSeverity.HIGH)], + DateTimeOffset.FromUnixTimeMilliseconds(1718182975467), + true, + false, + new TextRangeDto(14, 24, 14, 54), + [], + [], + null, + VulnerabilityProbability.HIGH, + HotspotStatus.TO_REVIEW)] + } + }, + false, + Guid.Parse("11ec4b5a-8ff6-4211-ab95-8c16eb8c7f0a")); + + var serialized = + """ + { + "configurationScopeId": "SLVS_Bound_VS2019", + "hotspotsByFileUri": { + "file:///C:/Users/developer/Documents/Repos/sonarlint-visualstudio-sampleprojects%20AAA%20ЖЖЖЖ/bound/sonarcloud/SLVS_Samples_Bound_VS2019/Secrets/ShouldExclude/Excluded.yml": [ + { + "id": "10bd4422-7d55-402f-889c-e080dbe4c781", + "serverKey": null, + "ruleKey": "secrets:S6336", + "primaryMessage": "Make sure this Alibaba Cloud Access Key Secret gets revoked, changed, and removed from the code.", + "severity": "BLOCKER", + "type": "VULNERABILITY", + "cleanCodeAttribute": "TRUSTWORTHY", + "impacts": [ + { + "softwareQuality": "SECURITY", + "impactSeverity": "HIGH" + } + ], + "introductionDate": 1718182975467, + "isOnNewCode": true, + "resolved": false, + "textRange": { + "startLine": 14, + "startLineOffset": 24, + "endLine": 14, + "endLineOffset": 54 + }, + "flows": [], + "quickFixes": [], + "ruleDescriptionContextKey": null, + "vulnerabilityProbability": "HIGH", + "status": "TO_REVIEW" + } + ] + }, + "isIntermediatePublication": false, + "analysisId": "11ec4b5a-8ff6-4211-ab95-8c16eb8c7f0a" + } + """; + + var deserialized = JsonConvert.DeserializeObject(serialized); + + deserialized.Should().BeEquivalentTo(expected, options => + options.ComparingByMembers().ComparingByMembers()); + } } diff --git a/src/SLCore/Listener/Analysis/IAnalysisListener.cs b/src/SLCore/Listener/Analysis/IAnalysisListener.cs index 49f4709b41..7a48ad0095 100644 --- a/src/SLCore/Listener/Analysis/IAnalysisListener.cs +++ b/src/SLCore/Listener/Analysis/IAnalysisListener.cs @@ -29,5 +29,5 @@ internal interface IAnalysisListener : ISLCoreListener void RaiseIssues(RaiseFindingParams parameters); - void RaiseHotspots(RaiseFindingParams parameters); + void RaiseHotspots(RaiseHotspotParams parameters); } diff --git a/src/SLCore/Listener/Analysis/RaiseFindingParams.cs b/src/SLCore/Listener/Analysis/RaiseFindingParams.cs index 66b13b694e..04e2db3c8b 100644 --- a/src/SLCore/Listener/Analysis/RaiseFindingParams.cs +++ b/src/SLCore/Listener/Analysis/RaiseFindingParams.cs @@ -24,3 +24,10 @@ namespace SonarLint.VisualStudio.SLCore.Listener.Analysis; public record RaiseFindingParams(string configurationScopeId, Dictionary> issuesByFileUri, bool isIntermediatePublication, Guid? analysisId) where T : RaisedFindingDto; + +public record RaiseHotspotParams( + string configurationScopeId, + Dictionary> hotspotsByFileUri, + bool isIntermediatePublication, + Guid? analysisId) + : RaiseFindingParams(configurationScopeId, hotspotsByFileUri, isIntermediatePublication, analysisId);