-
Notifications
You must be signed in to change notification settings - Fork 130
Users/zhentan/test branch #1757
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -59,11 +59,11 @@ internal enum MavenFallbackReason | |||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||||||
| /// Experimental Maven detector that combines MvnCli detection with static pom.xml parsing fallback. | ||||||||||||||||||||||||||||||||||||||||||||||
| /// Runs MvnCli detection first (like standard MvnCliComponentDetector), then checks if detection | ||||||||||||||||||||||||||||||||||||||||||||||
| /// produced any results. If MvnCli fails for any pom.xml, falls back to static parsing for failed files. | ||||||||||||||||||||||||||||||||||||||||||||||
| /// Maven detector that combines MvnCli detection with static pom.xml parsing fallback. | ||||||||||||||||||||||||||||||||||||||||||||||
| /// Runs MvnCli detection first, then checks if detection produced any results. | ||||||||||||||||||||||||||||||||||||||||||||||
| /// If MvnCli fails for any pom.xml, falls back to static parsing for failed files. | ||||||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||||||
| public class MavenWithFallbackDetector : FileComponentDetector, IExperimentalDetector | ||||||||||||||||||||||||||||||||||||||||||||||
| public class MvnCliComponentDetector : FileComponentDetector | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
| public class MvnCliComponentDetector : FileComponentDetector | |
| public class MvnCliComponentDetector : FileComponentDetector, IExperimentalDetector |
Copilot
AI
Apr 2, 2026
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.
Id was changed to MavenConstants.MvnCliDetectorId, which is already used by the existing MvnCliComponentDetector. Detector IDs need to be unique; sharing an ID can cause incorrect detector restriction behavior, ambiguous telemetry, and also affects Maven temp-file cleanup logic that checks detector IDs. Use a distinct ID (e.g., MavenWithFallbackDetectorId) for this detector, or remove the other detector if this is intended as a replacement.
Copilot
AI
Apr 2, 2026
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.
Version was bumped from 2 to 5 here. Version changes can affect cache/telemetry/baseline comparisons and should typically be incremented only when the detector’s output semantics change. Please confirm this new version is intentional (and consistent with the actual detector identity/ID), otherwise keep the prior version number.
| public override int Version => 5; | |
| public override int Version => 2; |
Copilot
AI
Apr 2, 2026
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.
Deleting bcde.mvndeps inside OnFileFoundAsync can race with other Maven detectors because detectors run concurrently (Task.WhenAll in the orchestrator). The other MvnCliComponentDetector enumerates these files during its prepare phase; if this detector deletes them early, the other detector can miss them and return incomplete results. Prefer leaving cleanup to the orchestrator-level CleanupMavenFiles that runs after all detectors finish, or coordinate deletion in a way that can’t affect other detectors.
| // Process MvnCli result | |
| this.ProcessMvnCliResult(processRequest); | |
| // Delete the deps file now that its content has been consumed (was read into MemoryStream during prepare phase) | |
| if (this.CurrentScanRequest?.CleanupCreatedFiles == true) | |
| { | |
| var filePath = processRequest.ComponentStream.Location; | |
| try | |
| { | |
| this.fileUtilityService.Delete(filePath); | |
| this.Logger.LogDebug("Cleaned up Maven deps file {File}", filePath); | |
| } | |
| catch (Exception e) | |
| { | |
| this.Logger.LogDebug(e, "Failed to delete Maven deps file {File}", filePath); | |
| } | |
| } | |
| // Process MvnCli result. | |
| // Do not delete the generated deps file here because Maven detectors run concurrently, | |
| // and other detectors may still need to enumerate or consume it. | |
| // Cleanup is handled after detector execution completes. | |
| this.ProcessMvnCliResult(processRequest); |
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 file now declares
public class MvnCliComponentDetector, but the repo already hassrc/Microsoft.ComponentDetection.Detectors/maven/MvnCliComponentDetector.csdefining the same public type. This will fail to compile due to a duplicate type, and it also removes theMavenWithFallbackDetectortype that is still referenced elsewhere (e.g., DI registration). Please keep this detector asMavenWithFallbackDetector(with a unique name), or rename/remove the existingMvnCliComponentDetectorand update all references accordingly.