ZAP Proxy Missing Parameter Exception

47 views Asked by At

I had tried to code zap proxy but encounter errors. This is the error:

org.zaproxy.clientapi.core.ClientApiException: Missing Parameter
    at org.zaproxy.clientapi.core.ApiResponseFactory.getResponse(ApiResponseFactory.java:50)
    at org.zaproxy.clientapi.core.ClientApi.callApi(ClientApi.java:389)
    at org.zaproxy.clientapi.core.ClientApi.callApi(ClientApi.java:378)
    at org.zaproxy.clientapi.gen.Reports.generate(Reports.java:114)
    at com.rev.testManager.GenericTestManager.generateZapReport(GenericTestManager.java:58)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at org.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:139)
    at org.testng.internal.invokers.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:69)
    at org.testng.internal.invokers.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:390)
    at org.testng.internal.invokers.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:325)
    at org.testng.internal.invokers.TestInvoker.runConfigMethods(TestInvoker.java:810)
    at org.testng.internal.invokers.TestInvoker.runAfterConfigurations(TestInvoker.java:779)
    at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:755)
    at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:227)
    at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
    at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:957)
    at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:200)
    at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:148)
    at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.testng.TestRunner.privateRun(TestRunner.java:848)
    at org.testng.TestRunner.run(TestRunner.java:621)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:443)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:437)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:397)
    at org.testng.SuiteRunner.run(SuiteRunner.java:336)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1280)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1200)
    at org.testng.TestNG.runSuites(TestNG.java:1114)
    at org.testng.TestNG.run(TestNG.java:1082)
    at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
    at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)

It point to line generate method.

My code:

@AfterMethod
public void generateZapReport() {
    String targetFolder = System.getProperty("user.dir");

    if (clientApi != null) {
        try {
            ApiResponse apiResponse = clientApi.reports.generate("WSM API Security Testing",
                    null, null, "WSM API Security Testing", null,
                    "https://google.com.my/", null, null, null,
                    "zap-Security.html",
                    null,"targetFolder", null);
            System.out.println(apiResponse);
        } catch (ClientApiException e) {
            e.printStackTrace();
        }
    }
    webDriver.quit();
}

I tried to research on client api reference but no clue on how to fix it. Any hints to pin point the root cause?

Please help. Thanks.

1

There are 1 answers

0
kingthorin On

You seem to be passing an awful lot of nulls

Name In Type Required Description
title query string true Report Title
template query string true Report Template
theme query string false Report Theme
description query string false Report Description
contexts query string false The name of the contexts to be included in the report, separated by '
sites query string false The site URLs that should be included in the report, separated by '
sections query string false The report sections that should be included, separated by '
includedConfidences query string false Confidences that should be included in the report, separated by '
includedRisks query string false Risks that should be included in the report, separated by '
reportFileName query string false The file name of the generated report. This value overrides the reportFileNamePattern parameter.
reportFileNamePattern query string false Report File Name Pattern.
reportDir query string false Path to directory in which the generated report should be placed.
display query string false Display the generated report. Either "true" or "false".

Passing null for template is likely the culprit as it's a required field.

Also checkout reportsViewTemplates.

API docs are here: https://www.zaproxy.org/docs/api/

Info on ZAP's log and home directory: