It would also be better to add the mapping outside the scan function,
since that just needs to be done once (the scripts are cached so that
would be executed less times even).
(Assuming it's ok to have the mapping when there are no occurrences.)
Best regards.
On 26/08/2021 02:06, kingthorin+owaspzap wrote:
> Okay got it sorted out. That error happens when you don't have Neonmarker
> installed. So install it first ;)
>
> You probably don't want to add the mapping inside the scan method,
> otherwise it'll be added for every message scanned. (The add-on should
> prevent duplicates, I'll have to tackle that separately.) The example in
> the wiki is meant to be a standalone script. (I'll tweak the content to
> make that more clear).
>
> For the color mapping you add you probably want "*extNeon.addColorMapping("my
> tag, 0x990000)*", so that it colors the things you tag :) [Not those that
> have the "Comment" tag.]
>
> Also if you're going to share the script with others (hopefully you'll add
> it to the community-scripts repo). It would probably be a good move to wrap
> the addColorMapping call in a conditional that checks that you actually
> found extNeon...
>
> if (extNeon != null) {
> *extNeon.addColorMapping("my tag", 0x990000)*
> }
>
> That way if others fail to install Neonmarker they'll still get the tag and
> not the error you got. (Of course you should comment the script so that
> it's clear that if they want colored history they need to install the
> add-on)
>
> On Wednesday, August 25, 2021 at 8:28:43 PM UTC-4 kingthorin+owaspzap wrote:
>
>> Hmmmm that might be due to more recent changes to the Scripts extension,
>> I'll do some testing.
>>
>>
>> On Wednesday, August 25, 2021 at 2:41:48 PM UTC-4 ZAPuser wrote:
>>
>>> I tried the following implementation:
>>>
>>> *extNeon =
>>> org.parosproxy.paros.control.Control.getSingleton().getExtensionLoader().getExtension(
org.zaproxy.zap.extension.neonmarker.ExtensionNeonmarker.NAME
>>> <
http://org.zaproxy.zap.extension.neonmarker.ExtensionNeonmarker.NAME>);*
>>>
>>> *function scan(ps, msg, src)*
>>> *{*
>>> *// Regex found a match, let's a tag and add color to the entry line in
>>> History tab*
>>> *ps.addTag("my tag");*
>>> *extNeon.addColorMapping("Comment", 0x990000)*
>>> *}*
>>>
>>> but getting the following error:
>>> *java.lang.RuntimeException: java.lang.NoSuchMethodException: Can't
>>> unambiguously select between fixed arity signatures [(java.lang.String),
>>> (int)] of the method
>>> org.parosproxy.paros.extension.ExtensionLoader.getExtension for argument
>>> types
>>> [jdk.nashorn.internal.runtime.NativeJavaPackage]java.lang.RuntimeException:
>>> java.lang.NoSuchMethodException: Can't unambiguously select between fixed
>>> arity signatures [(java.lang.String), (int)] of the method
>>> org.parosproxy.paros.extension.ExtensionLoader.getExtension for argument
>>> types [jdk.nashorn.internal.runtime.NativeJavaPackage]*
>>> On Wednesday, August 25, 2021 at 11:04:28 AM UTC-7 kingthorin+owaspzap
>>> wrote:
>>>
>>>> You can use it from scripts but your tag on the "latest" message would
>>>> need to be unique:
>>>>
https://github.com/kingthorin/neonmarker/wiki
>>>>
>>>> Might endup with some weird race condition(s) too.
>>>>
>>>> On Wednesday, August 25, 2021 at 11:59:05 AM UTC-4 ZAPuser wrote:
>>>>
>>>>> Thanks very much for your responses!
>>>>>
>>>>> I found the suggestion from thc202 to be just what I needed here (
>>>>> *ps.addTag*). I was looking for something similar but under the wrong
>>>>> name. I saw *msg.setNote(note)* and thought there might be