SonarLint in Visual Studio 2019 fails to analyse C++ files: System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms

I’m using Visual Studio Professional 2019 (v16.6.3) to connect to my enterprise’s SonarQube server via the SonarLint plugin for Visual Studio (v4.23.0.19399). When I save a C++ file to trigger analysis by SonarLint I get this stacktrace in the SonarLint output window:

Loaded settings from "C:\path\to\.sonarlint\myprojectkey_cpp_settings.json".
Using connected mode settings. User-specified settings in settings.json will be ignored.
Calculating effective rule settings...
Note: the following CFamily rules are not available in SonarLint: cpp:S5536, c:S5536, cpp:S5801, c:S5801, cpp:S5814, c:S5814, cpp:S5815, c:S5815, cpp:S5816, c:S5816, cpp:S5824, c:S5824
Analyzing C:\path\to\MyFile.cpp
Failed to analyze C:\path\to\MyFile.cpp, exception details: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.
   at System.Security.Cryptography.MD5CryptoServiceProvider..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Security.Cryptography.CryptoConfig.CreateFromName(String name, Object[] args)
   at System.Security.Cryptography.MD5.Create()
   at SonarLint.VisualStudio.Integration.Suppression.ChecksumCalculator.Calculate(String text)
   at SonarLint.VisualStudio.Integration.Vsix.IssueToIssueMarkerConverter.Convert(IAnalysisIssue issue, ITextSnapshot textSnapshot)
   at SonarLint.VisualStudio.Integration.Vsix.AccumulatingIssueConsumer.<Accept>b__8_0(IAnalysisIssue x)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at SonarLint.VisualStudio.Integration.Vsix.AccumulatingIssueConsumer.Accept(String path, IEnumerable`1 issues)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.CLangAnalyzer.HandleMessage(Message message, Request request, IIssueConsumer consumer, Int32& issueCount)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.CLangAnalyzer.<>c__DisplayClass12_0.<TriggerAnalysisAsync>b__0(Message message)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.Protocol.Read(BinaryReader reader, Action`1 handleIssue, String issueFilePath)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.CFamilyHelper.<>c__DisplayClass8_1.<CallClangAnalyzer>b__1(StreamReader reader)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.ProcessRunner.Execute(ProcessRunnerArguments runnerArgs)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.CFamilyHelper.CallClangAnalyzer(Action`1 handleMessage, Request request, IProcessRunner runner, IAnalysisStatusNotifier statusNotifier, ILogger logger, CancellationToken cancellationToken)
Found 1 issue(s) for C:\path\to\MyFile.cpp
ERROR: LLVM ERROR: IO failure on output stream: invalid argument
Checking for suppressions...
Number of suppressions found: 0

And the Error List window shows nothing to do with SonarLint in it.

I was able to generate a sonar-cfamily.reproducer file but I’m unable to attach it because the C++ source code is proprietary. Sorry.

Thanks @cacti77, I opened an issue that you can track. We’ll investigate and keep you posted.

Great - thanks @rita.g! I’ve subscribed to that issue. Until this is fixed we’ll have to rely on SonarQube scans via Azure DevOps to scan our code, so fixing this in Visual Studio soon will be very helpful.

I see as a workaround you can disable FIPs. Is this how you do it in Windows 10 - https://docs.trendmicro.com/all/ent/sc/v3.0/en-US/cmcolh/t_fips.html#:~:text=In%20Security%20Settings%2C%20expand%20Local,signing%2C%20and%20then%20click%20Disabled. ? I’ll still need to check if we’re allowed to do this by our corporate security admins though.

Yes. We know it’s not ideal and we will see what we can do regarding fixing the root cause.

@cacti77 would you mind downloading and installing a test build and checking if it solves the problem?

@rita.g I can try. Should I uninstall the SonarLint extension I downloaded from the Online Marketplace first? And then how do I get Studio to use the SonarLint.VSIX-4.24.0.19720-2019.vsix file you sent me?

Ok, I didn’t uninstall the old StudioLint from Studio. I just double-clicked on the *-2019.vsix file to install it. Under Manage Extensions it confirmed the version was 4.24.0.19720. Then when I saved the same C++ file as before I got this stacktrace in the SonarLint output window:

Failed to analyze C:\path\to\MyFile.cpp, exception details: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.
   at System.Security.Cryptography.MD5CryptoServiceProvider..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Security.Cryptography.CryptoConfig.CreateFromName(String name, Object[] args)
   at System.Security.Cryptography.MD5.Create()
   at SonarLint.VisualStudio.Integration.Suppression.ChecksumCalculator.Calculate(String text)
   at SonarLint.VisualStudio.Integration.Vsix.IssueToIssueMarkerConverter.Convert(IAnalysisIssue issue, ITextSnapshot textSnapshot)
   at SonarLint.VisualStudio.Integration.Vsix.AccumulatingIssueConsumer.<Accept>b__8_0(IAnalysisIssue x)
   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at SonarLint.VisualStudio.Integration.Vsix.AccumulatingIssueConsumer.Accept(String path, IEnumerable`1 issues)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.CLangAnalyzer.HandleMessage(Message message, Request request, IIssueConsumer consumer, Int32& issueCount)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.CLangAnalyzer.<>c__DisplayClass12_0.<TriggerAnalysisAsync>b__0(Message message)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.Protocol.Read(BinaryReader reader, Action`1 handleIssue, String issueFilePath)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.CFamilyHelper.<>c__DisplayClass8_1.<CallClangAnalyzer>b__1(StreamReader reader)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.ProcessRunner.Execute(ProcessRunnerArguments runnerArgs)
   at SonarLint.VisualStudio.Integration.Vsix.CFamily.CFamilyHelper.CallClangAnalyzer(Action`1 handleMessage, Request request, IProcessRunner runner, IAnalysisStatusNotifier statusNotifier, ILogger logger, CancellationToken cancellationToken)

This looks very similar, if not identical, to the original stacktrace.

Thanks for testing @cacti77, I appreciate it. Would you mind trying this build ? I believe it should work now.
And yes, as you wrote above, you don’t need to uninstall, just double-click it and your extension will update.

@rita.g Thank you! I’m pleased to report that build 4.24.0.19758 seems to work fine:).

Analyzing C:\path\to\MyFile.cpp
Finished analyzing C:\path\to\MyFile.cpp, analysis time: 0.529s
Found 139 issue(s) for C:\path\to\MyFile.cpp

…and I see green squiggly lines in the file editor pane and new issues listed in the Error List pane.

So when will you be able to update the official SonarLint build in the marketplace so I can tell my colleagues it’s ok to download?

That’s great! Thanks a lot for testing it. We don’t have an ETA yet for the release, please keep an eye on the github issue for further updates. I’ve also updated it to include another workaround, which is modifying Visual Studio’s config file devenv.exe.config and disabling the exception.

Hi @rita.g. Ok thanks. Hopefully the release will be soon. Thanks for the other workaround - I’ll consider that too but, as VS updates fairly regularly, that could get tedious to have to repeatedly edit devenv.exe.config. Studio v16.6.4 is already being pushed out. I’ll probably update to that if you’re sure I don’t need to do any more testing on v16.6.3 for you…?

1 Like

Nope, all good. Thank you very much! :slight_smile:

FYI, a version with the fix has been released.

1 Like