-
Notifications
You must be signed in to change notification settings - Fork 113
Add support for NuGet components in containers #1548
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
Conversation
|
👋 Hi! It looks like you modified some files in the
If none of the above scenarios apply, feel free to ignore this comment 🙂 |
6b57052 to
919da3a
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1548 +/- ##
=======================================
- Coverage 89.6% 89.5% -0.1%
=======================================
Files 426 427 +1
Lines 36256 36270 +14
Branches 2260 2262 +2
=======================================
+ Hits 32493 32497 +4
- Misses 3300 3311 +11
+ Partials 463 462 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR adds support for detecting NuGet packages in container images by extending the Linux container detector functionality. It builds on the infrastructure added in PR #1529 to support additional package ecosystems in container scans.
- Introduces
DotnetComponentFactoryto create NuGet components from Syft artifact output - Updates
LinuxContainerDetectorto include NuGet in supported categories and component types - Registers the new factory in the DI container for integration with the scanning pipeline
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs | Registers DotnetComponentFactory in the DI container alongside other artifact component factories |
| src/Microsoft.ComponentDetection.Detectors/linux/LinuxContainerDetector.cs | Adds NuGet to the detector's supported categories and component types |
| src/Microsoft.ComponentDetection.Detectors/linux/Factories/DotnetComponentFactory.cs | New factory that creates NuGetComponent instances from dotnet artifact types detected by Syft |
Comments suppressed due to low confidence (1)
src/Microsoft.ComponentDetection.Detectors/linux/Factories/DotnetComponentFactory.cs:37
- The new
DotnetComponentFactoryshould be added to thecomponentFactorieslist in theLinuxScannerTeststest constructor to ensure it's included in test coverage. Currently, onlyLinuxComponentFactory,NpmComponentFactory, andPipComponentFactoryare included in the tests. The factory should be added to match the pattern used for the other component factories.
This would ensure that tests like TestLinuxScanner_SupportsMultipleComponentTypes_Async can properly test dotnet artifacts alongside other component types.
public class DotnetComponentFactory : ArtifactComponentFactoryBase
{
/// <inheritdoc/>
public override IEnumerable<string> SupportedArtifactTypes => ["dotnet"];
/// <inheritdoc/>
public override TypedComponent? CreateComponent([NotNull] ArtifactElement artifact, [NotNull] Distro distro)
{
if (string.IsNullOrWhiteSpace(artifact.Name) || string.IsNullOrWhiteSpace(artifact.Version))
{
return null;
}
var author = GetAuthorFromArtifact(artifact);
var authors = string.IsNullOrWhiteSpace(author) ? null : new[] { author };
return new NuGetComponent(
name: artifact.Name,
version: artifact.Version,
authors: authors);
}
}
919da3a to
098b031
Compare
This extends on the support added in #1529 to support detection of NuGet packages in containers.
As an example, I ran
Which gave the output here