-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add support for Nuget lockfiles #497
base: main
Are you sure you want to change the base?
Conversation
foreach (var (name, value) in framework) | ||
{ | ||
var component = new NuGetComponent(name, value.Resolved); | ||
singleFileComponentRecorder.RegisterUsage(new DetectedComponent(component)); |
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.
Not sure if the team would want it included in this PR or not, but packages.lock.json supports reconstructing the whole component graph (see parentComponentId
docs link) by using the dependencies
property and also isExplicitlyReferencedDependency
(same doc link) through the type
property (is it Direct
or Transitive
).
@@ -105,6 +115,12 @@ private async Task ProcessFileAsync(ProcessRequest processRequest) | |||
else if ("paket.lock".Equals(stream.Pattern, StringComparison.OrdinalIgnoreCase)) | |||
{ | |||
this.ParsePaketLock(processRequest); | |||
return; |
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.
Fixed what seems like a small bug here; it would always continue to the "nuget bytes" parsing and throw a null reference exception which is then caught.
These have been supported since VS2017 but they are not yet parsed. The lockfile contains all transitive dependencies and does not require a build to be performed in order to be used.
I found that support for this was missing while investigating why our repo was not getting flagged for anything despite having transitive dependencies on packages with High- and Critical-level advisories. It turned out that Component Governance was not finding any dependencies at all, since the existing detectors require the project to be built first.
I've also added a simple test logger implementation when writing a test, since a mock logger is not very useful when tests fail.