Fix evaluator license violations with both license choices and path excludes#10873
Draft
Fix evaluator license violations with both license choices and path excludes#10873
Conversation
Co-authored-by: sschuberth <349154+sschuberth@users.noreply.github.com>
Co-authored-by: sschuberth <349154+sschuberth@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Evaluator: Incorrect license violations when both license choices and path excludes are configured
Fix evaluator license violations with both license choices and path excludes
Sep 19, 2025
Copilot stopped work on behalf of
sschuberth due to an error
September 19, 2025 12:22
|
|
||
| /** | ||
| * A DSL function to configure a [LicenseRule] and add it to this rule. | ||
| * |
Check warning
Code scanning / detekt
Detects trailing spaces Warning
| * 2. Filter excluded licenses (due to path excludes) - this must happen before applying choices | ||
| * 3. Apply package-specific license choices | ||
| * 4. Apply repository-wide license choices | ||
| * |
Check warning
Code scanning / detekt
Detects trailing spaces Warning
| * 3. Apply package-specific license choices | ||
| * 4. Apply repository-wide license choices | ||
| * | ||
| * This order matches the behavior of reporters and ensures that excluded licenses are not |
Check warning
Code scanning / detekt
Detects trailing spaces Warning
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10873 +/- ##
=========================================
Coverage 57.53% 57.53%
- Complexity 1698 1700 +2
=========================================
Files 346 346
Lines 12823 12823
Branches 1212 1212
=========================================
Hits 7378 7378
Misses 4978 4978
Partials 467 467
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
The ORT evaluator was incorrectly reporting license violations when a package had multiple license findings with both license choices and path excludes configured. This was due to the wrong order of operations in the evaluator logic.
Problem
The evaluator's
licenseRulefunction was processing licenses in this order:isExcluded()matcher)This is the reverse of how reporters handle the same scenario correctly.
Root Cause
Consider a package with:
MIT OR GPL-2.0-onlyinLICENSE(non-excluded)GPL-2.0-onlyinexcluded/some-file.txt(path excluded)MIT OR GPL-2.0-only -> MITBefore this fix: The evaluator would apply the choice first, then check exclusions, leading to
GPL-2.0-onlybeing considered for rule evaluation even though it should be filtered out by path excludes.After this fix: The evaluator filters excluded licenses first, then applies choices, resulting in only
MITbeing evaluated - matching the reporter behavior.Solution
Modified the
licenseRulefunction inPackageRule.ktto call.filterExcluded()before.applyChoices():This matches the working pattern in
EvaluatedModelMapper.ktwhere reporters correctly do:input.licenseInfoResolver.resolveLicenseInfo(pkg.id).filterExcluded().effectiveLicense(...)Impact
Fixes #10867.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
repo.eclipse.org/usr/lib/jvm/temurin-21-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -XX:MaxMetaspaceSize=1g -Xmx2g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/gradle-daemon-main-9.1.0.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/agents/gradle-instrumentation-agent-9.1.0.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 9.1.0(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.