Skip to content

Commit 8952df2

Browse files
committed
C#: Inherited feeds may not get properly computed if a nuget.config file contains a clear. This has been fixed.
1 parent 9987b93 commit 8952df2

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,9 +1003,13 @@ private IEnumerable<string> GetFeeds(Func<IList<string>> getNugetFeeds)
10031003
// Add all explicitFeeds to the set of all feeds.
10041004
allFeeds.UnionWith(explicitFeeds);
10051005

1006+
// Obtain the list of feeds from the root source directory.
1007+
// If a NuGet file is present it will be respected, otherwise we will just get the machine/environment specific feeds.
1008+
var nugetFeedsFromRoot = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(fileProvider.SourceDir.FullName));
1009+
allFeeds.UnionWith(nugetFeedsFromRoot);
1010+
10061011
if (nugetConfigs.Count > 0)
10071012
{
1008-
// We don't have to get the feeds from each of the folders from below, it would be enought to check the folders that recursively contain the others.
10091013
var nugetConfigFeeds = nugetConfigs
10101014
.Select(GetDirectoryName)
10111015
.Where(folder => folder != null)
@@ -1014,12 +1018,6 @@ private IEnumerable<string> GetFeeds(Func<IList<string>> getNugetFeeds)
10141018

10151019
allFeeds.UnionWith(nugetConfigFeeds);
10161020
}
1017-
else
1018-
{
1019-
// If we haven't found any `nuget.config` files, then obtain a list of feeds from the root source directory.
1020-
var nugetFeedsFromRoot = GetFeeds(() => dotnet.GetNugetFeedsFromFolder(fileProvider.SourceDir.FullName));
1021-
allFeeds.UnionWith(nugetFeedsFromRoot);
1022-
}
10231021

10241022
logger.LogInfo($"Found {allFeeds.Count} NuGet feeds (with inherited ones) in nuget.config files: {string.Join(", ", allFeeds.OrderBy(f => f))}");
10251023

0 commit comments

Comments
 (0)