-
Notifications
You must be signed in to change notification settings - Fork 35
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
support .jar file to be scanned in cli #259
base: main
Are you sure you want to change the base?
Conversation
There is no need to extract the JAR to a temporary directory. The Checker API can directly consume the InputStream when you pass them one by one. It must just handle a JAR file like a directory. Of course the classfile pattern needs to be applied, too. So the JAR file must be serially be passed to: forbidden-apis/src/main/java/de/thetaphi/forbiddenapis/Checker.java Lines 364 to 374 in 6019f14
I can take your PR as a base, but the implementation is not ideal, so I won't merge this as is. To make this work more modifications are needed. |
@uschindler I was wondering what could work but as i couldn't get any of my ides to import all the deps via ivy/build.xml I didn't get that far :) if you can take it from here and make it work right that would be cool - if not let me know and I'll try do it. |
No problem, will fix that. I have some ideas. Basically I would use a ZIPInputStream instead, so the ZIP file is read sequentially. I just have to figure out how to apply the glob-based filtering there, I think its somewhere in plexus-utils to apply it to strings. |
If you stick to NIO then you can use Path as an abstraction for file system files (.class files) and .class files inside ZIP archives (by opening a zip FileSystem [1]). There is usually some awkwardness in closing zip file systems but they work very well and are robust in my experience. For any downstream code, a Path (and streams) to a file inside a zip archive appears just as a normal filesystem path. [1] https://docs.oracle.com/en/java/javase/22/docs/api/jdk.zipfs/module-summary.html |
As for globbing, I've also used glob PathMatcher instances on those zip filesystems and they tend to work quite fine. Again: there are some oddities here and there but they do work, generally. |
as mentioned in #257 it would be nice to be able to scan jars.
this pr enables it so you can do things like:
jar -jar forbiddenapis.jar -d /Users/manderse/.m2/repository/io/quarkus/quarkus-core/3.18.1/quarkus-core-3.18.1.jar --allowmissingclasses --bundledsignatures jdk-system-out
or in more compact form with jbang (if you done
jbang app install forbiddenapis.jar
forbiddenapis -d
jbang info jar io.quarkus:quarkus-core:3.18.1--allowmissingclasses --bundledsignatures jdk-system-out
wdyt? I find this superuseful as i can check any maven artifact or even lib on disk without changing their build.