Skip to content

Add option to exclude base image components#1825

Draft
jasonpaulos wants to merge 3 commits into
mainfrom
users/jasonpaulos/exclude-base-image
Draft

Add option to exclude base image components#1825
jasonpaulos wants to merge 3 commits into
mainfrom
users/jasonpaulos/exclude-base-image

Conversation

@jasonpaulos

Copy link
Copy Markdown
Member

Add a new option to exclude components which solely originate from the base image when scanning a container image.

Copilot AI review requested due to automatic review settings June 10, 2026 20:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 a new scan option to exclude components that originate exclusively from base image layers when scanning container images, integrating the filtering into scan result generation and validating behavior with new unit tests.

Changes:

  • Added --FilterBaseImageComponents to ScanSettings to enable base-image-only component filtering for container scans.
  • Implemented filtering logic in DefaultGraphTranslationService to remove components whose referenced container layers are all marked IsBaseImage.
  • Added orchestrator tests covering removal/retention scenarios for base-image-only, mixed-layer, and non-container components.
Show a summary per file
File Description
test/Microsoft.ComponentDetection.Orchestrator.Tests/Services/DefaultGraphTranslationServiceTests.cs Adds unit tests validating the new base-image component filtering behavior.
src/Microsoft.ComponentDetection.Orchestrator/Services/GraphTranslation/DefaultGraphTranslationService.cs Applies the new filtering option during scan result generation and introduces base-image-only detection logic.
src/Microsoft.ComponentDetection.Orchestrator/Commands/ScanSettings.cs Introduces the new CLI/settings flag FilterBaseImageComponents.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 6

@jasonpaulos jasonpaulos force-pushed the users/jasonpaulos/exclude-base-image branch from 32138d8 to f97ff44 Compare June 22, 2026 20:56
@jasonpaulos jasonpaulos requested a review from Copilot June 22, 2026 20:57
@github-actions

Copy link
Copy Markdown

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment on lines +44 to +49
var componentsToOutput = mergedComponents;
if (settings.FilterBaseImageComponents)
{
componentsToOutput = FilterOutBaseImageComponents(componentsToOutput, detectorProcessingResult.ContainersDetailsMap);
PruneFilteredComponentsFromGraphs(dependencyGraphs, componentsToOutput);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants