-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C#: Check fallback nuget feeds before trying to use them in the fallb… #16164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C#: Check fallback nuget feeds before trying to use them in the fallb… #16164
Conversation
catch (Exception exc) | ||
{ | ||
logger.LogWarning($"Failed to get directory of '{config}': {exc}"); | ||
} |
Check notice
Code scanning / CodeQL
Generic catch clause
@@ -32,6 +33,12 @@ | |||
return Success; | |||
} | |||
|
|||
public bool RunCommand(string args, string? workingDirectory, out IList<string> output) |
Check notice
Code scanning / CodeQL
Local scope variable shadows member
Ahh, the test failure is due to the way we test for timeouts:
|
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.Nuget.cs
Show resolved
Hide resolved
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.Nuget.cs
Show resolved
Hide resolved
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.Nuget.cs
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
private HashSet<string> GetAllFeeds(List<FileInfo> allFiles) | ||
private (HashSet<string>, HashSet<string>) GetAllFeeds(List<FileInfo> allFiles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even though this method is private, maybe add some description of the return since it is a tuple of hashsets of the same type (to avoid confusing them)
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.Nuget.cs
Outdated
Show resolved
Hide resolved
csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.Nuget.cs
Outdated
Show resolved
Hide resolved
return feeds; | ||
|
||
// todo: this could be improved. | ||
// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you are thinking of removing all folder paths that are prefixes of other path before calling the CLI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be an option. (But I won't do it for the time being, as it would add extra complexity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Added some minor questions and comments.
1fdabcb
to
c004f92
Compare
@michaelnebel I've applied your suggestions and rebased the PR. |
logger.LogInfo($"Getting Nuget feeds from '{nugetConfig}'..."); | ||
return dotnet.GetNugetFeeds(nugetConfig); | ||
} | ||
IList<string> GetNugetFeeds(string nugetConfig) => dotnet.GetNugetFeeds(nugetConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just call dotnet.GetNugetFeeds
directly instead of declaring a local function (same comment below).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @tamasvajk !
I just saw the comment https://github.com/github/codeql-csharp-team/issues/432#issuecomment-2051098433 |
There are definitely ways to improve this. Let's get some feedback from the field team before tackling it. |
…ack restore process
This PR is improving the fallback nuget restore process by checking if the used nuget feeds are reachable or not. Currently the fallback restore process doesn't use a
nuget.config
file. This PR is changing this. The generatednuget.config
uses the reachable fallback feeds in the<packageSources>
. Additionally, we're logging the nuget feeds that are inherited from the user levelnuget.config
, but we're not (yet) checking their reachability.