Hi all!
I wrote a small class to interact with ZAP via the API and ran into a problem. When starting on a working PC, the following error always appears:
owasp zap org.zaproxy.clientapi.core.ClientApiException: org.xml.sax.SAXParseException; lineNumber: 135; columnNumber: 3; The element type "meta" must be terminated by the matching end-tag "</meta>".Google did not return anything useful for this error(
Tested on the following versions:
zap.jar: ZAP_2.13.0_Crossplatform, ZAP_WEEKLY_D-2023-09-18, ZAP_2.10.0_Core, ZAP_2.10.0_Crossplatform, ZAP_2_13_0_windows, ZAP_WEEKLY_D-2023-09-11
ZAP API Client: 1.12.0, 1.11.0, 1.10.0, 1.9.0, 1.8.0
Java: Oracle OpenJDK 11.0.13, Oracle OpenJDK 17.0.1, BellSoft Liberica 20.0.2
The result is the same.
The API works great through the browser or Postman or curl.
I tried to launch ZAP both through shortcuts on the desktop and with the command java -jar zap-2.13.0.jar -silent -config
api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true
At the same time, on a home computer with exactly the same versions of zap.jar, ZAP API Client and Java, everything works fine. Please help solve the problem!
Source code and exception stacktrace:
import org.testng.annotations.Test;
import org.zaproxy.clientapi.core.ApiResponseList;
import org.zaproxy.clientapi.core.ClientApi; //zap-clientapi-1.12.0.jar
public class zapExp {
//java -jar zap-2.13.0.jar -silent -config api.addrs.addr.name=.* -config api.addrs.addr.regex=true -config api.disablekey=true
//ZAP 2.13.0
private static final String ZAP_PROXY_ADDRESS = "localhost";
private static final int ZAP_PROXY_PORT = 8080;
private static final String ZAP_API_KEY = null;
private static final String TARGET = "https://juice-shop.***;
@Test(description = "ZAP scan. Target: " + TARGET)
public void zapTest() {
try {
ClientApi api = new ClientApi(ZAP_PROXY_ADDRESS, ZAP_PROXY_PORT, ZAP_API_KEY);
System.out.println("version: " + api.core.version());
System.out.println("zapHomePath: " + api.core.zapHomePath());
System.out.println("contextList: " + ((ApiResponseList) api.context.contextList()).getItems());
} catch (Exception e) {
System.out.println("Exception: " + e.getMessage());
e.printStackTrace();
}
}
}