diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 17f9b95a33..b40ab946e0 100644 --- a/THIRD-PARTY-NOTICES +++ b/THIRD-PARTY-NOTICES @@ -21,8 +21,8 @@ mailto:info AT sonarsource DOT com This program is distributed with SonarQube analyzers that are subject to specific license terms. -The sonar-csharp-enterprise-plugin and sonar-vbnet-enterprise-plugin are -SonarQube analyzers published under the following proprietary license: +The sonar-cfamily, sonar-csharp-enterprise-plugin and sonar-vbnet-enterprise-plugin +are SonarQube analyzers published under the following proprietary license: SonarSource SA grants you a non-transferable, non-sublicensable, limited license to use the aforementioned plugins solely as part of this program. Any use, reproduction, distribution, or modification of the diff --git a/src/EmbeddedSonarAnalyzer.props b/src/EmbeddedSonarAnalyzer.props index 6662250595..8b167ef163 100644 --- a/src/EmbeddedSonarAnalyzer.props +++ b/src/EmbeddedSonarAnalyzer.props @@ -5,10 +5,10 @@ 10.3.0.106239 - 6.60.0.76379 - 10.16.0.27621 - 2.16.0.4008 + 6.61.0.77816 + 10.18.0.28572 + 2.19.0.4883 - 10.10.0.79572 + 10.11.0.79687 \ No newline at end of file diff --git a/src/Integration.UnitTests/LocalServices/FileTrackerTests.cs b/src/Integration.UnitTests/LocalServices/FileTrackerTests.cs index c2d8489c2e..d951554f36 100644 --- a/src/Integration.UnitTests/LocalServices/FileTrackerTests.cs +++ b/src/Integration.UnitTests/LocalServices/FileTrackerTests.cs @@ -43,7 +43,7 @@ public void MefCtor_CheckExports() MefTestHelpers.CreateExport(), MefTestHelpers.CreateExport()); } - + [TestMethod] public void AddFiles_ServiceProviderFailed_LogsError() { @@ -56,7 +56,7 @@ public void AddFiles_ServiceProviderFailed_LogsError() var testLogger = new TestLogger(); var testSubject = new FileTracker(serviceProvider, activeConfigScopeTracker, threadHandling, clientFileDtoFactory, testLogger); - + testSubject.AddFiles(new SourceFile("C:\\Users\\test\\TestProject\\AFile.cs")); testLogger.AssertOutputStrings($"[FileTracker] {SLCoreStrings.ServiceProviderNotInitialized}"); @@ -72,7 +72,8 @@ public void AddFiles_ShouldForwardFilesToSlCore() testSubject.AddFiles(new SourceFile("C:\\Users\\test\\TestProject\\AFile.cs")); result.removedFiles.Should().BeEmpty(); - result.addedOrChangedFiles.Should().ContainSingle(); + result.addedFiles.Should().BeEmpty(); + result.changedFiles.Should().ContainSingle(); } [TestMethod] @@ -86,7 +87,8 @@ public void RemoveFiles_ShouldForwardFilesToSlCore() result.removedFiles.Should().ContainSingle(); result.removedFiles[0].Should().BeEquivalentTo(new FileUri("C:\\Users\\test\\TestProject\\AFile.cs")); - result.addedOrChangedFiles.Should().BeEmpty(); + result.addedFiles.Should().BeEmpty(); + result.changedFiles.Should().BeEmpty(); } [TestMethod] @@ -101,7 +103,8 @@ public void RenameFiles_ShouldForwardFilesToSlCore() result.removedFiles.Should().ContainSingle(); result.removedFiles[0].Should().BeEquivalentTo(new FileUri("C:\\Users\\test\\TestProject\\AFile.cs")); - result.addedOrChangedFiles.Should().ContainSingle(); + result.addedFiles.Should().BeEmpty(); + result.changedFiles.Should().ContainSingle(); } private static FileTracker CreateTestSubject(out IFileRpcSLCoreService slCoreService) @@ -124,7 +127,7 @@ private static FileTracker CreateTestSubject(out IFileRpcSLCoreService slCoreSer .Returns(async info => await info.Arg>>()()); var logger = Substitute.For(); - + return new FileTracker(serviceProvider, activeConfigScopeTracker, threadHandling, clientFileDtoFactory, logger); } } diff --git a/src/Integration.Vsix.UnitTests/CFamily/CFamilyEmbeddedSonarWayRulesTests.cs b/src/Integration.Vsix.UnitTests/CFamily/CFamilyEmbeddedSonarWayRulesTests.cs index eafa89e1cb..d4d8558543 100644 --- a/src/Integration.Vsix.UnitTests/CFamily/CFamilyEmbeddedSonarWayRulesTests.cs +++ b/src/Integration.Vsix.UnitTests/CFamily/CFamilyEmbeddedSonarWayRulesTests.cs @@ -46,12 +46,12 @@ public class CFamilyEmbeddedSonarWayRulesTests // e.g. https://next.sonarqube.com/sonarqube/api/plugins/installed and https://sonarcloud.io/api/plugins/installed // Note - you need to be logged in. - // Rule data for C-Family plugin v6.57.0.73017 + // Rule data for C-Family plugin v6.61.0.77816 - private const int Active_C_Rules = 209; + private const int Active_C_Rules = 211; private const int Inactive_C_Rules = 130; - private const int Active_CPP_Rules = 445; + private const int Active_CPP_Rules = 453; private const int Inactive_CPP_Rules = 219; private readonly CFamilySonarWayRulesConfigProvider rulesMetadataCache = new CFamilySonarWayRulesConfigProvider(CFamilyShared.CFamilyFilesDirectory); diff --git a/src/Integration/LocalServices/FileTracker.cs b/src/Integration/LocalServices/FileTracker.cs index 22059c8fea..82e1d54a7e 100644 --- a/src/Integration/LocalServices/FileTracker.cs +++ b/src/Integration/LocalServices/FileTracker.cs @@ -67,15 +67,17 @@ public void RenameFiles(string[] beforeRenameFiles, SourceFile[] afterRenameFile .Forget(); } - private void NotifySlCoreFilesChanged(string[] removedFiles, SourceFile[] addedFiles) + private void NotifySlCoreFilesChanged(string[] removedFiles, SourceFile[] addedOrChangedFiles) { - if (serviceProvider.TryGetTransientService(out IFileRpcSLCoreService fileRpcSlCoreService) && activeConfigScopeTracker.Current is {} configScope) + if (serviceProvider.TryGetTransientService(out IFileRpcSLCoreService fileRpcSlCoreService) && activeConfigScopeTracker.Current is {} configScope) { - var clientFiles = addedFiles.Select(sourceFile => clientFileDtoFactory.Create(configScope.Id, configScope.RootPath, sourceFile)).ToList(); + var clientFiles = addedOrChangedFiles.Select(sourceFile => clientFileDtoFactory.Create(configScope.Id, configScope.RootPath, sourceFile)).ToList(); var removedFileUris = removedFiles.Select(f => new FileUri(f)).ToList(); - fileRpcSlCoreService.DidUpdateFileSystem(new DidUpdateFileSystemParams( - removedFileUris, clientFiles)); + /* we're only sending changed files here as it is complicated to implement the proper tracking of added files + AND `changed` files that were actually added are recognized as added by SLCore + https://github.com/SonarSource/sonarlint-core/pull/1163/files#diff-070e6ef952d4a71245d92ea8f281c5a56050e8992179cde3955d4b1530dff664R152 */ + fileRpcSlCoreService.DidUpdateFileSystem(new DidUpdateFileSystemParams(removedFileUris, [], clientFiles)); } else { diff --git a/src/IssueViz.UnitTests/OpenInIDE/IssueDetailDtoToAnalysisIssueConverterTests.cs b/src/IssueViz.UnitTests/OpenInIDE/IssueDetailDtoToAnalysisIssueConverterTests.cs index 0fa921113a..acd633bee9 100644 --- a/src/IssueViz.UnitTests/OpenInIDE/IssueDetailDtoToAnalysisIssueConverterTests.cs +++ b/src/IssueViz.UnitTests/OpenInIDE/IssueDetailDtoToAnalysisIssueConverterTests.cs @@ -59,8 +59,6 @@ public void Convert_CalculatesChecksumForCodeSnippet() var issue = testSubject.Convert(new IssueDetailDto("key", "ruleKey", "ide\\path", - "branch", - "pr", "msg", "today", codeSnippet, @@ -83,8 +81,6 @@ public void Convert_PathTranslated() var issue = testSubject.Convert(new IssueDetailDto("key", "ruleKey", "ide\\path", - "branch", - "pr", "msg", "today", "codeSnippet", @@ -112,8 +108,6 @@ public void Convert_PrimaryRangeAndMessagePreserved() var issue = testSubject.Convert(new IssueDetailDto("key", "ruleKey", "ide\\path", - "branch", - "pr", message, "today", "codeSnippet", @@ -138,8 +132,6 @@ public void Convert_RuleKeyPreserved() var issue = testSubject.Convert(new IssueDetailDto("key", ruleKey, "ide\\path", - "branch", - "pr", "msg", "today", "codeSnippet", @@ -161,8 +153,6 @@ public void Convert_FlowsPreservedWithPathTranslation() var issue = testSubject.Convert(new IssueDetailDto("key", "rule", "ide\\path", - "branch", - "pr", "msg", "today", "codeSnippet", diff --git a/src/IssueViz.UnitTests/OpenInIDE/OpenIssueInIdeHandlerTests.cs b/src/IssueViz.UnitTests/OpenInIDE/OpenIssueInIdeHandlerTests.cs index 69080a0324..d5152e4fe5 100644 --- a/src/IssueViz.UnitTests/OpenInIDE/OpenIssueInIdeHandlerTests.cs +++ b/src/IssueViz.UnitTests/OpenInIDE/OpenIssueInIdeHandlerTests.cs @@ -43,19 +43,19 @@ public void MefCtor_CheckIsSingleton() { MefTestHelpers.CheckIsSingletonMefComponent(); } - + [DataTestMethod] [DataRow(true)] [DataRow(false)] public void Show_CallsBaseHandler(bool isTaint) { const string configScope = "configscope"; - var issue = new IssueDetailDto(default, default, default, default, default, default, + var issue = new IssueDetailDto(default, default, default, default, default, default, isTaint, default, default); var testSubject = CreateTestSubject(out var handler, out var converter); - + testSubject.Show(issue, configScope); - + handler.Received().ShowIssue(issue, configScope, converter, isTaint ? IssueListIds.TaintId : IssueListIds.ErrorListId, null); } @@ -66,5 +66,5 @@ private OpenIssueInIdeHandler CreateTestSubject(out IOpenInIdeHandlerImplementat issueOpenInIdeConverter = Substitute.For(); return new OpenIssueInIdeHandler(openInIdeHandlerImplementation, issueOpenInIdeConverter); - } + } } diff --git a/src/SLCore.IntegrationTests/FileAnalysisTestsRunner.cs b/src/SLCore.IntegrationTests/FileAnalysisTestsRunner.cs index 8575f8ef6a..a038cf8ca5 100644 --- a/src/SLCore.IntegrationTests/FileAnalysisTestsRunner.cs +++ b/src/SLCore.IntegrationTests/FileAnalysisTestsRunner.cs @@ -177,41 +177,41 @@ public void Dispose() internal interface ITestingFile { string RelativePath { get; } - List ExpectedIssues { get; } + List ExpectedIssues { get; } } -internal record ExpectedTestIssue(string ruleKey, TextRangeDto textRange, CleanCodeAttribute cleanCodeAttribute, int expectedFlows); +internal record TestIssue(string ruleKey, TextRangeDto textRange, CleanCodeAttribute? cleanCodeAttribute, int expectedFlows); internal class JavaScriptIssuesFile : ITestingFile { public string RelativePath => @"Resources\JavaScriptIssues.js"; - public List ExpectedIssues => + public List ExpectedIssues => [ - new ExpectedTestIssue("javascript:S1135", new TextRangeDto(1, 3, 1, 7), CleanCodeAttribute.COMPLETE, 0), - new ExpectedTestIssue("javascript:S3504", new TextRangeDto(2, 0, 2, 5), CleanCodeAttribute.CLEAR, 0) + new("javascript:S1135", new TextRangeDto(1, 3, 1, 7), CleanCodeAttribute.COMPLETE, 0), + new("javascript:S3504", new TextRangeDto(2, 0, 2, 5), CleanCodeAttribute.CLEAR, 0) ]; } internal class OneIssueRuleWithParamFile : ITestingFile { public string RelativePath => @"Resources\RuleParam.js"; - - public readonly string CtorParamRuleId = "javascript:S107"; - public readonly int ActualCtorParams = 4; - public readonly string CtorParamName = "maximumFunctionParameters"; - public List ExpectedIssues { get; set; } + + public const string CtorParamRuleId = "javascript:S107"; + public const int ActualCtorParams = 4; + public const string CtorParamName = "maximumFunctionParameters"; + public List ExpectedIssues { get; set; } } internal class TypeScriptIssuesFile : ITestingFile { public string RelativePath => @"Resources\TypeScriptIssues.ts"; - public List ExpectedIssues => + public List ExpectedIssues => [ - new ExpectedTestIssue("typescript:S2737", new TextRangeDto(3, 2, 3, 7), CleanCodeAttribute.CLEAR, 0), - new ExpectedTestIssue("typescript:S1186", new TextRangeDto(7, 16, 7, 19), CleanCodeAttribute.COMPLETE, 0), - new ExpectedTestIssue("typescript:S3776", new TextRangeDto(30, 9, 30, 18), CleanCodeAttribute.FOCUSED, 21) + new("typescript:S2737", new TextRangeDto(3, 2, 3, 7), CleanCodeAttribute.CLEAR, 0), + new("typescript:S1186", new TextRangeDto(7, 16, 7, 19), CleanCodeAttribute.COMPLETE, 0), + new("typescript:S3776", new TextRangeDto(30, 9, 30, 18), CleanCodeAttribute.FOCUSED, 21) ]; } @@ -219,10 +219,10 @@ internal class CssIssuesFile : ITestingFile { public string RelativePath => @"Resources\CssIssues.css"; - public List ExpectedIssues => + public List ExpectedIssues => [ - new ExpectedTestIssue("css:S4666", new TextRangeDto(20, 0, 20, 77), CleanCodeAttribute.LOGICAL, 0), - new ExpectedTestIssue("css:S4655", new TextRangeDto(12, 0, 12, 38), CleanCodeAttribute.LOGICAL, 0), + new("css:S4666", new TextRangeDto(20, 0, 20, 77), CleanCodeAttribute.LOGICAL, 0), + new("css:S4655", new TextRangeDto(12, 0, 12, 38), CleanCodeAttribute.LOGICAL, 0), ]; } @@ -230,24 +230,25 @@ internal class VueIssuesFile : ITestingFile { public string RelativePath => @"Resources\VueIssues.vue"; - public List ExpectedIssues => + public List ExpectedIssues => [ - new ExpectedTestIssue("css:S4661", new TextRangeDto(12, 0, 12, 43), CleanCodeAttribute.LOGICAL, 0), - new ExpectedTestIssue("css:S4658", new TextRangeDto(12, 0, 12, 43), CleanCodeAttribute.CLEAR, 0), + new("css:S4661", new TextRangeDto(12, 0, 12, 43), CleanCodeAttribute.LOGICAL, 0), + new("css:S4658", new TextRangeDto(12, 0, 12, 43), CleanCodeAttribute.CLEAR, 0), ]; } internal class SecretsIssuesFile : ITestingFile { - private const string CloudSecretsRuleKey = "secrets:S6336"; + private const string AmazonSecretsRuleKey = "secrets:S6290"; + private const string AzureSecretsRuleKey = "secrets:S6684"; public string RelativePath => @"Resources\Secrets.yml"; - public (string ruleKey, int issuesCount) RuleWithMultipleIssues => (CloudSecretsRuleKey, 2); + public (string ruleKey, int issuesCount) RuleWithMultipleIssues => (AmazonSecretsRuleKey, 2); - public List ExpectedIssues => + public List ExpectedIssues => [ - new ExpectedTestIssue(CloudSecretsRuleKey, new TextRangeDto(9, 24, 9, 40), CleanCodeAttribute.TRUSTWORTHY, 0), - new ExpectedTestIssue(CloudSecretsRuleKey, new TextRangeDto(14, 24, 14, 40), CleanCodeAttribute.TRUSTWORTHY, 0), - new ExpectedTestIssue("secrets:S6337", new TextRangeDto(20, 12, 20, 56), CleanCodeAttribute.TRUSTWORTHY, 0), + new(AmazonSecretsRuleKey, new TextRangeDto(9, 38, 9, 78), CleanCodeAttribute.TRUSTWORTHY, 0), + new(AmazonSecretsRuleKey, new TextRangeDto(14, 38, 14, 78), CleanCodeAttribute.TRUSTWORTHY, 0), + new(AzureSecretsRuleKey, new TextRangeDto(20, 33, 20, 65), CleanCodeAttribute.TRUSTWORTHY, 0), ]; } diff --git a/src/SLCore.IntegrationTests/Resources/Secrets.yml b/src/SLCore.IntegrationTests/Resources/Secrets.yml index 6f4e4057ef..70756f2b61 100644 --- a/src/SLCore.IntegrationTests/Resources/Secrets.yml +++ b/src/SLCore.IntegrationTests/Resources/Secrets.yml @@ -4,20 +4,26 @@ #________________ -# S6336 - Alibaba Cloud AccessKeys should not be disclosed +# S6290 - Amazon Web Services credentials should not be disclosed -#"String aliyunAcecret="LTAI5tBcc9SecYAo"; +# props.set("aws-secret-access-key", "kHeUAwnSUizTWpSbyGAz4f+As5LshPIjvtpswqGb") #___________________________________________________________________ -# S6336 - Alibaba Cloud AccessKeys should not be disclosed +# S6290 - Amazon Web Services credentials should not be disclosed -#"String aliyunAcecret="LTAI5tBcc9SecYAo"; +# props.set("aws-secret-access-key", "kHeUAwnSUizTWpSbyGAz4f+As5LshPIjvtpswqGb") + +#___________________________________________________________________ + +# S6684 Azure Subscription Keys should not be disclosed + +# props.set("subscription_key", "efbb1a98f026d061464af685cd16dcd3") #___________________________________________________________________ # S6337 - IBM API keys should not be disclosed -#"apikey": "fDKU7e_u_EnQgWgDVO4b_ubGqVTa5IYwWEey7lMfEB_1" +#"apikey": "fDKU7e_u_EnQgWgDVO4b_ubGqVTa5IYwWEey7lMfEB_1" NOT SUPPORTED WITH BASIC ANALYZER #___________________________________________________________________ diff --git a/src/SLCore.IntegrationTests/RuleConfigurationAnalysisTests.cs b/src/SLCore.IntegrationTests/RuleConfigurationAnalysisTests.cs index 5800290fbc..e044244ec7 100644 --- a/src/SLCore.IntegrationTests/RuleConfigurationAnalysisTests.cs +++ b/src/SLCore.IntegrationTests/RuleConfigurationAnalysisTests.cs @@ -35,7 +35,7 @@ public static void ClassInitialize(TestContext context) { sharedFileAnalysisTestsRunner = new FileAnalysisTestsRunner(nameof(RuleConfigurationAnalysisTests)); } - + [ClassCleanup] public static void ClassCleanup() { @@ -48,13 +48,13 @@ public async Task StandaloneRuleConfig_JavaScriptAnalysisShouldIgnoreOneIssueOfI var ruleToDisable = FileAnalysisTestsRunner.JavaScriptIssues.ExpectedIssues[0]; var ruleConfig = CreateInactiveRuleConfig(ruleToDisable.ruleKey); sharedFileAnalysisTestsRunner.SetRuleConfiguration(ruleConfig); - + var issuesByFileUri = await sharedFileAnalysisTestsRunner.RunFileAnalysis(FileAnalysisTestsRunner.JavaScriptIssues, TestContext.TestName); issuesByFileUri.Should().HaveCount(1); issuesByFileUri[new FileUri(FileAnalysisTestsRunner.JavaScriptIssues.GetFullPath())].Should().HaveCount(FileAnalysisTestsRunner.JavaScriptIssues.ExpectedIssues.Count - 1); } - + [TestMethod] public async Task StandaloneRuleConfig_SecretsAnalysisShouldIgnoreTwoIssuesOfInactiveRule() { @@ -67,7 +67,7 @@ public async Task StandaloneRuleConfig_SecretsAnalysisShouldIgnoreTwoIssuesOfIna issuesByFileUri.Should().HaveCount(1); issuesByFileUri[new FileUri(FileAnalysisTestsRunner.SecretsIssues.GetFullPath())].Should().HaveCount(FileAnalysisTestsRunner.SecretsIssues.ExpectedIssues.Count - multipleIssuesRule.issuesCount); } - + [TestMethod] public async Task StandaloneRuleConfig_JsLetRuleIsDisableInSettingsFile_JavaScriptAnalysisShouldIgnoreIssueOnInitialization() { @@ -80,7 +80,7 @@ public async Task StandaloneRuleConfig_JsLetRuleIsDisableInSettingsFile_JavaScri issuesByFileUri.Should().HaveCount(1); issuesByFileUri[new FileUri(FileAnalysisTestsRunner.JavaScriptIssues.GetFullPath())].Should().HaveCount(FileAnalysisTestsRunner.JavaScriptIssues.ExpectedIssues.Count - 1); } - + [TestMethod] public async Task StandaloneRuleConfig_CloudSecretsRuleIsDisabledInSettingsFile_SecretsAnalysisShouldIgnoreIssueOnInitialization() { @@ -89,31 +89,31 @@ public async Task StandaloneRuleConfig_CloudSecretsRuleIsDisabledInSettingsFile_ using var customTestRunner = new FileAnalysisTestsRunner(TestContext.TestName, secretsRuleConfig); var issuesByFileUri = await customTestRunner.RunFileAnalysis(FileAnalysisTestsRunner.SecretsIssues, TestContext.TestName); - + issuesByFileUri.Should().HaveCount(1); issuesByFileUri[new FileUri(FileAnalysisTestsRunner.SecretsIssues.GetFullPath())].Should().HaveCount(FileAnalysisTestsRunner.SecretsIssues.ExpectedIssues.Count - multipleIssuesRule.issuesCount); } - + [TestMethod] public async Task StandaloneRuleConfig_CtorParamsUnderThreshold_JavaScriptActiveRuleShouldHaveNoIssue() { - var ctorParamsRuleConfig = CreateActiveCtorParamRuleConfig(threshold: FileAnalysisTestsRunner.OneIssueRuleWithParam.ActualCtorParams + 1); + var ctorParamsRuleConfig = CreateActiveCtorParamRuleConfig(threshold: OneIssueRuleWithParamFile.ActualCtorParams + 1); sharedFileAnalysisTestsRunner.SetRuleConfiguration(ctorParamsRuleConfig); - + var issuesByFileUri = await sharedFileAnalysisTestsRunner.RunFileAnalysis(FileAnalysisTestsRunner.OneIssueRuleWithParam, TestContext.TestName); - + issuesByFileUri.Should().HaveCount(1); issuesByFileUri[new FileUri(FileAnalysisTestsRunner.OneIssueRuleWithParam.GetFullPath())].Should().HaveCount(0); } - + [TestMethod] public async Task StandaloneRuleConfig_CtorParamsAboveThreshold_JavaScriptActiveRuleShouldHaveOneIssue() { - var ctorParamsRuleConfig = CreateActiveCtorParamRuleConfig(threshold: FileAnalysisTestsRunner.OneIssueRuleWithParam.ActualCtorParams - 1); + var ctorParamsRuleConfig = CreateActiveCtorParamRuleConfig(threshold: OneIssueRuleWithParamFile.ActualCtorParams - 1); sharedFileAnalysisTestsRunner.SetRuleConfiguration(ctorParamsRuleConfig); - + var issuesByFileUri = await sharedFileAnalysisTestsRunner.RunFileAnalysis(FileAnalysisTestsRunner.OneIssueRuleWithParam, TestContext.TestName); - + issuesByFileUri.Should().HaveCount(1); issuesByFileUri[new FileUri(FileAnalysisTestsRunner.OneIssueRuleWithParam.GetFullPath())].Should().HaveCount(1); } @@ -122,7 +122,7 @@ private static Dictionary CreateActiveCtorParam { return new() { - { FileAnalysisTestsRunner.OneIssueRuleWithParam.CtorParamRuleId, new StandaloneRuleConfigDto(isActive: true, new() { { FileAnalysisTestsRunner.OneIssueRuleWithParam.CtorParamName, threshold.ToString() } }) } + { OneIssueRuleWithParamFile.CtorParamRuleId, new StandaloneRuleConfigDto(isActive: true, new() { { OneIssueRuleWithParamFile.CtorParamName, threshold.ToString() } }) } }; } diff --git a/src/SLCore.IntegrationTests/SimpleAnalysisTests.cs b/src/SLCore.IntegrationTests/SimpleAnalysisTests.cs index e8fdabb457..b950c93598 100644 --- a/src/SLCore.IntegrationTests/SimpleAnalysisTests.cs +++ b/src/SLCore.IntegrationTests/SimpleAnalysisTests.cs @@ -19,6 +19,7 @@ */ using SonarLint.VisualStudio.SLCore.Common.Models; +using SonarLint.VisualStudio.SLCore.Listener.Analysis.Models; namespace SonarLint.VisualStudio.SLCore.IntegrationTests; @@ -34,27 +35,27 @@ public static void ClassInitialize(TestContext context) { sharedFileAnalysisTestsRunner = new FileAnalysisTestsRunner(nameof(SimpleAnalysisTests)); } - + [ClassCleanup] public static void ClassCleanup() { sharedFileAnalysisTestsRunner.Dispose(); } - + [TestMethod] - public Task DefaultRuleConfig_ContentFromDisk_JavaScriptAnalysisProducesExpectedIssues() + public Task DefaultRuleConfig_ContentFromDisk_JavaScriptAnalysisProducesExpectedIssues() => DefaultRuleConfig_AnalysisProducesExpectedIssuesInFile(FileAnalysisTestsRunner.JavaScriptIssues,false); - + [TestMethod] - public Task DefaultRuleConfig_ContentFromRpc_JavaScriptAnalysisProducesExpectedIssues() + public Task DefaultRuleConfig_ContentFromRpc_JavaScriptAnalysisProducesExpectedIssues() => DefaultRuleConfig_AnalysisProducesExpectedIssuesInFile(FileAnalysisTestsRunner.JavaScriptIssues,true); [TestMethod] - public Task DefaultRuleConfig_ContentFromDisk_SecretsAnalysisProducesExpectedIssues() + public Task DefaultRuleConfig_ContentFromDisk_SecretsAnalysisProducesExpectedIssues() => DefaultRuleConfig_AnalysisProducesExpectedIssuesInFile(FileAnalysisTestsRunner.SecretsIssues, false); [TestMethod] - public Task DefaultRuleConfig_ContentFromRpc_SecretsAnalysisProducesExpectedIssues() + public Task DefaultRuleConfig_ContentFromRpc_SecretsAnalysisProducesExpectedIssues() => DefaultRuleConfig_AnalysisProducesExpectedIssuesInFile(FileAnalysisTestsRunner.SecretsIssues, true); [TestMethod] @@ -87,16 +88,7 @@ private async Task DefaultRuleConfig_AnalysisProducesExpectedIssuesInFile(ITesti issuesByFileUri.Should().HaveCount(1); var receivedIssues = issuesByFileUri[new FileUri(testingFile.GetFullPath())]; - receivedIssues.Should().HaveCount(testingFile.ExpectedIssues.Count); - - foreach (var expectedIssue in testingFile.ExpectedIssues) - { - var receivedIssue = receivedIssues.SingleOrDefault(x => x.ruleKey == expectedIssue.ruleKey && x.textRange.Equals(expectedIssue.textRange)); - receivedIssue.Should().NotBeNull(); - receivedIssue.severityMode.Right.Should().NotBeNull(); - receivedIssue.severityMode.Right.cleanCodeAttribute.Should().Be(expectedIssue.cleanCodeAttribute); - receivedIssue.flows.Count.Should().Be(expectedIssue.expectedFlows); - } + var receivedTestIssues = receivedIssues.Select(x => new TestIssue(x.ruleKey, x.textRange, x.severityMode.Right?.cleanCodeAttribute, x.flows.Count)); + receivedTestIssues.Should().BeEquivalentTo(testingFile.ExpectedIssues); } - } diff --git a/src/SLCore.Listeners.UnitTests/Implementation/ShowInIdeListenerTests.cs b/src/SLCore.Listeners.UnitTests/Implementation/ShowInIdeListenerTests.cs index 1f30609657..eadbbaf70c 100644 --- a/src/SLCore.Listeners.UnitTests/Implementation/ShowInIdeListenerTests.cs +++ b/src/SLCore.Listeners.UnitTests/Implementation/ShowInIdeListenerTests.cs @@ -46,18 +46,17 @@ public void MefCtor_CheckIsSingleton() [TestMethod] public void ShowIssue_ForwardsToHandler() { - var dummyIssue = new IssueDetailDto(default, default, default, default, - default, default, default, default, + var dummyIssue = new IssueDetailDto(default, default, default, default, default, default, default, default, default); const string configScopeId = "configscope"; var openIssueInIdeHandler = Substitute.For(); var testSubject = new ShowInIdeListener(openIssueInIdeHandler, Substitute.For()); - + testSubject.ShowIssue(new ShowIssueParams(configScopeId, dummyIssue)); - + openIssueInIdeHandler.Received().Show(dummyIssue, configScopeId); } - + [TestMethod] public void ShowHotspot_ForwardsToHandler() { @@ -66,9 +65,9 @@ public void ShowHotspot_ForwardsToHandler() const string configScopeId = "configscope"; var openHotspotInIdeHandler = Substitute.For(); var testSubject = new ShowInIdeListener(Substitute.For(), openHotspotInIdeHandler); - + testSubject.ShowHotspot(new ShowHotspotParams(configScopeId, dummyIssue)); - + openHotspotInIdeHandler.Received().Show(dummyIssue, configScopeId); } } diff --git a/src/SLCore.Listeners/Implementation/Http/ICertificateChainValidator.cs b/src/SLCore.Listeners/Implementation/Http/ICertificateChainValidator.cs index 585c425627..7664730f37 100644 --- a/src/SLCore.Listeners/Implementation/Http/ICertificateChainValidator.cs +++ b/src/SLCore.Listeners/Implementation/Http/ICertificateChainValidator.cs @@ -41,16 +41,16 @@ public CertificateChainValidator(ILogger logger) { this.logger = logger; } - + [ExcludeFromCodeCoverage] // can't easily unit test X509Chain public bool ValidateChain(X509Certificate2 primaryCertificate, IEnumerable additionalCertificates) { - logger.LogVerbose($"[{nameof(CertificateChainValidator)}] Validating certificate: " + primaryCertificate); + logger.LogVerbose("[CertificateChainValidator] Validating certificate: " + primaryCertificate); using var x509Chain = new X509Chain(); foreach (var additionalCertificate in additionalCertificates) { - logger.LogVerbose($"[{nameof(CertificateChainValidator)}] Using chain certificate: " + primaryCertificate); + logger.LogVerbose("[CertificateChainValidator] Using chain certificate: " + primaryCertificate); x509Chain.ChainPolicy.ExtraStore.Add(additionalCertificate); } @@ -59,12 +59,13 @@ public bool ValidateChain(X509Certificate2 primaryCertificate, IEnumerable + var addedFiles = new List { - new(new FileUri("file:///c:/Users/test/project/Baz.cs"), "Baz.cs", "CONFIG_SCOPE_ID", false, - "utf8", "C:\\Users\\test\\project", "CONTENT") + new(new FileUri("file:///c:/Users/test/project1/Baz.cs"), "Baz.cs", "CONFIG_SCOPE_ID", false, + "utf8", "C:\\Users\\test\\project1", "CONTENT") }; - var testSubject = new DidUpdateFileSystemParams(removedFiles, addedOrChangedFiles); + var changedFiles = new List + { + new(new FileUri("file:///c:/Users/test/project2/ABOBA.cs"), "ABOBA.cs", "CONFIG_SCOPE_ID", true, + "utf16", "C:\\Users\\test\\project2", "CONTENT2") + }; + + var testSubject = new DidUpdateFileSystemParams(removedFiles, addedFiles, changedFiles); const string expectedString = """ { @@ -51,17 +57,29 @@ public void Serialize_AsExpected() "file:///tmp/junit14012097140227905793/Foo.cs", "file:///tmp/junit14012097140227905793/Bar.cs" ], - "addedOrChangedFiles": [ + "addedFiles": [ { - "uri": "file:///c:/Users/test/project/Baz.cs", + "uri": "file:///c:/Users/test/project1/Baz.cs", "ideRelativePath": "Baz.cs", "configScopeId": "CONFIG_SCOPE_ID", "isTest": false, "charset": "utf8", - "fsPath": "C:\\Users\\test\\project", + "fsPath": "C:\\Users\\test\\project1", "content": "CONTENT", "isUserDefined": true } + ], + "changedFiles": [ + { + "uri": "file:///c:/Users/test/project2/ABOBA.cs", + "ideRelativePath": "ABOBA.cs", + "configScopeId": "CONFIG_SCOPE_ID", + "isTest": true, + "charset": "utf16", + "fsPath": "C:\\Users\\test\\project2", + "content": "CONTENT2", + "isUserDefined": true + } ] } """; diff --git a/src/SLCore/Listener/Visualization/Models/IssueDetailDto.cs b/src/SLCore/Listener/Visualization/Models/IssueDetailDto.cs index 1a553a74d0..df9361cb46 100644 --- a/src/SLCore/Listener/Visualization/Models/IssueDetailDto.cs +++ b/src/SLCore/Listener/Visualization/Models/IssueDetailDto.cs @@ -28,8 +28,6 @@ public record IssueDetailDto( string issueKey, string ruleKey, string ideFilePath, - string branch, - string pullRequest, string message, string creationDate, string codeSnippet, diff --git a/src/SLCore/SLCoreStrings.Designer.cs b/src/SLCore/SLCoreStrings.Designer.cs index a8f772b270..940e845c08 100644 --- a/src/SLCore/SLCoreStrings.Designer.cs +++ b/src/SLCore/SLCoreStrings.Designer.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -78,6 +77,24 @@ public static string AnalysisReadinessUpdate { } } + /// + /// Looks up a localized string similar to [CertificateChainValidator] Certificate validation failed for the following reason(s):. + /// + public static string CertificateValidator_Failed { + get { + return ResourceManager.GetString("CertificateValidator_Failed", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to [CertificateChainValidator] {0}: {1}. + /// + public static string CertificateValidator_FailureReasonTemplate { + get { + return ResourceManager.GetString("CertificateValidator_FailureReasonTemplate", resourceCulture); + } + } + /// /// Looks up a localized string similar to Configuration scope conflict. /// diff --git a/src/SLCore/SLCoreStrings.resx b/src/SLCore/SLCoreStrings.resx index 68a4c04346..d31c4ad3e9 100644 --- a/src/SLCore/SLCoreStrings.resx +++ b/src/SLCore/SLCoreStrings.resx @@ -171,4 +171,10 @@ Unexpected server connection type + + [CertificateChainValidator] Certificate validation failed for the following reason(s): + + + [CertificateChainValidator] {0}: {1} + \ No newline at end of file diff --git a/src/SLCore/Service/File/DidUpdateFileSystemParams.cs b/src/SLCore/Service/File/DidUpdateFileSystemParams.cs index 6df51d4e04..2bcab90a7f 100644 --- a/src/SLCore/Service/File/DidUpdateFileSystemParams.cs +++ b/src/SLCore/Service/File/DidUpdateFileSystemParams.cs @@ -23,4 +23,4 @@ namespace SonarLint.VisualStudio.SLCore.Service.File; -public record DidUpdateFileSystemParams(List removedFiles, List addedOrChangedFiles); +public record DidUpdateFileSystemParams(List removedFiles, List addedFiles, List changedFiles);