Adding Nashorn script action to zest script

15 views
Skip to first unread message

Hector Luna

unread,
Mar 13, 2023, 12:02:34 PM3/13/23
to OWASP ZAP User Group
This may be a super simple thing to do but I have not quite figured out how to do this...

I am trying to add a nashorn script action to a zest script. That works really well but I want to be able to pass parameters to that nashorn script so that I can use them inside the script and be able to reuse the same nashorn script in other parts of the zest script.

Here is what I am trying to do:
Screenshot 2023-03-13 at 10.56.06 AM.png
So my question is:
* Is it possible to access `firstParameter` and `secondParameter` from inside the `Basic Authentication Script.js` script?
* If so, how can go about doing so?
* How would I pass a return value to `variableForScriptResult` in such a way that does not require me to store a value in a global variable to retrieve later (not a big deal if I have to).

No big deal if such a thing isn't possible, but it gives me the impression that it should be possible to do and I just don't know how to do it.

Thanks!

thc...@gmail.com

unread,
Mar 13, 2023, 12:14:09 PM3/13/23
to zaprox...@googlegroups.com
Hi.

The parameters are variables in the script, you use them directly.

The script is evaluated and its result is what's set to the Zest variable.

Example script that returns the two parameters concatenated:
// Do things with parameters…
result = firstParameter + secondParameter
// …
result


Best regards.

Hector Luna

unread,
Mar 13, 2023, 12:18:47 PM3/13/23
to OWASP ZAP User Group
Thank you sir!
That works.

It is so easy I didn't think it was possible to get that to work like that.
Thank you very much.
Reply all
Reply to author
Forward
0 new messages