Skip to content
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

Unable to retrieve all classes of JarFile given in --classpath option #127

Closed
Spr1n9T1me opened this issue Nov 7, 2024 · 4 comments
Closed
Labels
type: bug A general bug

Comments

@Spr1n9T1me
Copy link

📝 Overall Description

I'm looking for an implementation class for the interface jakarta.servlet.http.HttpServletRequest (located in tomcat-embed-core-10.1.31.jar), which should be implemented by many third-party dependencies, for example

  • jakarta.servlet.http.HttpServletRequestWrapper (at tomcat-embed-core-10.1.31.jar)
  • org.apache.catalina.connector.RequestFacade (at tomcat-embed-core:10.1.31.jar)

    I have specified the path of the relevant jar to the --classpath option, but Tai-e doesn't seem to read these classes into the World, after debugging, I found that the front-end soot also does not read these classes into the Scene, is this a bug generated by soot as a front-end, or is it a bug of tai-e itself?

🎯 Expected Behavior

Obtain the implementation class of HttpServletRequest, such as the JClass instance of HttpServletRequestWrapper.

🐛 Current Behavior

Unable to obtain the implementation class of HttpServletRequest, such as the JClass instance of HttpServletRequestWrapper. And after dumping all the IRs, they can't be found in the TIR file either.

🔄 Reproducible Example

I use the following driver to start the analysis

    public static void main(String[] args) {
        Main.main("--options-file","src/main/resources/options.yml");
        JClass iClass = World.get().getClassHierarchy().getClass("jakarta.servlet.http.HttpServletRequest");
        World.get().getClassHierarchy().getDirectImplementorsOf(iClass).forEach(System.out::println);
        World.get().getClassHierarchy().getAllSubclassesOf(iClass).forEach(System.out::println);
        World.get().getClassHierarchy().getDirectSubinterfacesOf(iClass).forEach(System.out::println);
    }

The analysis target is available from the link: bench-0.0.1-SNAPSHOT.zip

⚙️ Tai-e Arguments

🔍 Click here to see Tai-e Options
optionsFile: null
printHelp: false
classPath: [bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-annotations-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-core-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-databind-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-datatype-jdk8-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-datatype-jsr310-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-module-parameter-names-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jakarta.annotation-api-2.1.1.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jul-to-slf4j-2.0.16.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\log4j-api-2.23.1.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\log4j-to-slf4j-2.23.1.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\logback-classic-1.5.11.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\logback-core-1.5.11.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\micrometer-commons-1.13.6.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\micrometer-observation-1.13.6.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\slf4j-api-2.0.16.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\snakeyaml-2.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-aop-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-beans-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-boot-3.3.5.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-boot-autoconfigure-3.3.5.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-boot-jarmode-tools-3.3.5.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-context-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-core-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-expression-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-jcl-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-web-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-webmvc-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\tomcat-embed-core-10.1.31.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\tomcat-embed-el-10.1.31.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\tomcat-embed-websocket-10.1.31.jar;]
appClassPath:
- bench-0.0.1-SNAPSHOT\BOOT-INF\classes
mainClass:
inputClasses: []
javaVersion: 8
prependJVM: false
allowPhantom: true
worldBuilderClass: pascal.taie.frontend.soot.SootWorldBuilder
outputDir: output
preBuildIR: false
worldCacheMode: false
scope: ALL
nativeModel: true
planFile: null
analyses:
 ir-dumper: ""
onlyGenPlan: false
keepResult:
- $KEEP-ALL
🔍 Click here to see Tai-e Analysis Plan
- id: ir-dumper
options: {}

📜 Tai-e Log

🔍 Click here to see Tai-e Log
Writing log to C:\Users\springtime\Desktop\Program-Analysis\Tai-e\output\tai-e.log
java.version: 17
java.version.date: 2021-09-14
java.runtime.version: 17+35-2724
java.vendor: Oracle Corporation
java.vendor.version: null
os.name: Windows 10
os.version: 10.0
os.arch: amd64
Tai-e Version: 0.5.1-SNAPSHOT
Tai-e Commit: 9eb966e35d518a6813a6a5be78dfaff4b90c907b
Writing analysis plan to C:\Users\springtime\Desktop\Program-Analysis\Tai-e\output\tai-e-plan.yml
WorldBuilder starts ...
Warning: main class was not given!
8999 classes with 82400 methods in the world
WorldBuilder finishes, elapsed time: 7.61s
ir-dumper starts ...
Dumping IR in C:\Users\springtime\Desktop\Program-Analysis\Tai-e\output\tir
8999 classes in scope (ALL) of class analyses
ir-dumper finishes, elapsed time: 8.70s
Tai-e finishes, elapsed time: 16.50s

ℹ️ Additional Information

No response

@Spr1n9T1me Spr1n9T1me added the type: bug A general bug label Nov 7, 2024
@ayanamists
Copy link
Member

ayanamists commented Nov 8, 2024

You need to put the target jars in appClassPath instead of classPath if you want Tai-e to load every class in your jars.

If you edit your config as below,

optionsFile: null
printHelp: false
classPath: []
appClassPath: [bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-annotations-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-core-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-databind-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-datatype-jdk8-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-datatype-jsr310-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-module-parameter-names-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jakarta.annotation-api-2.1.1.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jul-to-slf4j-2.0.16.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\log4j-api-2.23.1.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\log4j-to-slf4j-2.23.1.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\logback-classic-1.5.11.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\logback-core-1.5.11.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\micrometer-commons-1.13.6.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\micrometer-observation-1.13.6.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\slf4j-api-2.0.16.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\snakeyaml-2.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-aop-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-beans-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-boot-3.3.5.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-boot-autoconfigure-3.3.5.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-boot-jarmode-tools-3.3.5.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-context-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-core-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-expression-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-jcl-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-web-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-webmvc-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\tomcat-embed-core-10.1.31.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\tomcat-embed-el-10.1.31.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\tomcat-embed-websocket-10.1.31.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\classes;]
mainClass:
inputClasses: []
javaVersion: 8
prependJVM: false
allowPhantom: true
worldBuilderClass: pascal.taie.frontend.soot.SootWorldBuilder
outputDir: output
preBuildIR: false
worldCacheMode: false
scope: ALL
nativeModel: true
planFile: null
analyses:
 ir-dumper: ""
onlyGenPlan: false
keepResult:
- $KEEP-ALL

The output will be

WorldBuilder finishes, elapsed time: 35.47s
org.apache.catalina.connector.Request
org.apache.catalina.connector.RequestFacade
jakarta.servlet.http.HttpServletRequestWrapper
jakarta.servlet.http.HttpServletRequest
org.apache.catalina.connector.Request
org.apache.catalina.connector.RequestFacade
jakarta.servlet.http.HttpServletRequestWrapper
org.apache.catalina.core.ApplicationHttpRequest
org.springframework.web.context.support.ContextExposingHttpServletRequest
org.springframework.web.multipart.MultipartHttpServletRequest
org.springframework.web.filter.FormContentFilter$FormContentRequestWrapper
org.springframework.web.filter.HiddenHttpMethodFilter$HttpMethodRequestWrapper
org.springframework.web.servlet.handler.HandlerMappingIntrospector$AttributesPreservingRequest
org.springframework.web.multipart.support.AbstractMultipartHttpServletRequest
org.springframework.web.multipart.support.StandardMultipartHttpServletRequest
org.springframework.web.servlet.resource.ResourceUrlEncodingFilter$ResourceUrlEncodingRequestWrapper
org.springframework.web.filter.ForwardedHeaderFilter$ForwardedHeaderRemovingRequest
org.springframework.web.filter.ForwardedHeaderFilter$ErrorPathRequest
org.springframework.web.filter.ForwardedHeaderFilter$ForwardedHeaderExtractingRequest
org.springframework.web.util.ContentCachingRequestWrapper
org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest
org.apache.catalina.filters.RemoteIpFilter$XForwardedRequest
org.springframework.web.multipart.MultipartHttpServletRequest

Also note you'd better use Main.buildWorld instead of Main.main, because the old Soot frontend will be extremly slow dues to the ir-dumper.

    public static void main(String[] args) {
        Main.buildWorld("--options-file","src/main/resources/options.yml");
        JClass iClass = World.get().getClassHierarchy().getClass("jakarta.servlet.http.HttpServletRequest");
        World.get().getClassHierarchy().getDirectImplementorsOf(iClass).forEach(System.out::println);
        World.get().getClassHierarchy().getAllSubclassesOf(iClass).forEach(System.out::println);
        World.get().getClassHierarchy().getDirectSubinterfacesOf(iClass).forEach(System.out::println);
    }

@Spr1n9T1me
Copy link
Author

@ayanamists Thanks for you reply! one more question, if classes of jars which are put in classPath option cannot be fully loaded by Tai-e, what is the meaning of this option?

You need to put the target jars in appClassPath instead of classPath if you want Tai-e to load every class in your jars.

If you edit your config as below,

optionsFile: null
printHelp: false
classPath: []
appClassPath: [bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-annotations-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-core-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-databind-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-datatype-jdk8-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-datatype-jsr310-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jackson-module-parameter-names-2.17.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jakarta.annotation-api-2.1.1.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\jul-to-slf4j-2.0.16.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\log4j-api-2.23.1.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\log4j-to-slf4j-2.23.1.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\logback-classic-1.5.11.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\logback-core-1.5.11.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\micrometer-commons-1.13.6.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\micrometer-observation-1.13.6.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\slf4j-api-2.0.16.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\snakeyaml-2.2.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-aop-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-beans-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-boot-3.3.5.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-boot-autoconfigure-3.3.5.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-boot-jarmode-tools-3.3.5.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-context-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-core-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-expression-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-jcl-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-web-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\spring-webmvc-6.1.14.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\tomcat-embed-core-10.1.31.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\tomcat-embed-el-10.1.31.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\lib\tomcat-embed-websocket-10.1.31.jar;bench-0.0.1-SNAPSHOT\BOOT-INF\classes;]
mainClass:
inputClasses: []
javaVersion: 8
prependJVM: false
allowPhantom: true
worldBuilderClass: pascal.taie.frontend.soot.SootWorldBuilder
outputDir: output
preBuildIR: false
worldCacheMode: false
scope: ALL
nativeModel: true
planFile: null
analyses:
 ir-dumper: ""
onlyGenPlan: false
keepResult:
- $KEEP-ALL

The output will be

WorldBuilder finishes, elapsed time: 35.47s
org.apache.catalina.connector.Request
org.apache.catalina.connector.RequestFacade
jakarta.servlet.http.HttpServletRequestWrapper
jakarta.servlet.http.HttpServletRequest
org.apache.catalina.connector.Request
org.apache.catalina.connector.RequestFacade
jakarta.servlet.http.HttpServletRequestWrapper
org.apache.catalina.core.ApplicationHttpRequest
org.springframework.web.context.support.ContextExposingHttpServletRequest
org.springframework.web.multipart.MultipartHttpServletRequest
org.springframework.web.filter.FormContentFilter$FormContentRequestWrapper
org.springframework.web.filter.HiddenHttpMethodFilter$HttpMethodRequestWrapper
org.springframework.web.servlet.handler.HandlerMappingIntrospector$AttributesPreservingRequest
org.springframework.web.multipart.support.AbstractMultipartHttpServletRequest
org.springframework.web.multipart.support.StandardMultipartHttpServletRequest
org.springframework.web.servlet.resource.ResourceUrlEncodingFilter$ResourceUrlEncodingRequestWrapper
org.springframework.web.filter.ForwardedHeaderFilter$ForwardedHeaderRemovingRequest
org.springframework.web.filter.ForwardedHeaderFilter$ErrorPathRequest
org.springframework.web.filter.ForwardedHeaderFilter$ForwardedHeaderExtractingRequest
org.springframework.web.util.ContentCachingRequestWrapper
org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest
org.apache.catalina.filters.RemoteIpFilter$XForwardedRequest
org.springframework.web.multipart.MultipartHttpServletRequest

Also note you'd better use Main.buildWorld instead of Main.main, because the old Soot frontend will be extremly slow dues to the ir-dumper.

    public static void main(String[] args) {
        Main.buildWorld("--options-file","src/main/resources/options.yml");
        JClass iClass = World.get().getClassHierarchy().getClass("jakarta.servlet.http.HttpServletRequest");
        World.get().getClassHierarchy().getDirectImplementorsOf(iClass).forEach(System.out::println);
        World.get().getClassHierarchy().getAllSubclassesOf(iClass).forEach(System.out::println);
        World.get().getClassHierarchy().getDirectSubinterfacesOf(iClass).forEach(System.out::println);
    }

@ayanamists
Copy link
Member

ayanamists commented Nov 9, 2024 via email

@Spr1n9T1me
Copy link
Author

understood, appreciate your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants