Skip to content

Fix license scan exclusion regex to match ignore patterns at any depth - #6172

Merged
mthalman merged 1 commit into
dotnet:mainfrom
mthalman:dev/mthalman/license-scanning-exclusions-fix
Apr 21, 2026
Merged

mthalman merged 1 commit into
dotnet:mainfrom
mthalman:dev/mthalman/license-scanning-exclusions-fix

Conversation

@mthalman

Copy link
Copy Markdown
Member

The negative lookaheads for ignore patterns only checked the first path component after the repo root, but scancode --ignore matches directory names at any depth. For source-build-assets, exclusion paths like src/source-build-assets/src/externalPackages/... have an intermediate src/ directory, so the lookahead (?!externalPackages/) didn't filter them. Changed to (?!(?:.*/)?externalPackages/) to match at any depth.

This fixes the issue with source-build-assets paths being removed from the exclusions file.

Regression from #6009

The negative lookaheads for ignore patterns only checked the first path
component after the repo root, but scancode --ignore matches directory
names at any depth. For source-build-assets, exclusion paths like
src/source-build-assets/src/externalPackages/... have an intermediate
src/ directory, so the lookahead (?!externalPackages/) didn't filter
them. Changed to (?!(?:.*/)?externalPackages/) to match at any depth.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings April 21, 2026 17:14
@mthalman
mthalman requested review from a team as code owners April 21, 2026 17:14

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

Updates the license scan test’s exclusion-regex construction so additional --ignore directory patterns are treated as matching at any path depth (consistent with scancode behavior), preventing exclusions from being incorrectly marked unused for nested paths like src/source-build-assets/src/externalPackages/....

Changes:

  • Adjust negative lookahead generation to match ignored directory names at any depth under the scan root.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mthalman
mthalman enabled auto-merge (squash) April 21, 2026 19:29
@mthalman
mthalman merged commit df655cc into dotnet:main Apr 21, 2026
15 checks passed
@mthalman
mthalman deleted the dev/mthalman/license-scanning-exclusions-fix branch April 21, 2026 20:32
@ellahathaway

Copy link
Copy Markdown
Member

/backport to release/10.0.1xx

@ellahathaway

Copy link
Copy Markdown
Member

/backport to release/10.0.2xx

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0.1xx (link to workflow run)

@ellahathaway

Copy link
Copy Markdown
Member

/backport to release/10.0.3xx

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0.2xx (link to workflow run)

@ellahathaway

Copy link
Copy Markdown
Member

/backport to release/10.0.4xx

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0.3xx (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0.4xx (link to workflow run)

@mthalman

Copy link
Copy Markdown
Member Author

I wanted to wait for a successful SDK diff run here to validate this is really working before backporting. So let's leave those opened PRs for now.

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.

3 participants