dotnet-security-guard / roslyn-security-guard

Roslyn analyzers that aim to help security audit on .NET applications.
https://dotnet-security-guard.github.io
GNU Lesser General Public License v3.0
208 stars 38 forks source link

System.ArgumentException : An item with the same key has already been added. #101

Open jakubsuchybio opened 6 years ago

jakubsuchybio commented 6 years ago

Description: Given I have more SG0018 Path Traversal errors When I try to suppress then Solution wide Then I get this exception from you extension:

System.ArgumentException : An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key,TValue value,Boolean add)
   at async Microsoft.CodeAnalysis.CodeFixes.Suppression.AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.BatchPragmaFixesAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionInternalAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeFixes.BatchFixAllProvider.GetChangedDocumentsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeFixes.BatchFixAllProvider.GetDocumentIdToChangedDocuments(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeFixes.BatchFixAllProvider.TryMergeFixesAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeFixes.BatchFixAllProvider.TryGetMergedFixAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeFixes.BatchFixAllProvider.GetFixAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeFixes.Suppression.AbstractSuppressionCodeFixProvider.SuppressionFixAllProvider.GetFixAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.FixAllGetFixesService.GetFixAllCodeActionAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.FixAllGetFixesService.GetFixAllOperationsAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetOperationsCoreAsync(<Unknown Parameters>)
   at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetOperationsAsync(<Unknown Parameters>)
   at Roslyn.Utilities.TaskExtensions.WaitAndGetResult_CanCallOnBackground[T](Task`1 task,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InvokeWorker(Func`1 getFromDocument,IProgressTracker progressTracker,CancellationToken cancellationToken)
   at Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.<>c__DisplayClass18_0.<InvokeCore>b__0()
   at Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformAction(IExtensionManager extensionManager,Object extension,Action action)
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

Repro:

  1. Having like 8 SG0018 Path traversal Errors
  2. From editor, show code suggestion and suppress SG0018 In Source on Solution
  3. Verify that you got the exception: