Skip to content

Address potential classloader performance issues in JS scripts#504

Merged
psiinon merged 1 commit into
zaproxy:mainfrom
kingthorin:adjust-java-type-usage
May 28, 2026
Merged

Address potential classloader performance issues in JS scripts#504
psiinon merged 1 commit into
zaproxy:mainfrom
kingthorin:adjust-java-type-usage

Conversation

@kingthorin
Copy link
Copy Markdown
Member

No description provided.

@kingthorin
Copy link
Copy Markdown
Member Author

Note I used const in all the changes but didn't change/reduce other use of var. I can I just wasn't sure if it should be the same PR.

@psiinon
Copy link
Copy Markdown
Member

psiinon commented Dec 12, 2025

Logo
Checkmarx One – Scan Summary & Detailsd5fe9c10-d896-49f1-8201-4caa77808066


New Issues (6) Checkmarx found the following issues in this Pull Request
# Severity Issue Source File / Package Checkmarx Insight
1 HIGH Last User Is 'root' /docker-wrapper: 10
detailsLeaving the last user as root can cause security risks. Change to another user after running the commands that need privileges
2 MEDIUM CVE-2026-34479 Maven-org.apache.logging.log4j:log4j-1.2-api-2.24.2
detailsRecommended version: 2.25.4
Description: The Log4j1XmlLayout from the Apache Log4j 1-to-Log4j 2 bridge fails to escape characters forbidden by the XML 1.0 standard, producing malformed XML...
Attack Vector: NETWORK
Attack Complexity: LOW
Vulnerable Package
3 LOW MAINTAINER Instruction Being Used /docker-wrapper: 3
detailsThe MAINTAINER instruction sets the Author field of the generated images. The LABEL instruction is a much more flexible version of this and you sh...
4 LOW Unpinned Actions Full Length Commit SHA /codeql.yml: 31
detailsPinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA help...
5 LOW Unpinned Actions Full Length Commit SHA /codeql.yml: 34
detailsPinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA help...
6 LOW Unpinned Actions Full Length Commit SHA /codeql.yml: 35
detailsPinning an action to a full length commit SHA is currently the only way to use an action as an immutable release. Pinning to a particular SHA help...

Use @Checkmarx to interact with Checkmarx PR Assistant.
Examples:
@Checkmarx how are you able to help me?
@Checkmarx rescan this PR

@kingthorin kingthorin force-pushed the adjust-java-type-usage branch from 39d4e87 to 80916f9 Compare December 12, 2025 16:53
@kingthorin kingthorin changed the title Address potential classloader performance issues Address potential classloader performance issues in JS scripts Dec 12, 2025
@kingthorin
Copy link
Copy Markdown
Member Author

The CX failure is unrelated to the changes.

Comment thread httpfuzzerprocessor/addCacheBusting.js Outdated
Comment thread httpfuzzerprocessor/unexpected_responses.js Outdated
Comment thread httpsender/Alert on HTTP Response Code Errors.js
Comment thread passive/Report non static sites.js Outdated
Comment thread standalone/historySourceTagger.js Outdated
Comment thread targeted/json_csrf_poc_generator.js Outdated
@kingthorin kingthorin force-pushed the adjust-java-type-usage branch from 80916f9 to f6c4ce7 Compare December 19, 2025 14:31
@kingthorin
Copy link
Copy Markdown
Member Author

Think I got all those.

Comment thread CHANGELOG.md Outdated
@thc202
Copy link
Copy Markdown
Member

thc202 commented Dec 19, 2025

Not all scripts were updated (some still left in the changed scripts), was that on purpose?

@kingthorin
Copy link
Copy Markdown
Member Author

I thought I copied the full content from zaproxy/docker will check.

@thc202
Copy link
Copy Markdown
Member

thc202 commented Dec 19, 2025

I'm referring to scripts that are just here (e.g. Telerik Using Poor Crypto.js with Base64 and Alert, Capture and Replace Anti CSRF Token.js with ScriptVars).

@kingthorin
Copy link
Copy Markdown
Member Author

My search must have missed them, thanks for clarifying.

@kingthorin
Copy link
Copy Markdown
Member Author

I just remembered there were a few I left on purpose like in the extender scripts cause they're only used on install and uninstall or register and unregister, but I guess I should change them all to be consistent.

@kingthorin kingthorin force-pushed the adjust-java-type-usage branch from f6c4ce7 to 4cfd726 Compare May 26, 2026 11:25
Comment thread httpsender/Capture and Replace Anti CSRF Token.js
Comment thread passive/f5_bigip_cookie_internal_ip.js
@kingthorin kingthorin force-pushed the adjust-java-type-usage branch from 4cfd726 to 164e4a9 Compare May 26, 2026 21:48
@kingthorin
Copy link
Copy Markdown
Member Author

kingthorin commented May 26, 2026

Done & done. (If the var -> const change is too broad let me know and I can roll it back)

@thc202
Copy link
Copy Markdown
Member

thc202 commented May 27, 2026

It's not an if, it is. How does that address potential classloader performance issues.

@kingthorin
Copy link
Copy Markdown
Member Author

kingthorin commented May 27, 2026

We had agreed to update them as we were switching the fully qualified class usage to Java.types/extends. I was debating if consistency or minimal change was more important.

I'll roll it back.

@thc202
Copy link
Copy Markdown
Member

thc202 commented May 27, 2026

Minimal changes are more important if the other changes are not done consistently, there are other var that should be const (and we should drop the var as well) throughout (e.g. why in the first script it was not changed LOG_DEBUG_MESSAGES).

@kingthorin
Copy link
Copy Markdown
Member Author

Because my instruction had been to change it with Java.type and Java.extends. It's okay, I'll go back to minimal change, that's probably best for this case. Other stuff can be done in other passes or PRs.

@kingthorin kingthorin force-pushed the adjust-java-type-usage branch from 164e4a9 to 1ea2a05 Compare May 27, 2026 12:54
@kingthorin
Copy link
Copy Markdown
Member Author

Should be back on track.

@kingthorin
Copy link
Copy Markdown
Member Author

kingthorin commented May 27, 2026

That was a restoration to the original state (check the change tab, it doesn't show there). Unless it was something we had discussed and I lost track?

Edit: Disregard I was looking at the wrong sender/Alert on*

@thc202
Copy link
Copy Markdown
Member

thc202 commented May 27, 2026

It can also be squashed (would make diffs easier IMO).

@kingthorin kingthorin force-pushed the adjust-java-type-usage branch 2 times, most recently from 97935db to 14dc813 Compare May 27, 2026 14:48
@kingthorin
Copy link
Copy Markdown
Member Author

Removed unrelated changes in httpsender/Alert on * and squashed.

@kingthorin kingthorin force-pushed the adjust-java-type-usage branch from 14dc813 to 4cf6425 Compare May 27, 2026 14:54
Comment thread httpfuzzerprocessor/addCacheBusting.js Outdated
@kingthorin kingthorin force-pushed the adjust-java-type-usage branch 2 times, most recently from a8b939b to b6335c1 Compare May 27, 2026 15:48
@thc202 thc202 requested a review from Copilot May 27, 2026 16:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces repeated fully qualified Java class access in community JavaScript scripts by hoisting Java classes into top-level Java.type(...) bindings, aligning scripts with existing ZAP scripting conventions and addressing classloader performance concerns.

Changes:

  • Replaced inline fully qualified Java references with reusable Java.type(...) bindings across active, passive, HTTP sender, targeted, standalone, extender, and session scripts.
  • Updated static/enum references to use the new bindings.
  • Added a changelog entry for Issue 9187.

Reviewed changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
CHANGELOG.md Documents the classloader performance cleanup.
active/OpenModelContextProtocolServer.js Hoists Apache URI class binding.
authentication/DjangoAuthentication.js Moves authentication Java class imports to module scope.
extender/ZAP onEvent Handler.js Hoists ZAP event bus class binding.
extender/arpSyndicateSubdomainDiscovery.js Hoists ZAP event bus class binding.
httpfuzzerprocessor/addCacheBusting.js Hoists HTML parameter class/type bindings.
httpfuzzerprocessor/add_msgs_sites_tree.js Hoists history reference and event queue bindings.
httpsender/Alert on HTTP Response Code Errors.js Hoists alert/history/integer bindings and updates evidence handling.
httpsender/Alert on Unexpected Content Types.js Hoists alert/history/integer bindings.
httpsender/Capture and Replace Anti CSRF Token.js Hoists ScriptVars and parameter type bindings.
httpsender/greenbone-maintain-auth.js Hoists HTML parameter type binding.
httpsender/inject_js_in_html_page.js Hoists file/string Java class bindings.
httpsender/keep-cookies-going.js Hoists HTML parameter type binding.
httpsender/maintain-jwt.js Hoists HTML parameter type binding.
other/af-plans/juiceshop-selenium-auth/JuiceShopAuthentication.js Hoists Selenium extension binding.
other/af-plans/juiceshop-selenium-auth/JuiceShopReset.js Hoists user management extension binding.
other/af-plans/juiceshop-selenium-auth/JuiceShopSession.js Hoists HTML parameter type binding.
passive/Report non static sites.js Hoists passive scanner class binding and updates example comment.
passive/Telerik Using Poor Crypto.js Hoists Base64 and Alert bindings.
passive/f5_bigip_cookie_internal_ip.js Hoists integer and address bindings.
selenium/FillOTPInMFA.js Hoists Selenium and thread bindings.
session/Juice Shop Session Management.js Hoists HTML parameter type binding.
standalone/Active scan rule list.js Hoists active scan extension binding.
standalone/Juice shop authentication by form.js Hoists Selenium extension binding.
standalone/Juice shop authentication by google.js Hoists Selenium extension binding.
standalone/Loop through alerts.js Hoists alert extension and alert bindings.
standalone/Loop through history table.js Hoists history extension binding.
standalone/alertAndPluginDetails.js Hoists alert/passive scan/plugin bindings.
standalone/domainFinder.js Hoists InetAddress binding.
standalone/historySourceTagger.js Hoists ScriptVars and history extension bindings.
standalone/load_function_example.js Hoists system property binding.
standalone/scan_rule_list.js Hoists active/passive scan extension bindings.
targeted/Remove 302s.js Hoists purge sites binding.
targeted/SQLMapCommandGenerator.js Hoists clipboard-related bindings.
targeted/Search www.xssposed.org for known XSS.js Hoists DesktopUtils binding.
targeted/curl_command_generator.js Hoists clipboard-related bindings.
targeted/cve-2021-22214.js Hoists Alert binding.
targeted/cve-2021-41773-apache-path-trav.js Hoists Alert binding.
targeted/json_csrf_poc_generator.js Hoists header and clipboard bindings.
targeted/request_to_xml.js Hoists HTTP header binding.
targeted/search cvedetails using target server header.js Hoists DesktopUtils binding.
variant/CompoundCookies.js Hoists HTML parameter type binding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread httpsender/Alert on HTTP Response Code Errors.js
@thc202
Copy link
Copy Markdown
Member

thc202 commented May 27, 2026

Thank you!

Signed-off-by: kingthorin <kingthorin@users.noreply.github.com>
@kingthorin kingthorin force-pushed the adjust-java-type-usage branch from b6335c1 to 3a975c8 Compare May 28, 2026 09:14
@thc202 thc202 requested a review from psiinon May 28, 2026 09:16
@psiinon psiinon merged commit 07d3e63 into zaproxy:main May 28, 2026
9 checks passed
@kingthorin kingthorin deleted the adjust-java-type-usage branch May 28, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants