-
Notifications
You must be signed in to change notification settings - Fork 90
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
feat: add a new detector MvnPomCliComponentDetector
#544
base: main
Are you sure you want to change the base?
Conversation
This detector just finds all the .pom files and parses the dependencies (which are present similar to maven structure like<dependency> </dependency>) in those files. It does a simple text parsing and does not create the dependency graph.
using Microsoft.ComponentDetection.Contracts.TypedComponent; | ||
using Microsoft.Extensions.Logging; | ||
|
||
public class MvnPomCliComponentDetector : FileComponentDetector |
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.
Could you also implement IDefaultOffComponentDetector
? We don't want a new detector to be enabled by default (only explicitly opted-in) before we've had the chance to fully verify it correctly works.
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.
Done
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.
MavenPomComponentDetector
is marked IDefaultOffComponenDetector
, but MvnPomCliComponentDetector
is not
src/Microsoft.ComponentDetection.Detectors/maven/MvnPomCliComponentDetector.cs
Show resolved
Hide resolved
src/Microsoft.ComponentDetection.Detectors/maven/MvnPomCliComponentDetector.cs
Show resolved
Hide resolved
src/Microsoft.ComponentDetection.Detectors/maven/MvnPomCliComponentDetector.cs
Show resolved
Hide resolved
src/Microsoft.ComponentDetection.Detectors/maven/MvnPomCliComponentDetector.cs
Show resolved
Hide resolved
Thanks for the contribution! I left some feedback on your PR. We also need unit tests to verify this new detector. You can view an example here |
…es (Just the deps in the pom files will be read as components) along with one implementation (MavenFileParserService) that is being used in MavenPomCliComponentDetector. Renamed MavenPomCliComponentDetector to MavenPomComponentDetector Added test case (MavenPomComponentDetectorTest.cs) for the new detector class MavenPomComponentDetector.
@AbhinavAbhinav11 what the need for this detector have over the |
} | ||
} | ||
|
||
private void RegisterComponent(XmlNode node, XmlNamespaceManager nsmgr, ISingleFileComponentRecorder singleFileComponentRecorder) |
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.
This method looks the same as RegisterComponent(XmlNode node, XmlNamespaceManager nsmgr, ISingleFileComponentRecorder singleFileComponentRecorder)
in MavenFileParserService
. We should refactor this and DRY.
using Microsoft.ComponentDetection.Contracts.TypedComponent; | ||
using Microsoft.Extensions.Logging; | ||
|
||
public class MvnPomCliComponentDetector : FileComponentDetector |
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.
MavenPomComponentDetector
is marked IDefaultOffComponenDetector
, but MvnPomCliComponentDetector
is not
@@ -97,6 +97,8 @@ public static IServiceCollection AddComponentDetection(this IServiceCollection s | |||
services.AddSingleton<IMavenCommandService, MavenCommandService>(); | |||
services.AddSingleton<IMavenStyleDependencyGraphParserService, MavenStyleDependencyGraphParserService>(); | |||
services.AddSingleton<IComponentDetector, MvnCliComponentDetector>(); | |||
services.AddSingleton<IMavenFileParserService, MavenFileParserService>(); | |||
services.AddSingleton<IComponentDetector, MavenPomComponentDetector>(); |
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.
Missing MvnPomCliComponentDetector
?
MvnPomCliComponentDetector
This detector just finds all the .pom files and parses the dependencies (which are present similar to maven structure like ) in those files. It does a simple text parsing and does not create the dependency graph.