DOMParser() undefined while running JS own scripts

374 views
Skip to first unread message

KHUSHBOO KUMARI

unread,
Mar 16, 2021, 5:32:21 AM3/16/21
to OWASP ZAP Scripts
Hi everyone, Does ZAP support DOMParser() and require('fs') in javascript proxy scripting? I am getting error as DOMParser() undefined. I need it for parsing string containing serialised XML response i.e of format text/xml. How can I make it work in ZAP?

Simon Bennetts

unread,
Mar 16, 2021, 5:49:20 AM3/16/21
to OWASP ZAP Scripts
ZAP Proxy scripts run in ZAP rather than in a browser. This means that browser features such as DOMParser are not available.
However you do have access to all of the functionality available within ZAP, and that includes an XML parser :)
And lots of examples of JavaScript calling java code in https://github.com/zaproxy/community-scripts

KHUSHBOO KUMARI

unread,
Mar 17, 2021, 3:30:31 AM3/17/21
to OWASP ZAP Scripts
I don't exactly know how can I use java code like this https://github.com/zaproxy/zaproxy/blob/main/zap/src/main/java/org/zaproxy/zap/spider/parser/SpiderSitemapXMLParser.java in JavaScript proxy scripts. I explored other scripts but that just use public java function which is available in that script context.

KHUSHBOO KUMARI

unread,
Mar 17, 2021, 8:40:53 AM3/17/21
to OWASP ZAP Scripts
Also, How can I add my own java file to use with Javascript file in ZAP? Because later after parsing text/xml I need to add/replicate some tag to the httpmessage response which is in form of text/xml. Please help if it can be done.

thc...@gmail.com

unread,
Mar 23, 2021, 3:11:11 AM3/23/21
to zaproxy...@googlegroups.com
Hi.

You can use the Java classes directly from the script (refer to syntax
of the engine used).

Best regards.
Reply all
Reply to author
Forward
0 new messages