Skip to content

Commit 62f0519

Browse files
committed
Added standalone script 'PrivateMethodAccess.js'
Signed-off-by: Simon Bennetts <psiinon@gmail.com>
1 parent 4e0d979 commit 62f0519

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this add-on will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

66
## [Unreleased]
7+
### Added
8+
- Standalone script 'PrivateMethodAccess.js'
79
### Changed
810
- Add cautionary note to help and readme.
911
### Fixed

standalone/PrivateMethodAccess.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
When writing scripts you may find that you need to access private java methods.
3+
This script shows how you can do this easily.
4+
5+
WARNING: we do not consider private methods to be part of the code API, so they may
6+
be changed or removed at any time.
7+
If you think you have a strong case for making a method public then either:
8+
9+
1. Ask on the ZAP Dev Group: https://groups.google.com/group/zaproxy-develop
10+
2. Submit a pull request making the change (but be prepared for it to be rejected)
11+
12+
*/
13+
14+
var ExtensionAlert = Java.type(
15+
"org.zaproxy.zap.extension.alert.ExtensionAlert"
16+
);
17+
var MethodUtils = Java.type("org.apache.commons.lang3.reflect.MethodUtils");
18+
19+
extAlert = control.getExtensionLoader().getExtension(ExtensionAlert);
20+
21+
print(extAlert);
22+
23+
// Note that there are a lot of other methods in MethodUtils, e.g. for passing parameters.
24+
print(MethodUtils.invokeMethod(extAlert, true, "getAlertPanel"));

0 commit comments

Comments
 (0)