Skip to content

Commit b5ce4a8

Browse files
committed
C#: Also apply feed exclusions to inherited feeds.
1 parent 81df3fc commit b5ce4a8

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,11 @@ public HashSet<AssemblyLookupLocation> Restore()
137137
compilationInfoContainer.CompilationInfos.Add(("Inherited NuGet feed count", inheritedFeeds.Count.ToString()));
138138
}
139139

140-
if (!CheckSpecifiedFeeds(explicitFeeds, out var reachableFeeds))
140+
var timeout = CheckSpecifiedFeeds(explicitFeeds, out var reachableFeeds);
141+
var allReachable = explicitFeeds.Count == reachableFeeds.Count;
142+
EmitUnreachableFeedsDiagnostics(allReachable);
143+
144+
if (timeout)
141145
{
142146
// If we experience a timeout, we use this fallback.
143147
// todo: we could also check the reachability of the inherited nuget feeds, but to use those in the fallback we would need to handle authentication too.
@@ -148,7 +152,8 @@ public HashSet<AssemblyLookupLocation> Restore()
148152
}
149153

150154
// Inherited feeds should only be used, if they are indeed reachable (as they may be environment specific).
151-
reachableFeeds.UnionWith(GetReachableNuGetFeeds(inheritedFeeds, isFallback: false, out var _));
155+
CheckSpecifiedFeeds(inheritedFeeds, out var reachableInheritedFeeds);
156+
reachableFeeds.UnionWith(reachableInheritedFeeds);
152157

153158
// If feed responsiveness is being checked, we only want to use the feeds that are reachable (note this set includes private
154159
// registry feeds if they are reachable).
@@ -803,7 +808,7 @@ private HashSet<string> GetExcludedFeeds()
803808
/// <param name="feeds">The set of package feeds to check.</param>
804809
/// <param name="reachableFeeds">The list of feeds that were reachable.</param>
805810
/// <returns>
806-
/// True if there is no timeout when trying to reach the feeds (excluding any feeds that are configured
811+
/// True if there is a timeout when trying to reach the feeds (excluding any feeds that are configured
807812
/// to be excluded from the check) or false otherwise.
808813
/// </returns>
809814
private bool CheckSpecifiedFeeds(HashSet<string> feeds, out HashSet<string> reachableFeeds)
@@ -823,13 +828,11 @@ private bool CheckSpecifiedFeeds(HashSet<string> feeds, out HashSet<string> reac
823828
}).ToHashSet();
824829

825830
reachableFeeds = GetReachableNuGetFeeds(feedsToCheck, isFallback: false, out var isTimeout).ToHashSet();
826-
var allReachable = reachableFeeds.Count == feedsToCheck.Count;
827-
EmitUnreachableFeedsDiagnostics(allReachable);
828831

829832
// Always consider feeds excluded for the reachability check as reachable.
830833
reachableFeeds.UnionWith(feeds.Where(feed => excludedFeeds.Contains(feed)));
831834

832-
return !isTimeout;
835+
return isTimeout;
833836
}
834837

835838
/// <summary>

0 commit comments

Comments
 (0)