@@ -31,11 +31,13 @@ public class NuGetComponentDetector : FileComponentDetector
3131
3232 private readonly IList < string > repositoryPathKeyNames = new List < string > { "repositorypath" , "globalpackagesfolder" } ;
3333
34+ private static readonly IEnumerable < string > LowConfidencePackages = new [ ] { "Newtonsoft.Json" } ;
35+
3436 protected override async Task OnFileFound ( ProcessRequest processRequest , IDictionary < string , string > detectorArgs )
3537 {
3638 var stream = processRequest . ComponentStream ;
3739 bool ignoreNugetConfig = detectorArgs . TryGetValue ( "NuGet.IncludeRepositoryPaths" , out string includeRepositoryPathsValue ) && includeRepositoryPathsValue . Equals ( bool . FalseString , StringComparison . OrdinalIgnoreCase ) ;
38-
40+
3941 if ( NugetConfigFileName . Equals ( stream . Pattern , StringComparison . OrdinalIgnoreCase ) )
4042 {
4143 await ProcessAdditionalDirectory ( processRequest , ignoreNugetConfig ) ;
@@ -50,7 +52,7 @@ private async Task ProcessAdditionalDirectory(ProcessRequest processRequest, boo
5052 {
5153 var singleFileComponentRecorder = processRequest . SingleFileComponentRecorder ;
5254 var stream = processRequest . ComponentStream ;
53-
55+
5456 if ( ! ignoreNugetConfig )
5557 {
5658 var additionalPaths = GetRepositoryPathsFromNugetConfig ( stream ) ;
@@ -106,7 +108,7 @@ private async Task ProcessFile(ProcessRequest processRequest)
106108 string name = metadataNode [ "id" ] . InnerText ;
107109 string version = metadataNode [ "version" ] . InnerText ;
108110
109- string [ ] authors = metadataNode [ "authors" ] ? . InnerText . Split ( "," ) . Select ( author => author . Trim ( ) ) . ToArray ( ) ;
111+ string [ ] authors = metadataNode [ "authors" ] ? . InnerText . Split ( "," ) . Select ( author => author . Trim ( ) ) . ToArray ( ) ;
110112
111113 if ( ! NuGetVersion . TryParse ( version , out NuGetVersion parsedVer ) )
112114 {
@@ -116,7 +118,10 @@ private async Task ProcessFile(ProcessRequest processRequest)
116118 }
117119
118120 NuGetComponent component = new NuGetComponent ( name , version , authors ) ;
119- singleFileComponentRecorder . RegisterUsage ( new DetectedComponent ( component ) ) ;
121+ if ( ! LowConfidencePackages . Contains ( name , StringComparer . OrdinalIgnoreCase ) )
122+ {
123+ singleFileComponentRecorder . RegisterUsage ( new DetectedComponent ( component ) ) ;
124+ }
120125 }
121126 catch ( Exception e )
122127 {
0 commit comments