imperva / automatic-api-attack-tool

Imperva's customizable API attack tool takes an API specification as an input, generates and runs attacks that are based on it as an output.
MIT License
445 stars 91 forks source link

Swagger Parser Issues #9

Open kleozzy opened 3 years ago

kleozzy commented 3 years ago

I am always getting this error on runwhich i assume it has something to do with outdated parser? Can you fix this?

0:36:05.376 [main] ERROR c.i.a.tests.ScenariosDataProvider - Failed to get httpRequestList, for file: site_staging.yaml java.lang.NullPointerException: null at com.imperva.apispecparser.parsers.swagger.Swagger2Parser.getEndpointModelList(Swagger2Parser.java:52) at com.imperva.apiattacktool.tests.AbstractTestDriver.parseSwagger(AbstractTestDriver.java:85) at com.imperva.apiattacktool.tests.SingleValueScenarioTestDriver.getHttpRequestList(SingleValueScenarioTestDriver.java:36) at com.imperva.apiattacktool.tests.ScenariosDataProvider.getEndpointTestRequestData(ScenariosDataProvider.java:57) at com.imperva.apiattacktool.tests.ScenariosDataProvider.positiveScenarioDataProvider(ScenariosDataProvider.java:30) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:77) at org.testng.internal.MethodInvocationHelper.invokeMethodNoCheckedException(MethodInvocationHelper.java:46) at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:146) at org.testng.internal.Parameters.handleParameters(Parameters.java:820) at org.testng.internal.Parameters.handleParameters(Parameters.java:762) at org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:60) at org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:39) at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:771) at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.testng.TestRunner.privateRun(TestRunner.java:770) at org.testng.TestRunner.run(TestRunner.java:591) at org.testng.SuiteRunner.runTest(SuiteRunner.java:402) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355) at org.testng.SuiteRunner.run(SuiteRunner.java:304) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180) at org.testng.TestNG.runSuitesLocally(TestNG.java:1102) at org.testng.TestNG.runSuites(TestNG.java:1032) at org.testng.TestNG.run(TestNG.java:1000) at com.imperva.apiattacktool.cli.ApiAttackTool.call(ApiAttackTool.java:87) at com.imperva.apiattacktool.cli.ApiAttackTool.call(ApiAttackTool.java:13) at picocli.CommandLine.executeUserObject(CommandLine.java:1781) at picocli.CommandLine.access$900(CommandLine.java:145) at picocli.CommandLine$RunLast.handle(CommandLine.java:2139) at picocli.CommandLine$RunLast.handle(CommandLine.java:2106) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1973) at picocli.CommandLine.execute(CommandLine.java:1902) at com.imperva.apiattacktool.ToolMain.main(ToolMain.java:17) [Utils] [ERROR] [Error] org.testng.TestNGException: Data Provider public static java.lang.Object[][] com.imperva.apiattacktool.tests.ScenariosDataProvider.positiveScenarioDataProvider() returned a null value at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:148) at org.testng.internal.Parameters.handleParameters(Parameters.java:820) at org.testng.internal.Parameters.handleParameters(Parameters.java:762) at org.testng.internal.ParameterHandler.handleParameters(ParameterHandler.java:60) at org.testng.internal.ParameterHandler.createParameters(ParameterHandler.java:39) at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:771) at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:145) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.testng.TestRunner.privateRun(TestRunner.java:770) at org.testng.TestRunner.run(TestRunner.java:591) at org.testng.SuiteRunner.runTest(SuiteRunner.java:402) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:396) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:355) at org.testng.SuiteRunner.run(SuiteRunner.java:304) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1180) at org.testng.TestNG.runSuitesLocally(TestNG.java:1102) at org.testng.TestNG.runSuites(TestNG.java:1032) at org.testng.TestNG.run(TestNG.java:1000) at com.imperva.apiattacktool.cli.ApiAttackTool.call(ApiAttackTool.java:87) at com.imperva.apiattacktool.cli.ApiAttackTool.call(ApiAttackTool.java:13) at picocli.CommandLine.executeUserObject(CommandLine.java:1781) at picocli.CommandLine.access$900(CommandLine.java:145) at picocli.CommandLine$RunLast.handle(CommandLine.java:2139) at picocli.CommandLine$RunLast.handle(CommandLine.java:2106) at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1973) at picocli.CommandLine.execute(CommandLine.java:1902) at com.imperva.apiattacktool.ToolMain.main(ToolMain.java:17)

thenorthernpole commented 3 years ago

Thanks for reaching out. Could you please provide the yaml file you're using?

Thanks

Lulztigre commented 3 years ago

I got this same error as well, and i can't seem to find any .yaml

mercutioviz commented 3 years ago

I also get this. Here's the yaml file I am using:

swagger: '2.0' info: version: '1.0.0' title: Swagger Petstore description: > This is a sample Petstore server. You can find

out more about Swagger at

[http://swagger.io](http://swagger.io) or on

[irc.freenode.net, #swagger](http://swagger.io/irc/).

contact: email: apiteam@swagger.io host: '*' basePath: /api/petstore/1.0.0 securityDefinitions: api_key: type: apiKey description: '' name: api_key in: header schemes:

0xabdi commented 2 years ago

Getting the same error. How did fix this?

HeyThisHaku commented 2 years ago

I got same error, but I was fix with this converter: https://editor.swagger.io/

Import ur swagger.json or yaml .json after u import, try to export to yaml after that, check your yaml file make sure first line is:

'swagger: [version]' because my problem the first line is not swagger but 'openfile:[version]'

AnjiB commented 1 year ago

I am getting the same issue even after I added the first line as swagger: 3.0.1

thenorthernpole commented 1 year ago

@AnjiB and all, the parser currently supports only Swagger 2.

sertal70 commented 7 months ago

@thenorthernpole Maybe it could be worth spending 2 mins to add this valuable information in the README, just to help people to avoid wasting time to download, compile and run the tool on an unsupported OpenAPI specification.