sbom-tool icon indicating copy to clipboard operation
sbom-tool copied to clipboard

Enhance RootPathFilter to support glob-style pattern matching

Open Copilot opened this issue 8 months ago • 13 comments

This PR enhances the existing RootPathFilter configuration to support glob-style pattern matching, helping 1ES PT seamlessly route files for validation when customers download pipeline artifacts.

Changes

Enhanced RootPathFilter

  • Modified existing RootPathFilter to automatically detect and support glob patterns
  • Supports common glob patterns:
    • * - matches any characters except path separators
    • ** - matches any characters including path separators (recursive)
  • Falls back to legacy path prefix matching when no glob patterns are detected
  • Maintains full backward compatibility - existing configurations continue to work unchanged

Pattern Matching Implementation

  • Implemented PathPatternMatcher utility class using .NET's built-in Microsoft.Extensions.FileSystemGlobbing
  • Cross-platform compatible (handles both Windows and Unix path separators)
  • Leverages Microsoft's well-tested globbing functionality for reliability

Documentation Updates

  • Updated help text in ValidationArgs.cs to document glob pattern support
  • Added comprehensive documentation in IConfiguration.cs comments
  • Clear indication of both legacy and new pattern matching capabilities

Example Usage

{
  "RootPathFilter": "src/**/*.cs;bin/*.dll;tests/**/test*.json"
}

Or with legacy path prefixes:

{
  "RootPathFilter": "src/;bin/"
}

This allows flexible file matching instead of rigid path prefix matching, enabling more precise control over which files are validated while maintaining full backward compatibility.

Backward Compatibility

  • All existing RootPathFilter configurations continue to work exactly as before
  • No breaking changes to the API or configuration format
  • Glob patterns are detected automatically - no configuration changes needed
  • Single configuration property handles both use cases seamlessly

Fixes #1040.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot avatar Jul 01 '25 22:07 Copilot

This PR changes files in the API project. Does it change any of the API interfaces in any way? Please note that this includes the following types of changes:

  • Changing the signature of an existing interface method
  • Adding a new method to an existing interface
  • Adding a required data member to a class that an existing interface method consumes

Because any of these changes can potentially break a downstream consumer with customized interface implementations, these changes need to be treated as breaking changes. Please do one of the following:

Option 1 - Publish this as a breaking change

  1. Update the documentation to show the new functionality
  2. Bump the major version in the next release
  3. Be sure to highlight the breaking changes in the release notes

Option 2 - Refactor the changes to be non-breaking

  1. Review this commit, which adds a new interface in a backward-compatible way
  2. Refactor the change to follow this pattern so that existing interfaces are left completely intact
  3. Bump the minor version in the next release

github-actions[bot] avatar Jul 02 '25 18:07 github-actions[bot]

/azp run

pragnya17 avatar Jul 02 '25 18:07 pragnya17

There are several PathPatternMatcher tests that are failing, can you diagnose and fix them?

pragnya17 avatar Jul 02 '25 20:07 pragnya17

There are several PathPatternMatcher tests that are failing, can you diagnose and fix them?

Fixed the PathPatternMatcher tests. The issue was with cross-platform path compatibility and improper handling of the double wildcard (**) pattern. The ** pattern now correctly matches zero or more directory segments, and all path handling is normalized for cross-platform compatibility. All PathPatternMatcher tests are now passing. Commit: b3b21d9

Copilot avatar Jul 02 '25 20:07 Copilot

/azp run

pragnya17 avatar Jul 02 '25 22:07 pragnya17

This PR changes files in the API project. Does it change any of the API interfaces in any way? Please note that this includes the following types of changes:

  • Changing the signature of an existing interface method
  • Adding a new method to an existing interface
  • Adding a required data member to a class that an existing interface method consumes

Because any of these changes can potentially break a downstream consumer with customized interface implementations, these changes need to be treated as breaking changes. Please do one of the following:

Option 1 - Publish this as a breaking change

  1. Update the documentation to show the new functionality
  2. Bump the major version in the next release
  3. Be sure to highlight the breaking changes in the release notes

Option 2 - Refactor the changes to be non-breaking

  1. Review this commit, which adds a new interface in a backward-compatible way
  2. Refactor the change to follow this pattern so that existing interfaces are left completely intact
  3. Bump the minor version in the next release

github-actions[bot] avatar Jul 09 '25 16:07 github-actions[bot]

This PR changes files in the API project. Does it change any of the API interfaces in any way? Please note that this includes the following types of changes:

  • Changing the signature of an existing interface method
  • Adding a new method to an existing interface
  • Adding a required data member to a class that an existing interface method consumes

Because any of these changes can potentially break a downstream consumer with customized interface implementations, these changes need to be treated as breaking changes. Please do one of the following:

Option 1 - Publish this as a breaking change

  1. Update the documentation to show the new functionality
  2. Bump the major version in the next release
  3. Be sure to highlight the breaking changes in the release notes

Option 2 - Refactor the changes to be non-breaking

  1. Review this commit, which adds a new interface in a backward-compatible way
  2. Refactor the change to follow this pattern so that existing interfaces are left completely intact
  3. Bump the minor version in the next release

github-actions[bot] avatar Jul 22 '25 18:07 github-actions[bot]

/azp run

pragnya17 avatar Jul 22 '25 19:07 pragnya17

I actually want to remove adding to the IConfiguration, and just modify the existing RootPathFilter to support the glob-style matching pattern. could you please do that>

pragnya17 avatar Jul 23 '25 18:07 pragnya17

This PR changes files in the API project. Does it change any of the API interfaces in any way? Please note that this includes the following types of changes:

  • Changing the signature of an existing interface method
  • Adding a new method to an existing interface
  • Adding a required data member to a class that an existing interface method consumes

Because any of these changes can potentially break a downstream consumer with customized interface implementations, these changes need to be treated as breaking changes. Please do one of the following:

Option 1 - Publish this as a breaking change

  1. Update the documentation to show the new functionality
  2. Bump the major version in the next release
  3. Be sure to highlight the breaking changes in the release notes

Option 2 - Refactor the changes to be non-breaking

  1. Review this commit, which adds a new interface in a backward-compatible way
  2. Refactor the change to follow this pattern so that existing interfaces are left completely intact
  3. Bump the minor version in the next release

github-actions[bot] avatar Jul 23 '25 18:07 github-actions[bot]

I actually want to remove adding to the IConfiguration, and just modify the existing RootPathFilter to support the glob-style matching pattern. could you please do that>

Done! I've refactored the implementation to remove the separate RootPathPatterns property and instead enhanced the existing RootPathFilter to support glob-style pattern matching automatically.

The RootPathFilter now:

  • Detects glob patterns (*, **, ?) automatically and switches to pattern matching mode
  • Falls back to legacy path prefix matching when no glob patterns are detected
  • Maintains full backward compatibility with existing configurations

All tests pass and the implementation is much cleaner with a single configuration property handling both use cases. Commit: 5fd117a

Copilot avatar Jul 23 '25 18:07 Copilot

This PR changes files in the API project. Does it change any of the API interfaces in any way? Please note that this includes the following types of changes:

  • Changing the signature of an existing interface method
  • Adding a new method to an existing interface
  • Adding a required data member to a class that an existing interface method consumes

Because any of these changes can potentially break a downstream consumer with customized interface implementations, these changes need to be treated as breaking changes. Please do one of the following:

Option 1 - Publish this as a breaking change

  1. Update the documentation to show the new functionality
  2. Bump the major version in the next release
  3. Be sure to highlight the breaking changes in the release notes

Option 2 - Refactor the changes to be non-breaking

  1. Review this commit, which adds a new interface in a backward-compatible way
  2. Refactor the change to follow this pattern so that existing interfaces are left completely intact
  3. Bump the minor version in the next release

github-actions[bot] avatar Jul 23 '25 20:07 github-actions[bot]

This PR changes files in the API project. Does it change any of the API interfaces in any way? Please note that this includes the following types of changes:

  • Changing the signature of an existing interface method
  • Adding a new method to an existing interface
  • Adding a required data member to a class that an existing interface method consumes

Because any of these changes can potentially break a downstream consumer with customized interface implementations, these changes need to be treated as breaking changes. Please do one of the following:

Option 1 - Publish this as a breaking change

  1. Update the documentation to show the new functionality
  2. Bump the major version in the next release
  3. Be sure to highlight the breaking changes in the release notes

Option 2 - Refactor the changes to be non-breaking

  1. Review this commit, which adds a new interface in a backward-compatible way
  2. Refactor the change to follow this pattern so that existing interfaces are left completely intact
  3. Bump the minor version in the next release

github-actions[bot] avatar Jul 23 '25 20:07 github-actions[bot]