Add application-layer Syft factories for 6 new ecosystems#1632
Add application-layer Syft factories for 6 new ecosystems#1632JamieMagee merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for 6 new ecosystems (RubyGems, Go, Cargo/Rust, CocoaPods, Conda, and Maven) to the Linux container scanner by creating artifact component factories that parse Syft output. The PR also refactors the LinuxScanner to build factory lookups dynamically instead of using hardcoded mappings.
Changes:
- Added
SupportedComponentTypeproperty toIArtifactComponentFactoryinterface to enable dynamic factory-to-component-type mapping - Created 6 new factory classes to parse Syft artifacts for RubyGems, Go, Cargo, CocoaPods, Conda, and Maven ecosystems
- Refactored
LinuxScannerto build bothartifactTypeToFactoryLookupandcomponentTypeToFactoryLookupdictionaries dynamically using LINQ - Updated
LinuxApplicationLayerDetectorto include all 6 new ecosystems in its categories and supported component types - Added 32 unit tests covering the new factories with various scenarios (happy path, null checks, empty string validation, metadata extraction)
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/Microsoft.ComponentDetection.Detectors/linux/Factories/IArtifactComponentFactory.cs |
Added SupportedComponentType property to the interface to enable dynamic factory lookup |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/ArtifactComponentFactoryBase.cs |
Added abstract SupportedComponentType property that derived classes must implement |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/LinuxComponentFactory.cs |
Implemented SupportedComponentType property returning ComponentType.Linux |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/NpmComponentFactory.cs |
Implemented SupportedComponentType property returning ComponentType.Npm and minor formatting cleanup |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/PipComponentFactory.cs |
Implemented SupportedComponentType property returning ComponentType.Pip and minor formatting cleanup |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/DotnetComponentFactory.cs |
Implemented SupportedComponentType property returning ComponentType.NuGet |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/RubyGemsComponentFactory.cs |
New factory for creating RubyGemsComponent instances from "gem" artifacts with source extraction |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/GoComponentFactory.cs |
New factory for creating GoComponent instances from "go-module" artifacts with optional H1 digest hash |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/CargoComponentFactory.cs |
New factory for creating CargoComponent instances from "rust-crate" artifacts with author/license/source metadata |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/PodComponentFactory.cs |
New factory for creating PodComponent instances from "pod" artifacts |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/CondaComponentFactory.cs |
New factory for creating CondaComponent instances from "conda" artifacts with build/channel/subdir/md5 metadata |
src/Microsoft.ComponentDetection.Detectors/linux/Factories/MavenComponentFactory.cs |
New factory for creating MavenComponent instances from "java-archive" artifacts with multiple fallback strategies for extracting Maven coordinates |
src/Microsoft.ComponentDetection.Detectors/linux/LinuxScanner.cs |
Refactored to build factory lookup dictionaries dynamically using LINQ instead of hardcoded mappings; renamed factoryLookup to artifactTypeToFactoryLookup for clarity |
src/Microsoft.ComponentDetection.Detectors/linux/LinuxApplicationLayerDetector.cs |
Updated to include all 6 new ecosystems in Categories and SupportedComponentTypes; updated documentation |
src/Microsoft.ComponentDetection.Detectors/linux/LinuxContainerDetector.cs |
Minor code formatting improvements (line breaking) |
src/Microsoft.ComponentDetection.Orchestrator/Extensions/ServiceCollectionExtensions.cs |
Registered all 6 new factories in the DI container |
test/Microsoft.ComponentDetection.Detectors.Tests/ArtifactComponentFactoryTests.cs |
Added 32 comprehensive unit tests covering all new factories with various scenarios |
test/Microsoft.ComponentDetection.Detectors.Tests/ArtifactComponentFactoryTests.cs
Show resolved
Hide resolved
test/Microsoft.ComponentDetection.Detectors.Tests/ArtifactComponentFactoryTests.cs
Show resolved
Hide resolved
src/Microsoft.ComponentDetection.Detectors/linux/Factories/CargoComponentFactory.cs
Show resolved
Hide resolved
test/Microsoft.ComponentDetection.Detectors.Tests/ArtifactComponentFactoryTests.cs
Show resolved
Hide resolved
src/Microsoft.ComponentDetection.Detectors/linux/Factories/GoComponentFactory.cs
Show resolved
Hide resolved
test/Microsoft.ComponentDetection.Detectors.Tests/ArtifactComponentFactoryTests.cs
Show resolved
Hide resolved
test/Microsoft.ComponentDetection.Detectors.Tests/ArtifactComponentFactoryTests.cs
Show resolved
Hide resolved
08b3aee to
cd8d49a
Compare
|
👋 Hi! It looks like you modified some files in the
If none of the above scenarios apply, feel free to ignore this comment 🙂 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1632 +/- ##
======================================
Coverage 90.7% 90.8%
======================================
Files 444 451 +7
Lines 39710 40148 +438
Branches 2418 2443 +25
======================================
+ Hits 36030 36460 +430
- Misses 3187 3188 +1
- Partials 493 500 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Adds factory classes so the Linux container scanner can detect RubyGems, Go, Cargo (Rust), CocoaPods, Conda, and Maven components from Syft output.
Changes: