-
Notifications
You must be signed in to change notification settings - Fork 352
Fix evaluator license violations with both license choices and path excludes #10873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: sschuberth <[email protected]>
Co-authored-by: sschuberth <[email protected]>
|
||
/** | ||
* 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:
|
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
licenseRule
function 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-only
inLICENSE
(non-excluded)GPL-2.0-only
inexcluded/some-file.txt
(path excluded)MIT OR GPL-2.0-only -> MIT
Before this fix: The evaluator would apply the choice first, then check exclusions, leading to
GPL-2.0-only
being 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
MIT
being evaluated - matching the reporter behavior.Solution
Modified the
licenseRule
function inPackageRule.kt
to call.filterExcluded()
before.applyChoices()
:This matches the working pattern in
EvaluatedModelMapper.kt
where 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.