-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Update forbiddenapis to v2.6 #33759
Comments
Pinging @elastic/es-core-infra |
@uschindler thanks for letting us know! We are running with the CLI so that we can do it with a different JVM than the one Gradle is running with to be able to better handle multi release jars, and was planning to open an issue about and discuss to see if we can incorporate this into the plugin, but it did not seem straight forward. We want to move Gradle to run on Java 10 but still run forbiddenapi checks with Java 8 without calling this out specifically in CI. |
Hi Alpar,
To correctly use forbiddenapis in any JVM, you just need to:
BTW, neither Checkstyle nor PMD are able to fork (for the same reason), they use the Ant task internally to execute. Unless there are any other reasons (please explain details), I see no reason to add an option to the upstream forbiddenapis task to support forking. The only thing would be to use the |
Maybe bring @rjernst in here... |
Here is the magic in Here you see the "bad" thread methods, as declared "deprecated in Java 8": https://github.com/policeman-tools/forbidden-apis/blob/2.6/src/main/resources/de/thetaphi/forbiddenapis/signatures/jdk-deprecated-1.8.txt#L176-L180 On Java 11, this still allows forbiddenapis to work correctly, as those files are not hand-maintained, they were generated by machine, so ignoring signatures not available at runtime is safe, as a typos / human errors cannot happen. |
Multi release jars were a problem with 3rd party multi release jars for sure in the third party audit for sure, as different classes would be loaded and scanned depending on the running jvm, and would thus produce different results. We should have produced and example with @rjernst when we discussed this instead of relying on memory. We might also have been confused that during the third party audit task some classes meant for java 9 were being scanned when running on 8 as well due to how the jars were being extracted. |
The third party audit was indeed a problem in the previous setup: It just extracted all JAR files and therefor it also extracted the META-INF/versions folder. So Thirdparty-Audit should have applied an exclusion rule on META-INF/** Uwe |
Thanks @uschindler. This all makes more sense now. @atorok Let's switch back to using the forbiddenapis plugin and change third party audit to exclude META-INF as suggested. |
Hi @rjernst , I think the main forbiddenapis scan (of Elasticsearch Source code) is perfectly fine with the official plugin, there are no changes needed. I'd only remove the duplicate signatures (jdk-deprecated and elasttic's own have both Thread deprecated method, that's unneeded). Of course with the new plugin version, the Elasticsearch Java 9 sourceSet can now also be scanned (see the code I added, but commented out in my PR of March 2018). The third party audit has some special cases, which are also not solvable with running forked (the problem stays): The JAR files are extracted and then the ANT task is started to scan the extracted class files. When doing this, there is no classloader involved, so it's reproducible with different JVMs. The problem is another one: META-INF/versions contains duplicate class files, which are also scanned. Due to same class name, this leads to non-reproducibility, because it depends on scanning order which class file is then looked up internally in forbiddenapis, when other classes are scanned that refer to those duplicated ones. The only way to solve this is to only extract class files from the main folder and exclude META-INF/ folder while extracting the JAR file. Of course this would not scan the java9/10/11 versions in third party audits. But due to the module system, it's very unlikely that a 3rd party JAR uses internal APIs in the Java 9+ versions of class files. If you still want to scan those classes, it needs more work in 3rd party audit (it needs to extract and scan the 3rd party jar multiple times and for each run, extract java9/java10/... class files separately and overwrite the main class files (so replace original files with versioned ones, and then scan again with targetVersion=...). I'd not do this! |
@uschindler This is what we do for third party audit now:
So when we are scanning with an older JVM, we don't run into the class files meant for the newer versions and unknown class format or missing class errors. There are different jobs in CI that set the target compatibility from 8 to 11 so that assures us that we do eventually scan all the classes, even those meant for java 9. |
Hi, |
* Upgrade forbiddenapis to 2.6 Closes #33759 * Switch forbiddenApis back to official plugin * Remove CLI based task * Fix forbiddenApisJava9
* Upgrade forbiddenapis to 2.6 Closes #33759 * Switch forbiddenApis back to official plugin * Remove CLI based task * Fix forbiddenApisJava9
* Upgrade forbiddenapis to 2.6 Closes #33759 * Switch forbiddenApis back to official plugin * Remove CLI based task * Fix forbiddenApisJava9
Changelog: Version 2.6 (released 2018-09-17):
Important: Normally I would supply a PR, but due to the recent changes in Elasticsearch (use forbiddenapis CLI instead of plugin - why the hell???), I can't support it anymore (the CLI is also not actively maintained and stays for "simple use cases", it was never made for automated running from build scripts). Therefore, please do the update on your own. Just a few things:
server/java9
sourceset. The release fixed the bug in the Gradle plugin (later added sourcesets are not initialized withforbiddenApisJava9
task). Due to many updates in the Gradle plugin, an update of release/maintenance branches should really be investigated (especially to check Java 9 code and compiled Groovy code).Uwe
The text was updated successfully, but these errors were encountered: