简体   繁体   中英

CodeQL Scanning JAR Files

I'm just getting started with CodeQL and have had plenty of success scanning Python projects. Now, I'm starting to scan Java projects, and I struggle to scan precompiled projects.

From what I gathered, it appears CodeQL CLI includes an autobuilder for Java code and will build the projects for me. I'm trying to scan projects already compiled from the Maven central repository.

Question:

  1. Is it possible to scan compiled Java source code (ie, bytecode, class files) contained within a JAR file with CodeQL?
  2. If so, how can I invoke these properties to scan JAR files from the CLI?

Thanks for any insight!

As mentioned in the other answer, for Java CodeQL observes the results during compilation and creates a database from it. It is therefore not possible to build a database from a JAR containing compiled classes. It is however possible to use compiled classes in a project (eg in the form of Maven dependencies, or JDK usage), and CodeQL will record the information that these classes are used, but it has no insight into what these classes do. That means no dataflow or taintflow will be available for them, unless CodeQL explicitly models it, see the list of supported frameworks .

However, since your plan is to run queries against projects from Maven Central, it is most likely easiest to obtain the databases from lgtm.com , or to directly use the Query Console on lgtm.com, see also the documentation . For most projects lgtm.com is able to build the project on its own.

lgtm.com is owned by Semmle, which originally created CodeQL and was acquired by GitHub .

From what I read, it does not seem to work on compiled classes. You will need the src code, whether that exists as a (Jar, which then you need to unzip before processing), or a Github project.

Usually during running you would provide the way to build your project, such as --language=java --command='mvn clean install -DskipTests' <-- This requires source code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM