Allow DefaultOff detectors to be filtered and run exclusively - #1867
Open
RKS (rksharma-owg) wants to merge 1 commit into
Open
RKS (rksharma-owg) wants to merge 1 commit into
RKS (rksharma-owg) wants to merge 1 commit into
Conversation
Explicitly enabled or filtered DefaultOff detectors were previously removed from the detector list before filter restrictions were applied. This caused an InvalidDetectorFilterException when attempting to run a DefaultOff detector exclusively via --DetectorsFilter or AllowedDetectorIds. This change brings explicitly enabled or requested DefaultOff detectors into the candidate pool prior to applying allowed detector and category filters, allowing them to be run exclusively and subject to normal category and ID filtering.
RKS (rksharma-owg)
requested review from
Ryan Brandenburg (ryanbrandenburg)
and
a lite review from Copilot
September 17, 2026 03:34
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the stated requirements and is covered by focused tests.
Pull request overview
Updates detector restriction handling so DefaultOff detectors can be explicitly enabled or selected exclusively through detector filters while still respecting category filters.
Changes:
- Includes matching DefaultOff detectors before ID/category filtering with case-insensitive matching.
- Removes the trailing union that bypassed filters.
- Adds comprehensive restriction-service tests.
File summaries
| File | Description |
|---|---|
src/Microsoft.ComponentDetection.Orchestrator/Services/DetectorRestrictionService.cs |
Corrects DefaultOff detector inclusion and filtering order. |
test/Microsoft.ComponentDetection.Orchestrator.Tests/Services/DetectorRestrictionServiceTests.cs |
Tests exclusive selection, case handling, and filter exclusion behavior. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allows
DefaultOffdetectors to be filtered and run exclusively via--DetectorsFilterand/or--DetectorArgs <DetectorId>=EnableIfDefaultOff.Fixes #1457
Problem
In
DetectorRestrictionService.ApplyRestrictions, all detectors implementingIDefaultOffComponentDetectorwere removed from the candidatedetectorslist beforeAllowedDetectorIds(specified via--DetectorsFilter) orAllowedDetectorCategorieswere evaluated:--DetectorsFilter <DefaultOffDetector>(with or without--DetectorArgs <DefaultOffDetector>=EnableIfDefaultOff),detectors.Where(d => allowedIds.Contains(...))resulted in an empty match because the detector had already been stripped.InvalidDetectorFilterException: Detector '<DetectorId>' was not found.ExplicitlyEnabledDetectorIdswas located at the very end ofApplyRestrictions, meaning it was never reached when--DetectorsFilterwas provided, and if reached without--DetectorsFilter, bypassed any category filtering.Solution
DetectorRestrictionService.ApplyRestrictions, identify and add anyDefaultOffdetectors that are present inrestrictions.ExplicitlyEnabledDetectorIdsorrestrictions.AllowedDetectorIds(using case-insensitive comparison) intodetectorsbefore applying theAllowedDetectorIdsandAllowedDetectorCategoriesfilters.ApplyRestrictionsso that explicitly enabled detectors are subject to the normal filtering pipeline.Tests
Added comprehensive test cases to
DetectorRestrictionServiceTests:WithRestrictions_AllowsDefaultOffWhenFilteredExclusively: verifies a DefaultOff detector can be filtered exclusively with bothAllowedDetectorIdsandExplicitlyEnabledDetectorIds.WithRestrictions_AllowsDefaultOffWhenInAllowedDetectorIds: verifies a DefaultOff detector is allowed when requested viaAllowedDetectorIds.WithRestrictions_AllowsDefaultOffCaseInsensitive: verifies case-insensitive handling of detector IDs.WithRestrictions_DefaultOffFilteredOutWhenOtherDetectorRequested: verifies DefaultOff detector is excluded if a different detector is filtered.WithRestrictions_DefaultOffFilteredOutWhenCategoryDoesNotMatch: verifies DefaultOff detector is excluded if category filter does not match.