Endava / cats

CATS is a REST API Fuzzer and negative testing tool for OpenAPI endpoints. CATS automatically generates, runs and reports tests with minimum configuration and no coding effort. Tests are self-healing and do not require maintenance.
Apache License 2.0
1.17k stars 74 forks source link

java.lang.NullPointerException #21

Closed comat0zz closed 2 years ago

comat0zz commented 2 years ago

I am using version cats-linux 7.0.1 launch string: cats --contract=../swagger.json --server=https://api-site/ Why does not it work? cats.jar starts without problems

Powered by Quarkus 2.5.1.Final [**][*] ▶ start Starting CATS, version 7.0.1, build-time 2021-12-18T19:44:03Z UTC [**][*] ● note Processing configuration... [**][*] ℹ info No security custom Fuzzer file. SecurityFuzzer will be skipped! [**][*] ℹ info No custom Fuzzer file. CustomFuzzer will be skipped! [**][*] ℹ info No reference data file was supplied! Payloads supplied by Fuzzers will remain unchanged! [**][*] ℹ info No URL parameters supplied! [**][*] ℹ info No headers file was supplied! No additional header will be added! [**][*] ☑ complete Finished parsing the contract in 1 ms [**][*] ▶ start Start cleaning up cats-report folder ... [**][*] ☑ complete Cleanup complete! java.lang.NullPointerException at com.endava.cats.util.OpenApiUtils.getSchemas(OpenApiUtils.java:49) at com.endava.cats.command.CatsCommand.initGlobalData(CatsCommand.java:127) at com.endava.cats.command.CatsCommand.doLogic(CatsCommand.java:121) at com.endava.cats.command.CatsCommand.run(CatsCommand.java:109) at picocli.CommandLine.executeUserObject(CommandLine.java:1939) at picocli.CommandLine.access$1300(CommandLine.java:145) at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358) at picocli.CommandLine$RunLast.handle(CommandLine.java:2352) at picocli.CommandLine$RunLast.handle(CommandLine.java:2314) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179) at picocli.CommandLine$RunLast.execute(CommandLine.java:2316) at picocli.CommandLine.execute(CommandLine.java:2078) at com.endava.cats.CatsMain.run(CatsMain.java:27) at com.endava.cats.CatsMain_ClientProxy.run(Unknown Source) at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:125) at io.quarkus.runtime.Quarkus.run(Quarkus.java:67) at io.quarkus.runtime.Quarkus.run(Quarkus.java:41) at io.quarkus.runner.GeneratedMain.main(Unknown Source)

en-milie commented 2 years ago

Hi @comat0zz. Thank you for reporting this. It seems to be caused by the fact the the Swagger 2 parser was not included in the generated linux native image. Can you please confirm if your API spec is swagger 2? If this is true, the fix is available in https://github.com/Endava/cats/commit/58a338e6961ac192c5775799cb80797f8b677160 and will be released in 7.0.2.

comat0zz commented 2 years ago

Yes, "swagger": "2.0"

en-milie commented 2 years ago

Great. The fix will be available in 7.0.2, which will be released this week.

tasoskoutlis-f3 commented 2 years ago

Hi @en-milie I just got the 7.0.2 version, I have a Swagger 2 file and I am still getting the same error

cats --contract=swagger.yaml --server=https://api --headers=headers.yaml --blackbox

[**********][*******] ▶ start      Starting CATS, version 7.0.2, build-time 2022-01-16T18:22:12Z UTC 
[**********][*******] ● note       Processing configuration... 
[**********][*******] ℹ info       No security custom Fuzzer file. SecurityFuzzer will be skipped! 
[**********][*******] ℹ info       No custom Fuzzer file. CustomFuzzer will be skipped! 
[**********][*******] ℹ info       No reference data file was supplied! Payloads supplied by Fuzzers will remain unchanged! 
[**********][*******] ℹ info       No URL parameters supplied! 
[**********][*******] ☑ complete   Finished parsing the contract in 62 ms 
[**********][*******] ▶ start      Start cleaning up cats-report folder ... 
[**********][*******] ☑ complete   Cleanup complete! 
java.lang.NullPointerException
        at com.endava.cats.util.OpenApiUtils.getSchemas(OpenApiUtils.java:49)
        at com.endava.cats.command.CatsCommand.initGlobalData(CatsCommand.java:125)
        at com.endava.cats.command.CatsCommand.doLogic(CatsCommand.java:119)
        at com.endava.cats.command.CatsCommand.run(CatsCommand.java:107)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
        at picocli.CommandLine.access$1300(CommandLine.java:145)
        at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
        at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
        at picocli.CommandLine.execute(CommandLine.java:2078)
        at com.endava.cats.CatsMain.run(CatsMain.java:27)
        at com.endava.cats.CatsMain_ClientProxy.run(Unknown Source)
        at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:125)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
        at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
        at io.quarkus.runner.GeneratedMain.main(Unknown Source)

Can you please have a look? Thanks

en-milie commented 2 years ago

Hi @tasoskoutlis-f3 yes. It seems so. I will release a patch tonight.

en-milie commented 2 years ago

Hi @tasoskoutlis-f3. This is fixed now in https://github.com/Endava/cats/releases/tag/cats-7.0.3

daniel-f3 commented 2 years ago

Hi @en-milie I just got the 7.0.3 version, I have a Swagger 2 file and I am still getting the same error, could you please have a look? Thank you

# # # # # # # # # # # # # # # # # # # # # # # # # #
#             _____   ___ _____ _____             #
#            /  __ \ / _ \_   _/  ___|            #
#            | /  \// /_\ \| | \ `--.             #
#            | |    |  _  || |  `--. \            #
#            | \__/\| | | || | /\__/ /            #
#             \____/\_| |_/\_/ \____/             #
#           .. ...    -.-. --- --- .-..           #
#                                                 #
# # # # # # # # # # # # # # # # # # # # # # # # # #
                     Powered by Quarkus 2.6.2.Final
[**********][*******] ▶ start      Starting CATS, version 7.0.3, build-time 2022-01-18T18:51:46Z UTC 
[**********][*******] ● note       Processing configuration... 
[**********][*******] ℹ info       No security custom Fuzzer file. SecurityFuzzer will be skipped! 
[**********][*******] ℹ info       No custom Fuzzer file. CustomFuzzer will be skipped! 
[**********][*******] ℹ info       No reference data file was supplied! Payloads supplied by Fuzzers will remain unchanged! 
[**********][*******] ℹ info       No URL parameters supplied! 
[**********][*******] ☑ complete   Finished parsing the contract in 279 ms 
[**********][*******] ▶ start      Start cleaning up cats-report folder ... 
[**********][*******] ☑ complete   Cleanup complete! 
java.lang.NullPointerException
    at com.endava.cats.util.OpenApiUtils.getSchemas(OpenApiUtils.java:59)
    at com.endava.cats.command.CatsCommand.initGlobalData(CatsCommand.java:125)
    at com.endava.cats.command.CatsCommand.doLogic(CatsCommand.java:119)
    at com.endava.cats.command.CatsCommand.run(CatsCommand.java:107)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
    at picocli.CommandLine.access$1300(CommandLine.java:145)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
    at picocli.CommandLine.execute(CommandLine.java:2078)
    at com.endava.cats.CatsMain.run(CatsMain.java:27)
    at com.endava.cats.CatsMain_ClientProxy.run(Unknown Source)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:125)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:67)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:41)
    at io.quarkus.runner.GeneratedMain.main(Unknown Source)
en-milie commented 2 years ago

Hi @daniel-f3. Can you please post a sample that fails? I'm not able to reproduce this anymore with the swagger 2 spec I have.

en-milie commented 2 years ago

Should be (finally) fixed now in https://github.com/Endava/cats/releases/tag/cats-7.0.4

daniel-f3 commented 2 years ago

Awesome thank you, it is fixed.