-
Notifications
You must be signed in to change notification settings - Fork 114
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
Can JQF be used in Spring Application #43
Comments
Hi @flyingjohn. I have not tried fuzzing Spring applications (in fact, I don't know much about Spring). Assuming the application is in pure Java, JQF should not have a problem with instrumentation and running tests. However, if the framework is heavily multi-threaded, that could pose some problems with fuzzing. Could you please describe the problems that you are facing in more detail? |
Hi @rohanpadhye, thanks for your answer. JQF performs great when I try to fuzz most java programs. But the thing is that,,Spring is a most-used web framework,it uses a mechanism called "Dependency injection" to create objects dynamically (see @AutoWire),for example:
SpringJunit4 will load the private object orderService dymanically. But when I use JQF to test the same function like this:
It won't work and throw NullPointerException for orderService. And it's reasonable because JQF doesn't implement @autowire notation.
However, this still won't work and orderService still be null. So I think objects must be loaded through Dependency injection in Spring applications. Is it true that JQF can't work in this situation(Spring applications)? |
The JQF test runner ( I have never tried something like this before, but StackOverflow seems to have some posts about people trying to combine MockitoRunner with other runners: https://stackoverflow.com/questions/24431427/multiple-runwith-statements-in-junit. Maybe there is a solution hidden in there somewhere? |
Thank you for your help! |
@flyingjohn @rohanpadhye I stumbled upon the same problem and as far as I understand this is due to this behaviour of springboot. Any idea of a more elegant solution? |
@flyingjohn @yevgenypats I was trying to explore the same option. Have you found any working solution for this? If yes, can you please share, it would be really helpful :) |
In order to use JQF + Spring, I think you can avoid using |
@rohanpadhye Thanks for sharing this. This helped in moving forward from this issue. But after going forward, facing another issue where I think it is not able to find classes from the dependencies. For example, when I try to run the jqf mvn plugin command, where it also tries to initialise some beans, it gives below error but it is already part of dependencies: While trying something different it gives: Any thoughts on how to resolve those? |
@rand-guy I'm glad the annotations helped. Unfortunately, I don't know how to resolve that specific error. I don't use Spring so I don't know about the API very much. One thing I can tell you is that JQF is just running the test as a regular JUnit test, using the classpath for scope
Where |
I have tried your suggestion. I tried running below command but for some reason it is not able to find the test and outputs " No tests were executed!".
This is the file: But when I try running the test directly via IDE's Run Test option, it is able to run it successfully and generated 100 tests. Will you be able to help with these details? Let me know if you need any details which could help ease the debugging. |
Partially addresses rohanpadhye/JQF#43
Thanks for the sample repo @rand-guy ! I was able to reproduce your issue. Turns out that spring-boot-starter-test pulls in JUnit5 by default so it won't let you run JUnit4 tests out of the box. I did some searching around and apparently have to add a dependency on For me, this makes |
I use jqf to fuzz generic functions, and the result is good. But when i try to fuzz web application functions written in Spring format, some problems occur. How can i use autowire and mock in JQF, is it possible to extend jqf to fuzz wen application?
The text was updated successfully, but these errors were encountered: