From de344bba7c19244c91ea83b2486e6d6609014020 Mon Sep 17 00:00:00 2001 From: Simon Bennetts Date: Fri, 1 Mar 2024 14:37:37 +0000 Subject: [PATCH] Menu Restructure Signed-off-by: Simon Bennetts --- addOns/bruteforce/CHANGELOG.md | 3 +- addOns/bruteforce/bruteforce.gradle.kts | 2 +- .../bruteforce/PopupMenuBruteForceSite.java | 5 + addOns/client/CHANGELOG.md | 3 +- addOns/client/client.gradle.kts | 4 +- .../addon/client/spider/PopupMenuSpider.java | 9 ++ addOns/commonlib/CHANGELOG.md | 3 + .../zaproxy/addon/commonlib/MenuWeights.java | 115 ++++++++++++++++++ addOns/diff/CHANGELOG.md | 3 +- addOns/diff/diff.gradle.kts | 8 ++ .../zap/extension/diff/ExtensionDiff.java | 3 + .../zap/extension/diff/PopupMenuDiff.java | 9 ++ addOns/encoder/CHANGELOG.md | 2 + addOns/encoder/encoder.gradle.kts | 9 ++ .../addon/encoder/PopupEncoderMenu.java | 5 + addOns/exim/CHANGELOG.md | 1 + addOns/exim/exim.gradle.kts | 2 +- .../zaproxy/addon/exim/PopupMenuCopyUrls.java | 5 + .../exim/PopupMenuExportContextUrls.java | 6 + .../exim/PopupMenuExportSelectedUrls.java | 6 + .../addon/exim/PopupMenuExportUrls.java | 5 + .../addon/exim/PopupMenuSaveRawMessage.java | 5 + .../addon/exim/PopupMenuSaveXmlMessage.java | 5 + .../exim/har/PopupMenuItemSaveHarMessage.java | 5 + .../addon/exim/resources/Messages.properties | 16 +-- addOns/fuzz/CHANGELOG.md | 2 + addOns/fuzz/fuzz.gradle.kts | 2 +- .../ui/HttpFuzzAttackPopupMenuItem.java | 9 ++ addOns/invoke/CHANGELOG.md | 3 +- addOns/invoke/invoke.gradle.kts | 11 ++ .../extension/invoke/PopupMenuInvokers.java | 5 + addOns/paramdigger/CHANGELOG.md | 3 + addOns/paramdigger/paramdigger.gradle.kts | 2 +- .../paramdigger/gui/PopupMenuParamDigger.java | 9 ++ addOns/portscan/CHANGELOG.md | 3 + addOns/portscan/portscan.gradle.kts | 2 +- .../extension/portscan/PopupMenuPortScan.java | 5 + addOns/requester/CHANGELOG.md | 1 + addOns/requester/requester.gradle.kts | 9 ++ .../internal/PopupMenuResendMessage.java | 5 + .../internal/RightClickMsgMenuRequester.java | 5 + addOns/scripts/CHANGELOG.md | 2 + addOns/scripts/scripts.gradle.kts | 8 +- .../InvokeScriptWithHttpMessagePopupMenu.java | 5 + .../scripts/SyntaxHighlightTextArea.java | 53 ++++++-- addOns/selenium/CHANGELOG.md | 3 +- addOns/selenium/selenium.gradle.kts | 4 + .../selenium/PopupMenuOpenInBrowser.java | 5 + addOns/spider/CHANGELOG.md | 2 + addOns/spider/spider.gradle.kts | 2 +- .../spider/PopupMenuItemSpiderDialog.java | 9 ++ .../PopupMenuItemSpiderDialogWithContext.java | 5 + addOns/spiderAjax/CHANGELOG.md | 1 + addOns/spiderAjax/spiderAjax.gradle.kts | 2 +- .../spiderAjax/PopupMenuAjaxSite.java | 9 ++ .../PopupMenuItemSpiderDialogWithContext.java | 5 + addOns/websocket/CHANGELOG.md | 2 + .../ui/PopupExcludeWebSocketContextMenu.java | 5 + .../ui/PopupIncludeWebSocketContextMenu.java | 5 + addOns/websocket/websocket.gradle.kts | 8 ++ addOns/zest/CHANGELOG.md | 3 + .../zest/menu/ZestAddToScriptMenu.java | 5 + .../zest/menu/ZestAddToScriptPopupMenu.java | 5 + .../menu/ZestRecordFromNodePopupMenu.java | 5 + addOns/zest/zest.gradle.kts | 2 +- 65 files changed, 437 insertions(+), 33 deletions(-) create mode 100644 addOns/commonlib/src/main/java/org/zaproxy/addon/commonlib/MenuWeights.java diff --git a/addOns/bruteforce/CHANGELOG.md b/addOns/bruteforce/CHANGELOG.md index 29d7ebdd405..6b7210a96c1 100644 --- a/addOns/bruteforce/CHANGELOG.md +++ b/addOns/bruteforce/CHANGELOG.md @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased - +### Added +- Support for menu weights (Issue 8369) ## [15] - 2023-10-12 ### Changed diff --git a/addOns/bruteforce/bruteforce.gradle.kts b/addOns/bruteforce/bruteforce.gradle.kts index 12cb524c0bd..fe516040dba 100644 --- a/addOns/bruteforce/bruteforce.gradle.kts +++ b/addOns/bruteforce/bruteforce.gradle.kts @@ -13,7 +13,7 @@ zapAddOn { dependencies { addOns { register("commonlib") { - version.set(">= 1.13.0 & < 2.0.0") + version.set(">= 1.23.0 & < 2.0.0") } } } diff --git a/addOns/bruteforce/src/main/java/org/zaproxy/zap/extension/bruteforce/PopupMenuBruteForceSite.java b/addOns/bruteforce/src/main/java/org/zaproxy/zap/extension/bruteforce/PopupMenuBruteForceSite.java index af362a98592..3a56ad20d91 100644 --- a/addOns/bruteforce/src/main/java/org/zaproxy/zap/extension/bruteforce/PopupMenuBruteForceSite.java +++ b/addOns/bruteforce/src/main/java/org/zaproxy/zap/extension/bruteforce/PopupMenuBruteForceSite.java @@ -22,6 +22,7 @@ import javax.swing.ImageIcon; import org.parosproxy.paros.Constant; import org.parosproxy.paros.model.SiteNode; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.view.messagecontainer.http.HttpMessageContainer; import org.zaproxy.zap.view.popup.PopupMenuItemSiteNodeContainer; @@ -57,6 +58,10 @@ public int getParentMenuIndex() { return ATTACK_MENU_INDEX; } + public int getParentWeight() { + return MenuWeights.MENU_ATTACK_WEIGHT; + } + @Override public void performAction(SiteNode node) { // Loop up to get the top parent diff --git a/addOns/client/CHANGELOG.md b/addOns/client/CHANGELOG.md index 3ebf3166e8b..006a3dc0be4 100644 --- a/addOns/client/CHANGELOG.md +++ b/addOns/client/CHANGELOG.md @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased - +### Added +- Support for menu weights (Issue 8369) ## [0.8.0] - 2024-01-16 ### Changed diff --git a/addOns/client/client.gradle.kts b/addOns/client/client.gradle.kts index 3565454430b..45847bd8f78 100644 --- a/addOns/client/client.gradle.kts +++ b/addOns/client/client.gradle.kts @@ -28,7 +28,9 @@ zapAddOn { register("network") { version.set(">=0.8.0") } - register("commonlib") + register("commonlib") { + version.set(">=1.23.0") + } } } } diff --git a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/PopupMenuSpider.java b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/PopupMenuSpider.java index f79e15e1bcc..7558a455087 100644 --- a/addOns/client/src/main/java/org/zaproxy/addon/client/spider/PopupMenuSpider.java +++ b/addOns/client/src/main/java/org/zaproxy/addon/client/spider/PopupMenuSpider.java @@ -22,6 +22,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.model.SiteNode; import org.zaproxy.addon.client.ExtensionClientIntegration; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.view.messagecontainer.http.HttpMessageContainer; import org.zaproxy.zap.view.popup.PopupMenuItemSiteNodeContainer; @@ -52,6 +53,14 @@ public int getParentMenuIndex() { return ATTACK_MENU_INDEX; } + public int getParentWeight() { + return MenuWeights.MENU_ATTACK_WEIGHT; + } + + public int getWeight() { + return MenuWeights.MENU_ATTACK_CLIENT_WEIGHT; + } + @Override public void performAction(SiteNode node) { if (node != null) { diff --git a/addOns/commonlib/CHANGELOG.md b/addOns/commonlib/CHANGELOG.md index da0e38f4017..03c7ade822d 100644 --- a/addOns/commonlib/CHANGELOG.md +++ b/addOns/commonlib/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Added +- Support for menu weights (Issue 8369) + ### Changed - Maintenance changes. diff --git a/addOns/commonlib/src/main/java/org/zaproxy/addon/commonlib/MenuWeights.java b/addOns/commonlib/src/main/java/org/zaproxy/addon/commonlib/MenuWeights.java new file mode 100644 index 00000000000..d0fa079de58 --- /dev/null +++ b/addOns/commonlib/src/main/java/org/zaproxy/addon/commonlib/MenuWeights.java @@ -0,0 +1,115 @@ +/* + * Zed Attack Proxy (ZAP) and its related class files. + * + * ZAP is an HTTP/HTTPS proxy for assessing web application security. + * + * Copyright 2024 The ZAP Development Team + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.zaproxy.addon.commonlib; + +/** + * This class is duplicated from the core (org.zaproxy.zap.view.popup) so that it can be used prior + * to a full release. + * + * @since 1.23.0 + */ +public class MenuWeights { + + public static final int MENU_DEFAULT_WEIGHT = 1000; + + // Main Sites / History etc menus + public static final int MENU_ATTACK_WEIGHT = 29090; + public static final int MENU_BREAK_WEIGHT = 29080; + public static final int MENU_DELETE_WEIGHT = 29070; + public static final int MENU_EXCLUDE_WEIGHT = 29060; + public static final int MENU_FIND_WEIGHT = 29050; + public static final int MENU_ENCODE_WEIGHT = 29040; + public static final int MENU_RUN_APP_WEIGHT = 29030; + public static final int MENU_NEW_ALERT_WEIGHT = 29020; + public static final int MENU_ALERTS_NODE_WEIGHT = 29010; + // --- + public static final int MENU_INC_CONTEXT_WEIGHT = 27090; + public static final int MENU_INC_SITE_CONTEXT_WEIGHT = 27080; + public static final int MENU_EXC_CONTEXT_WEIGHT = 27070; + public static final int MENU_FLAG_CONTEXT_WEIGHT = 27060; + public static final int MENU_INC_CHANNEL_CONTEXT_WEIGHT = 27050; + public static final int MENU_EXC_CHANNEL_CONTEXT_WEIGHT = 27040; + // --- + public static final int MENU_OPEN_REQUEST_WEIGHT = 25060; + public static final int MENU_OPEN_REQUESTER_WEIGHT = 25050; + public static final int MENU_OPEN_BROWSER_WEIGHT = 25040; + public static final int MENU_OPEN_SYS_BROWSER_WEIGHT = 25030; + // --- + public static final int MENU_SITES_SHOW_WEIGHT = 23060; + public static final int MENU_HISTORY_SHOW_WEIGHT = 23060; + public static final int MENU_HISTORY_TAGS_WEIGHT = 23040; + public static final int MENU_HISTORY_JUMP_WEIGHT = 23020; + // --- + public static final int MENU_SCRIPT_INVOKE_WEIGHT = 21060; + public static final int MENU_SCRIPT_ZEST_ADD_WEIGHT = 21040; + public static final int MENU_SCRIPT_ZEST_RECORD_WEIGHT = 21020; + // --- + // Section typically only used in work window + public static final int MENU_UNDO_WEIGHT = 19060; + public static final int MENU_REDO_WEIGHT = 19040; + // --- + // Section typically only used in work window + public static final int MENU_EDIT_CUT_WEIGHT = 17080; + public static final int MENU_EDIT_COPY_WEIGHT = 17060; + public static final int MENU_EDIT_PASTE_WEIGHT = 17040; + public static final int MENU_EDIT_DELETE_WEIGHT = 17020; + // --- + // Section typically only used in work window + public static final int MENU_SECECT_ALL_WEIGHT = 15050; + // --- + public static final int MENU_COPY_URLS_WEIGHT = 13080; + public static final int MENU_SAVE_URLS_WEIGHT = 13070; + public static final int MENU_SAVE_ALL_URLS_WEIGHT = 13060; + public static final int MENU_SAVE_RAW_WEIGHT = 13050; + public static final int MENU_SAVE_XML_WEIGHT = 13040; + public static final int MENU_SAVE_HAR_WEIGHT = 13030; + // --- + public static final int MENU_COMPARE_REQ_WEIGHT = 11060; + public static final int MENU_COMPARE_RESP_WEIGHT = 11040; + // --- + // Anything under 1000 will appear in the lowest section + public static final int MENU_SYNTAX_WEIGHT = 60; + public static final int MENU_VIEW_WEIGHT = 40; + public static final int MENU_SITE_REFRESH_WEIGHT = 20; + + // Contexts menu + public static final int MENU_CONTEXT_ACTIVE_WEIGHT = 11680; + public static final int MENU_CONTEXT_AJAX_WEIGHT = 11660; + public static final int MENU_CONTEXT_SPIDER_WEIGHT = 11640; + // --- + public static final int MENU_CONTEXT_EXPORT_WEIGHT = 11460; + public static final int MENU_CONTEXT_EXPORT_URLS_WEIGHT = 11440; + // --- + public static final int MENU_CONTEXT_SCOPE_WEIGHT = 11260; + public static final int MENU_CONTEXT_DELETE_WEIGHT = 11240; + + // Attack menus + public static final int MENU_ATTACK_ACTIVE_WEIGHT = 1190; + public static final int MENU_ATTACK_AJAX_WEIGHT = 1180; + public static final int MENU_ATTACK_CLIENT_WEIGHT = 1170; + public static final int MENU_ATTACK_SPIDER_WEIGHT = 1160; + public static final int MENU_ATTACK_FUZZ_WEIGHT = 1150; + public static final int MENU_ATTACK_DIGGER_WEIGHT = 1140; + + // Exclude From menus + public static final int MENU_EXCLUDE_PROXY_WEIGHT = 1180; + public static final int MENU_EXCLUDE_SPIDER_WEIGHT = 1160; + public static final int MENU_EXCLUDE_SCANNER_WEIGHT = 1140; +} diff --git a/addOns/diff/CHANGELOG.md b/addOns/diff/CHANGELOG.md index 09d694e9f53..4cb787729b3 100644 --- a/addOns/diff/CHANGELOG.md +++ b/addOns/diff/CHANGELOG.md @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased - +### Added +- Support for menu weights (Issue 8369) ## [14] - 2023-10-12 ### Changed diff --git a/addOns/diff/diff.gradle.kts b/addOns/diff/diff.gradle.kts index 06c4342494a..8e712543f66 100644 --- a/addOns/diff/diff.gradle.kts +++ b/addOns/diff/diff.gradle.kts @@ -9,10 +9,18 @@ zapAddOn { manifest { author.set("ZAP Dev Team") url.set("https://www.zaproxy.org/docs/desktop/addons/diff/") + dependencies { + addOns { + register("commonlib") { + version.set(">=1.23.0") + } + } + } } } dependencies { + zapAddOn("commonlib") implementation("com.googlecode.java-diff-utils:diffutils:1.3.0") } diff --git a/addOns/diff/src/main/java/org/zaproxy/zap/extension/diff/ExtensionDiff.java b/addOns/diff/src/main/java/org/zaproxy/zap/extension/diff/ExtensionDiff.java index 6c2ce2551fa..dca5cd20c06 100644 --- a/addOns/diff/src/main/java/org/zaproxy/zap/extension/diff/ExtensionDiff.java +++ b/addOns/diff/src/main/java/org/zaproxy/zap/extension/diff/ExtensionDiff.java @@ -27,6 +27,7 @@ import org.parosproxy.paros.extension.ExtensionAdaptor; import org.parosproxy.paros.extension.ExtensionHook; import org.parosproxy.paros.network.HttpMessage; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.extension.diff.ZapDiffRowGenerator.Builder; import org.zaproxy.zap.extension.diff.diff_match_patch.Diff; @@ -73,6 +74,7 @@ private PopupMenuDiff getPopupMenuDiffRequests() { popupMenuDiffRequests = new PopupMenuDiff( Constant.messages.getString("diff.diff.req.popup"), this, true); + popupMenuDiffRequests.setWeight(MenuWeights.MENU_COMPARE_REQ_WEIGHT); } return popupMenuDiffRequests; } @@ -82,6 +84,7 @@ private PopupMenuDiff getPopupMenuDiffResponses() { popupMenuDiffResponses = new PopupMenuDiff( Constant.messages.getString("diff.diff.resp.popup"), this, false); + popupMenuDiffResponses.setWeight(MenuWeights.MENU_COMPARE_RESP_WEIGHT); } return popupMenuDiffResponses; } diff --git a/addOns/diff/src/main/java/org/zaproxy/zap/extension/diff/PopupMenuDiff.java b/addOns/diff/src/main/java/org/zaproxy/zap/extension/diff/PopupMenuDiff.java index e71b2cfb853..cb9595f2371 100644 --- a/addOns/diff/src/main/java/org/zaproxy/zap/extension/diff/PopupMenuDiff.java +++ b/addOns/diff/src/main/java/org/zaproxy/zap/extension/diff/PopupMenuDiff.java @@ -33,6 +33,7 @@ public class PopupMenuDiff extends PopupMenuItemHistoryReferenceContainer { private static final long serialVersionUID = 1L; private ExtensionDiff ext = null; private boolean request = false; + private int weight; /** * @param label @@ -84,4 +85,12 @@ public void performAction(HistoryReference href) { public boolean isSafe() { return true; } + + public int getWeight() { + return weight; + } + + public void setWeight(int weight) { + this.weight = weight; + } } diff --git a/addOns/encoder/CHANGELOG.md b/addOns/encoder/CHANGELOG.md index 2513a3a6d00..e4c152c5a55 100644 --- a/addOns/encoder/CHANGELOG.md +++ b/addOns/encoder/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Added +- Support for menu weights (Issue 8369) ### Changed - Maintenance changes. diff --git a/addOns/encoder/encoder.gradle.kts b/addOns/encoder/encoder.gradle.kts index e95dc3314ef..f0151830bff 100644 --- a/addOns/encoder/encoder.gradle.kts +++ b/addOns/encoder/encoder.gradle.kts @@ -9,6 +9,13 @@ zapAddOn { manifest { author.set("ZAP Dev Team") url.set("https://www.zaproxy.org/docs/desktop/addons/encode-decode-hash/") + dependencies { + addOns { + register("commonlib") { + version.set(">=1.23.0") + } + } + } } } @@ -21,5 +28,7 @@ crowdin { } dependencies { + zapAddOn("commonlib") + testImplementation(project(":testutils")) } diff --git a/addOns/encoder/src/main/java/org/zaproxy/addon/encoder/PopupEncoderMenu.java b/addOns/encoder/src/main/java/org/zaproxy/addon/encoder/PopupEncoderMenu.java index afa2c78f94f..7e43669830d 100644 --- a/addOns/encoder/src/main/java/org/zaproxy/addon/encoder/PopupEncoderMenu.java +++ b/addOns/encoder/src/main/java/org/zaproxy/addon/encoder/PopupEncoderMenu.java @@ -23,6 +23,7 @@ import javax.swing.text.JTextComponent; import org.parosproxy.paros.Constant; import org.parosproxy.paros.extension.ExtensionPopupMenuItem; +import org.zaproxy.addon.commonlib.MenuWeights; public class PopupEncoderMenu extends ExtensionPopupMenuItem { @@ -71,4 +72,8 @@ private boolean isInvokerFromEncodeDecode(Component invoker) { return invoker.getName().equals(EncodeDecodeDialog.ENCODE_DECODE_FIELD) || invoker.getName().equals(EncodeDecodeDialog.ENCODE_DECODE_RESULTFIELD); } + + public int getWeight() { + return MenuWeights.MENU_ENCODE_WEIGHT; + } } diff --git a/addOns/exim/CHANGELOG.md b/addOns/exim/CHANGELOG.md index 8dd5a8a47fe..27cfb01b5d0 100644 --- a/addOns/exim/CHANGELOG.md +++ b/addOns/exim/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased ### Added - Initial PCAP import support (Issue 4812). +- Support for menu weights (Issue 8369) ### Changed - Maintenance changes. diff --git a/addOns/exim/exim.gradle.kts b/addOns/exim/exim.gradle.kts index d6adc0c4042..0373340fa6c 100644 --- a/addOns/exim/exim.gradle.kts +++ b/addOns/exim/exim.gradle.kts @@ -31,7 +31,7 @@ zapAddOn { dependencies { addOns { register("commonlib") { - version.set(">= 1.19.0 & < 2.0.0") + version.set(">= 1.23.0 & < 2.0.0") } } } diff --git a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuCopyUrls.java b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuCopyUrls.java index 8f4b4b16613..cdeb23009b0 100644 --- a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuCopyUrls.java +++ b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuCopyUrls.java @@ -26,6 +26,7 @@ import java.awt.datatransfer.Transferable; import java.util.List; import org.parosproxy.paros.model.HistoryReference; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.utils.Stats; import org.zaproxy.zap.view.popup.PopupMenuItemHistoryReferenceContainer; @@ -71,4 +72,8 @@ public boolean isSafe() { public void lostOwnership(Clipboard clipboard, Transferable contents) { // Ignore } + + public int getWeight() { + return MenuWeights.MENU_COPY_URLS_WEIGHT; + } } diff --git a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportContextUrls.java b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportContextUrls.java index 62fd047b6dd..56d733ab33c 100644 --- a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportContextUrls.java +++ b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportContextUrls.java @@ -30,6 +30,7 @@ import org.parosproxy.paros.extension.Extension; import org.parosproxy.paros.model.SiteNode; import org.parosproxy.paros.view.SiteMapPanel; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.model.Context; import org.zaproxy.zap.utils.Stats; @@ -89,4 +90,9 @@ private void getOutputSet(Context ctx, SortedSet outputSet) { outputSet.add(node.getHistoryReference().getURI().toString()); } } + + @Override + public int getWeight() { + return MenuWeights.MENU_CONTEXT_EXPORT_URLS_WEIGHT; + } } diff --git a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportSelectedUrls.java b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportSelectedUrls.java index d921bfa25fd..6c0d1ad7f6c 100644 --- a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportSelectedUrls.java +++ b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportSelectedUrls.java @@ -30,6 +30,7 @@ import org.apache.commons.lang3.ArrayUtils; import org.parosproxy.paros.extension.Extension; import org.parosproxy.paros.model.SiteNode; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.utils.Stats; public class PopupMenuExportSelectedUrls extends PopupMenuExportUrls { @@ -79,4 +80,9 @@ private SortedSet getOutputSet(TreePath[] startingPoints) { } return outputSet; } + + @Override + public int getWeight() { + return MenuWeights.MENU_SAVE_URLS_WEIGHT; + } } diff --git a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportUrls.java b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportUrls.java index 9c4db611990..0b3cb1291dd 100644 --- a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportUrls.java +++ b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuExportUrls.java @@ -36,6 +36,7 @@ import org.parosproxy.paros.extension.Extension; import org.parosproxy.paros.extension.ExtensionPopupMenuItem; import org.parosproxy.paros.model.SiteNode; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.utils.Stats; import org.zaproxy.zap.view.widgets.WritableFileChooser; @@ -186,4 +187,8 @@ public void approveSelection() { } return null; } + + public int getWeight() { + return MenuWeights.MENU_SAVE_ALL_URLS_WEIGHT; + } } diff --git a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuSaveRawMessage.java b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuSaveRawMessage.java index 30ff7120bd6..97270a561aa 100644 --- a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuSaveRawMessage.java +++ b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuSaveRawMessage.java @@ -29,6 +29,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.network.HttpMessage; import org.parosproxy.paros.view.View; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.utils.Stats; public class PopupMenuSaveRawMessage extends AbstractPopupMenuSaveMessage { @@ -107,4 +108,8 @@ private static void writeToFile( Stats.incCounter(STATS_RAW_FILE_MSG_ERROR + "." + messageComponent.name()); } } + + public int getWeight() { + return MenuWeights.MENU_SAVE_RAW_WEIGHT; + } } diff --git a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuSaveXmlMessage.java b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuSaveXmlMessage.java index a97e22b7d65..338965377df 100644 --- a/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuSaveXmlMessage.java +++ b/addOns/exim/src/main/java/org/zaproxy/addon/exim/PopupMenuSaveXmlMessage.java @@ -34,6 +34,7 @@ import org.parosproxy.paros.view.View; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.utils.Stats; import org.zaproxy.zap.utils.XmlUtils; @@ -137,4 +138,8 @@ private static void writeToFile( Stats.incCounter(STATS_XML_FILE_MSG_ERROR + "." + messageComponent.name()); } } + + public int getWeight() { + return MenuWeights.MENU_SAVE_XML_WEIGHT; + } } diff --git a/addOns/exim/src/main/java/org/zaproxy/addon/exim/har/PopupMenuItemSaveHarMessage.java b/addOns/exim/src/main/java/org/zaproxy/addon/exim/har/PopupMenuItemSaveHarMessage.java index 7cdb608587d..96433f18984 100644 --- a/addOns/exim/src/main/java/org/zaproxy/addon/exim/har/PopupMenuItemSaveHarMessage.java +++ b/addOns/exim/src/main/java/org/zaproxy/addon/exim/har/PopupMenuItemSaveHarMessage.java @@ -34,6 +34,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.network.HttpMessage; import org.parosproxy.paros.view.View; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.addon.exim.EximFileChooser; import org.zaproxy.addon.exim.ExtensionExim; import org.zaproxy.zap.utils.HarUtils; @@ -121,4 +122,8 @@ private static File getOutputFile() { } return null; } + + public int getWeight() { + return MenuWeights.MENU_SAVE_HAR_WEIGHT; + } } diff --git a/addOns/exim/src/main/resources/org/zaproxy/addon/exim/resources/Messages.properties b/addOns/exim/src/main/resources/org/zaproxy/addon/exim/resources/Messages.properties index 1e97880dd59..df5fe84899e 100644 --- a/addOns/exim/src/main/resources/org/zaproxy/addon/exim/resources/Messages.properties +++ b/addOns/exim/src/main/resources/org/zaproxy/addon/exim/resources/Messages.properties @@ -32,7 +32,7 @@ exim.file.save.error = Error saving file to {0}. exim.har.file.description = HTTP Archive File (*.har) exim.har.file.import.error = Could not import the file {0} exim.har.file.save.error = Error saving file to {0}. -exim.har.popup.option = Save Selected Entries as HAR (HTTP Archive File) +exim.har.popup.option = Save as HAR... exim.har.topmenu.import.importhar = Import HAR (HTTP Archive File) exim.har.topmenu.import.importhar.tooltip = Import a HTTP Archive File and add the messages to the sites tree and history panel. exim.import.pcap.choosefile.filter.pcap.description = PCAP file (*.pcap) @@ -56,14 +56,14 @@ exim.importurls.warn.scheme = "{0}" does not have a scheme. exim.menu.copyurls.popup = Copy URLs exim.menu.export = Export -exim.menu.export.context.urls = Export URLs for Context(s) -exim.menu.export.messages.popup = Export Messages to File... +exim.menu.export.context.urls = Save URLs... +exim.menu.export.messages.popup = Save Messages... exim.menu.export.messages.select.warning = Select HTTP messages in History panel before export to file. exim.menu.export.mnemonic = E -exim.menu.export.popup = Export All URLs to File... +exim.menu.export.popup = Save All URLs... exim.menu.export.popup.context.error = Please select a Context. -exim.menu.export.popup.selected = Export Selected URLs to File... -exim.menu.export.responses.popup = Export Response(s) to File... +exim.menu.export.popup.selected = Save URLs... +exim.menu.export.responses.popup = Save Response(s)... exim.menu.export.urls.save.error = Error saving file to {0} exim.options.value.type.har = HAR (HTTP Archive File) @@ -84,9 +84,9 @@ exim.popup.option.response = Response exim.progress.currentimport = Importing: {0} exim.saveraw.file.description = Raw Binary (*.raw) -exim.saveraw.popup.option = Save Raw +exim.saveraw.popup.option = Save as Raw exim.savexml.file.description = XML with Base64 Encoded Components (*.xml) -exim.savexml.popup.option = Save XML +exim.savexml.popup.option = Save as XML exim.ui.name = Import/Export diff --git a/addOns/fuzz/CHANGELOG.md b/addOns/fuzz/CHANGELOG.md index 29b69396d32..fa4769ef710 100644 --- a/addOns/fuzz/CHANGELOG.md +++ b/addOns/fuzz/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Added +- Support for menu weights (Issue 8369) ### Changed - Maintenance changes. diff --git a/addOns/fuzz/fuzz.gradle.kts b/addOns/fuzz/fuzz.gradle.kts index 8ab4a251f24..3af6827b51c 100644 --- a/addOns/fuzz/fuzz.gradle.kts +++ b/addOns/fuzz/fuzz.gradle.kts @@ -12,7 +12,7 @@ zapAddOn { dependencies { addOns { register("commonlib") { - version.set(">= 1.13.0 & < 2.0.0") + version.set(">= 1.23.0 & < 2.0.0") } } } diff --git a/addOns/fuzz/src/main/java/org/zaproxy/zap/extension/fuzz/httpfuzzer/ui/HttpFuzzAttackPopupMenuItem.java b/addOns/fuzz/src/main/java/org/zaproxy/zap/extension/fuzz/httpfuzzer/ui/HttpFuzzAttackPopupMenuItem.java index aa9810b2a13..0c5b55e2fa8 100644 --- a/addOns/fuzz/src/main/java/org/zaproxy/zap/extension/fuzz/httpfuzzer/ui/HttpFuzzAttackPopupMenuItem.java +++ b/addOns/fuzz/src/main/java/org/zaproxy/zap/extension/fuzz/httpfuzzer/ui/HttpFuzzAttackPopupMenuItem.java @@ -21,6 +21,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.network.HttpMessage; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.extension.fuzz.ExtensionFuzz; import org.zaproxy.zap.extension.fuzz.FuzzerUIUtils; import org.zaproxy.zap.extension.fuzz.httpfuzzer.HttpFuzzer; @@ -60,6 +61,14 @@ public int getParentMenuIndex() { return ATTACK_MENU_INDEX; } + public int getParentWeight() { + return MenuWeights.MENU_ATTACK_WEIGHT; + } + + public int getWeight() { + return MenuWeights.MENU_ATTACK_FUZZ_WEIGHT; + } + @Override protected void performAction(HttpMessage httpMessage) { HttpFuzzer fuzzer = diff --git a/addOns/invoke/CHANGELOG.md b/addOns/invoke/CHANGELOG.md index df883f7607d..2abcb76ade2 100644 --- a/addOns/invoke/CHANGELOG.md +++ b/addOns/invoke/CHANGELOG.md @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased - +### Added +- Support for menu weights (Issue 8369) ## [14] - 2023-10-12 ### Changed diff --git a/addOns/invoke/invoke.gradle.kts b/addOns/invoke/invoke.gradle.kts index 0d1e28928e4..6120ad70ed8 100644 --- a/addOns/invoke/invoke.gradle.kts +++ b/addOns/invoke/invoke.gradle.kts @@ -9,5 +9,16 @@ zapAddOn { manifest { author.set("ZAP Dev Team") url.set("https://www.zaproxy.org/docs/desktop/addons/invoke-applications/") + dependencies { + addOns { + register("commonlib") { + version.set(">=1.23.0") + } + } + } } } + +dependencies { + zapAddOn("commonlib") +} diff --git a/addOns/invoke/src/main/java/org/zaproxy/zap/extension/invoke/PopupMenuInvokers.java b/addOns/invoke/src/main/java/org/zaproxy/zap/extension/invoke/PopupMenuInvokers.java index b3602eda46d..cfa5d00b658 100644 --- a/addOns/invoke/src/main/java/org/zaproxy/zap/extension/invoke/PopupMenuInvokers.java +++ b/addOns/invoke/src/main/java/org/zaproxy/zap/extension/invoke/PopupMenuInvokers.java @@ -21,6 +21,7 @@ import java.util.List; import org.parosproxy.paros.Constant; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.view.popup.PopupMenuHttpMessageContainer; public class PopupMenuInvokers extends PopupMenuHttpMessageContainer { @@ -62,4 +63,8 @@ public void setApps(List apps) { } add(confPopup); } + + public int getWeight() { + return MenuWeights.MENU_RUN_APP_WEIGHT; + } } diff --git a/addOns/paramdigger/CHANGELOG.md b/addOns/paramdigger/CHANGELOG.md index 99af2092ac8..9f75e0970fc 100644 --- a/addOns/paramdigger/CHANGELOG.md +++ b/addOns/paramdigger/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Added +- Support for menu weights (Issue 8369) + ### Changed - Maintenance changes. - Update minimum ZAP version to 2.14.0. diff --git a/addOns/paramdigger/paramdigger.gradle.kts b/addOns/paramdigger/paramdigger.gradle.kts index 46926d527f0..f2979f715f6 100644 --- a/addOns/paramdigger/paramdigger.gradle.kts +++ b/addOns/paramdigger/paramdigger.gradle.kts @@ -10,7 +10,7 @@ zapAddOn { dependencies { addOns { register("commonlib") { - version.set(">= 1.13.0 & < 2.0.0") + version.set(">= 1.23.0 & < 2.0.0") } } } diff --git a/addOns/paramdigger/src/main/java/org/zaproxy/addon/paramdigger/gui/PopupMenuParamDigger.java b/addOns/paramdigger/src/main/java/org/zaproxy/addon/paramdigger/gui/PopupMenuParamDigger.java index 31f190f5c0c..85da86c98e3 100644 --- a/addOns/paramdigger/src/main/java/org/zaproxy/addon/paramdigger/gui/PopupMenuParamDigger.java +++ b/addOns/paramdigger/src/main/java/org/zaproxy/addon/paramdigger/gui/PopupMenuParamDigger.java @@ -21,6 +21,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.network.HttpMessage; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.addon.paramdigger.ExtensionParamDigger; import org.zaproxy.zap.view.popup.PopupMenuItemHttpMessageContainer; @@ -51,6 +52,14 @@ public int getParentMenuIndex() { return ATTACK_MENU_INDEX; } + public int getParentWeight() { + return MenuWeights.MENU_ATTACK_WEIGHT; + } + + public int getWeight() { + return MenuWeights.MENU_ATTACK_DIGGER_WEIGHT; + } + @Override protected void performAction(HttpMessage httpMessage) { extension.showParamDiggerDialog(httpMessage); diff --git a/addOns/portscan/CHANGELOG.md b/addOns/portscan/CHANGELOG.md index cb462eb5cb0..3d3bb42bf7f 100644 --- a/addOns/portscan/CHANGELOG.md +++ b/addOns/portscan/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Added +- Support for menu weights (Issue 8369) + ### Changed - Update minimum ZAP version to 2.14.0. - Maintenance changes. diff --git a/addOns/portscan/portscan.gradle.kts b/addOns/portscan/portscan.gradle.kts index 868cedc1b48..ac40f3d4d73 100644 --- a/addOns/portscan/portscan.gradle.kts +++ b/addOns/portscan/portscan.gradle.kts @@ -16,7 +16,7 @@ zapAddOn { version.set(">=0.3.0") } register("commonlib") { - version.set(">= 1.13.0 & < 2.0.0") + version.set(">= 1.23.0 & < 2.0.0") } } } diff --git a/addOns/portscan/src/main/java/org/zaproxy/zap/extension/portscan/PopupMenuPortScan.java b/addOns/portscan/src/main/java/org/zaproxy/zap/extension/portscan/PopupMenuPortScan.java index 8f3f5468a13..befca0fe9b6 100644 --- a/addOns/portscan/src/main/java/org/zaproxy/zap/extension/portscan/PopupMenuPortScan.java +++ b/addOns/portscan/src/main/java/org/zaproxy/zap/extension/portscan/PopupMenuPortScan.java @@ -22,6 +22,7 @@ import javax.swing.ImageIcon; import org.parosproxy.paros.Constant; import org.parosproxy.paros.model.SiteNode; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.view.messagecontainer.http.HttpMessageContainer; import org.zaproxy.zap.view.popup.PopupMenuItemSiteNodeContainer; @@ -55,6 +56,10 @@ public int getParentMenuIndex() { return ATTACK_MENU_INDEX; } + public int getParentWeight() { + return MenuWeights.MENU_ATTACK_WEIGHT; + } + void setExtension(ExtensionPortScan extension) { this.extension = extension; } diff --git a/addOns/requester/CHANGELOG.md b/addOns/requester/CHANGELOG.md index 7071f2e5aa5..72298eac834 100644 --- a/addOns/requester/CHANGELOG.md +++ b/addOns/requester/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased ## Added - Button to lowercase request header names (Issue 8176). +- Support for menu weights (Issue 8369) ## [7.4.0] - 2023-10-12 ### Added diff --git a/addOns/requester/requester.gradle.kts b/addOns/requester/requester.gradle.kts index f2fb9caf31f..9874e463af3 100644 --- a/addOns/requester/requester.gradle.kts +++ b/addOns/requester/requester.gradle.kts @@ -10,6 +10,13 @@ zapAddOn { manifest { author.set("Surikato and the ZAP Dev Team") url.set("https://www.zaproxy.org/docs/desktop/addons/requester/") + dependencies { + addOns { + register("commonlib") { + version.set(">=1.23.0") + } + } + } helpSet { baseName.set("help%LC%.helpset") @@ -37,5 +44,7 @@ spotless { } dependencies { + zapAddOn("commonlib") + testImplementation(project(":testutils")) } diff --git a/addOns/requester/src/main/java/org/zaproxy/addon/requester/internal/PopupMenuResendMessage.java b/addOns/requester/src/main/java/org/zaproxy/addon/requester/internal/PopupMenuResendMessage.java index 3f5cc66c1a2..3b04423663d 100644 --- a/addOns/requester/src/main/java/org/zaproxy/addon/requester/internal/PopupMenuResendMessage.java +++ b/addOns/requester/src/main/java/org/zaproxy/addon/requester/internal/PopupMenuResendMessage.java @@ -23,6 +23,7 @@ import java.util.function.Consumer; import javax.swing.Icon; import org.parosproxy.paros.network.HttpMessage; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.view.popup.PopupMenuItemHttpMessageContainer; @SuppressWarnings("serial") @@ -45,4 +46,8 @@ public PopupMenuResendMessage( protected void performAction(HttpMessage message) { showResendDialogue.accept(message.cloneRequest()); } + + public int getWeight() { + return MenuWeights.MENU_OPEN_REQUEST_WEIGHT; + } } diff --git a/addOns/requester/src/main/java/org/zaproxy/addon/requester/internal/RightClickMsgMenuRequester.java b/addOns/requester/src/main/java/org/zaproxy/addon/requester/internal/RightClickMsgMenuRequester.java index 9ba0ba5a849..c03583b3bc4 100644 --- a/addOns/requester/src/main/java/org/zaproxy/addon/requester/internal/RightClickMsgMenuRequester.java +++ b/addOns/requester/src/main/java/org/zaproxy/addon/requester/internal/RightClickMsgMenuRequester.java @@ -22,6 +22,7 @@ import java.awt.event.KeyEvent; import org.parosproxy.paros.network.HttpMessage; import org.parosproxy.paros.view.View; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.addon.requester.ExtensionRequester; import org.zaproxy.zap.view.messagecontainer.http.HttpMessageContainer; import org.zaproxy.zap.view.popup.PopupMenuItemHttpMessageContainer; @@ -59,4 +60,8 @@ public boolean isEnableForInvoker(Invoker invoker, HttpMessageContainer httpMess // You can examine the invoker is you wish to restrict this to specific tabs return true; } + + public int getWeight() { + return MenuWeights.MENU_OPEN_REQUESTER_WEIGHT; + } } diff --git a/addOns/scripts/CHANGELOG.md b/addOns/scripts/CHANGELOG.md index 245e719f6d1..ea27e9bd865 100644 --- a/addOns/scripts/CHANGELOG.md +++ b/addOns/scripts/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Added +- Support for menu weights (Issue 8369) ### Fixed - Propagate script errors to the Automation Framework when running them. diff --git a/addOns/scripts/scripts.gradle.kts b/addOns/scripts/scripts.gradle.kts index ec1fc066555..aa1804a50d0 100644 --- a/addOns/scripts/scripts.gradle.kts +++ b/addOns/scripts/scripts.gradle.kts @@ -19,11 +19,17 @@ zapAddOn { register("automation") { version.set(">=0.31.0") } - register("commonlib") } } } } + dependencies { + addOns { + register("commonlib") { + version.set(">= 1.23.0") + } + } + } } } diff --git a/addOns/scripts/src/main/java/org/zaproxy/zap/extension/scripts/InvokeScriptWithHttpMessagePopupMenu.java b/addOns/scripts/src/main/java/org/zaproxy/zap/extension/scripts/InvokeScriptWithHttpMessagePopupMenu.java index bdf510e2efe..e5be5115d08 100644 --- a/addOns/scripts/src/main/java/org/zaproxy/zap/extension/scripts/InvokeScriptWithHttpMessagePopupMenu.java +++ b/addOns/scripts/src/main/java/org/zaproxy/zap/extension/scripts/InvokeScriptWithHttpMessagePopupMenu.java @@ -25,6 +25,7 @@ import org.parosproxy.paros.extension.ExtensionPopupMenuItem; import org.parosproxy.paros.network.HttpMessage; import org.parosproxy.paros.view.View; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.extension.script.ExtensionScript; import org.zaproxy.zap.extension.script.ScriptWrapper; import org.zaproxy.zap.view.messagecontainer.http.HttpMessageContainer; @@ -96,4 +97,8 @@ private ExtensionPopupMenuItem createPopupAddToScriptMenu(ScriptWrapper script) public boolean isSafe() { return true; } + + public int getParentWeight() { + return MenuWeights.MENU_SCRIPT_INVOKE_WEIGHT; + } } diff --git a/addOns/scripts/src/main/java/org/zaproxy/zap/extension/scripts/SyntaxHighlightTextArea.java b/addOns/scripts/src/main/java/org/zaproxy/zap/extension/scripts/SyntaxHighlightTextArea.java index 5ce492ad6ea..3fe682593d2 100644 --- a/addOns/scripts/src/main/java/org/zaproxy/zap/extension/scripts/SyntaxHighlightTextArea.java +++ b/addOns/scripts/src/main/java/org/zaproxy/zap/extension/scripts/SyntaxHighlightTextArea.java @@ -34,6 +34,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.extension.ExtensionPopupMenuItem; import org.parosproxy.paros.view.View; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.utils.DisplayUtils; public class SyntaxHighlightTextArea extends RSyntaxTextArea { @@ -147,15 +148,38 @@ private void initActions() { syntaxMenu = new SyntaxMenu(); viewMenu = new ViewMenu(); - undoAction = new TextAreaMenuItem(RTextArea.UNDO_ACTION, true, false); - redoAction = new TextAreaMenuItem(RTextArea.REDO_ACTION, false, true); - - cutAction = new TextAreaMenuItem(RTextArea.CUT_ACTION, false, false); - copyAction = new TextAreaMenuItem(RTextArea.COPY_ACTION, false, false); - pasteAction = new TextAreaMenuItem(RTextArea.PASTE_ACTION, false, false); - deleteAction = new TextAreaMenuItem(RTextArea.DELETE_ACTION, false, true); - - selectAllAction = new TextAreaMenuItem(RTextArea.SELECT_ALL_ACTION, false, false); + undoAction = + new TextAreaMenuItem( + RTextArea.UNDO_ACTION, true, false, MenuWeights.MENU_UNDO_WEIGHT); + redoAction = + new TextAreaMenuItem( + RTextArea.REDO_ACTION, false, true, MenuWeights.MENU_REDO_WEIGHT); + + cutAction = + new TextAreaMenuItem( + RTextArea.CUT_ACTION, false, false, MenuWeights.MENU_EDIT_CUT_WEIGHT); + copyAction = + new TextAreaMenuItem( + RTextArea.COPY_ACTION, false, false, MenuWeights.MENU_EDIT_COPY_WEIGHT); + pasteAction = + new TextAreaMenuItem( + RTextArea.PASTE_ACTION, + false, + false, + MenuWeights.MENU_EDIT_PASTE_WEIGHT); + deleteAction = + new TextAreaMenuItem( + RTextArea.DELETE_ACTION, + false, + true, + MenuWeights.MENU_EDIT_DELETE_WEIGHT); + + selectAllAction = + new TextAreaMenuItem( + RTextArea.SELECT_ALL_ACTION, + false, + false, + MenuWeights.MENU_SECECT_ALL_WEIGHT); final List mainPopupMenuItems = View.getSingleton().getPopupList(); mainPopupMenuItems.add(syntaxMenu); @@ -249,13 +273,18 @@ private static class TextAreaMenuItem extends ExtensionPopupMenuItem { private int actionId; private boolean precedeWithSeparator; private boolean succeedWithSeparator; + private int weight; public TextAreaMenuItem( - int actionId, boolean precedeWithSeparator, boolean succeedWithSeparator) + int actionId, + boolean precedeWithSeparator, + boolean succeedWithSeparator, + int weight) throws IllegalArgumentException { this.actionId = actionId; this.precedeWithSeparator = precedeWithSeparator; this.succeedWithSeparator = succeedWithSeparator; + this.weight = weight; Action action = RTextArea.getAction(actionId); if (action == null) { throw new IllegalArgumentException("Action not found with id: " + actionId); @@ -302,5 +331,9 @@ public boolean succeedWithSeparator() { public boolean isSafe() { return true; } + + public int getWeight() { + return weight; + } } } diff --git a/addOns/selenium/CHANGELOG.md b/addOns/selenium/CHANGELOG.md index ba3fd723e09..dc7d7c87b4b 100644 --- a/addOns/selenium/CHANGELOG.md +++ b/addOns/selenium/CHANGELOG.md @@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased - +### Added +- Support for menu weights (Issue 8369) ## [15.19.0] - 2024-02-22 ### Changed diff --git a/addOns/selenium/selenium.gradle.kts b/addOns/selenium/selenium.gradle.kts index 645ae067c6d..9aed47170c1 100644 --- a/addOns/selenium/selenium.gradle.kts +++ b/addOns/selenium/selenium.gradle.kts @@ -18,6 +18,9 @@ zapAddOn { register("network") { version.set(">=0.2.0") } + register("commonlib") { + version.set(">=1.23.0") + } } } @@ -41,6 +44,7 @@ dependencies { exclude(group = "org.apache.logging.log4j") } + zapAddOn("commonlib") zapAddOn("network") testImplementation(project(":testutils")) diff --git a/addOns/selenium/src/main/java/org/zaproxy/zap/extension/selenium/PopupMenuOpenInBrowser.java b/addOns/selenium/src/main/java/org/zaproxy/zap/extension/selenium/PopupMenuOpenInBrowser.java index b3c39598826..a036a8609e8 100644 --- a/addOns/selenium/src/main/java/org/zaproxy/zap/extension/selenium/PopupMenuOpenInBrowser.java +++ b/addOns/selenium/src/main/java/org/zaproxy/zap/extension/selenium/PopupMenuOpenInBrowser.java @@ -20,6 +20,7 @@ package org.zaproxy.zap.extension.selenium; import org.parosproxy.paros.Constant; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.view.messagecontainer.MessageContainer; import org.zaproxy.zap.view.popup.PopupMenuHttpMessageContainer; @@ -61,4 +62,8 @@ public boolean isEnableForMessageContainer(MessageContainer invoker) { return super.isEnableForMessageContainer(invoker); } + + public int getWeight() { + return MenuWeights.MENU_OPEN_BROWSER_WEIGHT; + } } diff --git a/addOns/spider/CHANGELOG.md b/addOns/spider/CHANGELOG.md index 8f38d6c2301..8e9c0805c5a 100644 --- a/addOns/spider/CHANGELOG.md +++ b/addOns/spider/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Added +- Support for menu weights (Issue 8369) ### Fixed - Fix grammatical error in help content. diff --git a/addOns/spider/spider.gradle.kts b/addOns/spider/spider.gradle.kts index 0c3dda9972c..10cde0adf6d 100644 --- a/addOns/spider/spider.gradle.kts +++ b/addOns/spider/spider.gradle.kts @@ -18,7 +18,7 @@ zapAddOn { version.set(">=0.3.0") } register("commonlib") { - version.set(">= 1.17.0 & < 2.0.0") + version.set(">= 1.23.0 & < 2.0.0") } } } diff --git a/addOns/spider/src/main/java/org/zaproxy/addon/spider/PopupMenuItemSpiderDialog.java b/addOns/spider/src/main/java/org/zaproxy/addon/spider/PopupMenuItemSpiderDialog.java index 99c9dcf9ad7..612ab8ace71 100644 --- a/addOns/spider/src/main/java/org/zaproxy/addon/spider/PopupMenuItemSpiderDialog.java +++ b/addOns/spider/src/main/java/org/zaproxy/addon/spider/PopupMenuItemSpiderDialog.java @@ -21,6 +21,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.model.SiteNode; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.view.messagecontainer.http.HttpMessageContainer; import org.zaproxy.zap.view.popup.PopupMenuItemSiteNodeContainer; @@ -80,4 +81,12 @@ protected boolean isEnableForInvoker( return true; } } + + public int getParentWeight() { + return MenuWeights.MENU_ATTACK_WEIGHT; + } + + public int getWeight() { + return MenuWeights.MENU_ATTACK_SPIDER_WEIGHT; + } } diff --git a/addOns/spider/src/main/java/org/zaproxy/addon/spider/PopupMenuItemSpiderDialogWithContext.java b/addOns/spider/src/main/java/org/zaproxy/addon/spider/PopupMenuItemSpiderDialogWithContext.java index 4ddcb1b799a..093565a28ff 100644 --- a/addOns/spider/src/main/java/org/zaproxy/addon/spider/PopupMenuItemSpiderDialogWithContext.java +++ b/addOns/spider/src/main/java/org/zaproxy/addon/spider/PopupMenuItemSpiderDialogWithContext.java @@ -20,6 +20,7 @@ package org.zaproxy.addon.spider; import org.parosproxy.paros.model.Model; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.extension.stdmenus.PopupContextTreeMenu; import org.zaproxy.zap.model.Context; import org.zaproxy.zap.model.Target; @@ -46,4 +47,8 @@ public PopupMenuItemSpiderDialogWithContext(ExtensionSpider2 extension) { extension.showSpiderDialog(new Target(context)); }); } + + public int getWeight() { + return MenuWeights.MENU_CONTEXT_SPIDER_WEIGHT; + } } diff --git a/addOns/spiderAjax/CHANGELOG.md b/addOns/spiderAjax/CHANGELOG.md index 3f03c045171..d95cbebb920 100644 --- a/addOns/spiderAjax/CHANGELOG.md +++ b/addOns/spiderAjax/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased ### Added - Video link in help for Automation Framework job. +- Support for menu weights (Issue 8369) ### Changed - Maintenance changes. diff --git a/addOns/spiderAjax/spiderAjax.gradle.kts b/addOns/spiderAjax/spiderAjax.gradle.kts index 45fe8010d46..f0678cdf5fa 100644 --- a/addOns/spiderAjax/spiderAjax.gradle.kts +++ b/addOns/spiderAjax/spiderAjax.gradle.kts @@ -40,7 +40,7 @@ zapAddOn { dependencies { addOns { register("commonlib") { - version.set(">= 1.17.0 & < 2.0.0") + version.set(">= 1.23.0 & < 2.0.0") } register("network") { version.set(">=0.11.0") diff --git a/addOns/spiderAjax/src/main/java/org/zaproxy/zap/extension/spiderAjax/PopupMenuAjaxSite.java b/addOns/spiderAjax/src/main/java/org/zaproxy/zap/extension/spiderAjax/PopupMenuAjaxSite.java index c32083b395c..d9f57f7b2bb 100644 --- a/addOns/spiderAjax/src/main/java/org/zaproxy/zap/extension/spiderAjax/PopupMenuAjaxSite.java +++ b/addOns/spiderAjax/src/main/java/org/zaproxy/zap/extension/spiderAjax/PopupMenuAjaxSite.java @@ -21,6 +21,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.model.SiteNode; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.view.messagecontainer.http.HttpMessageContainer; import org.zaproxy.zap.view.popup.PopupMenuItemSiteNodeContainer; @@ -54,6 +55,14 @@ public int getParentMenuIndex() { return ATTACK_MENU_INDEX; } + public int getParentWeight() { + return MenuWeights.MENU_ATTACK_WEIGHT; + } + + public int getWeight() { + return MenuWeights.MENU_ATTACK_AJAX_WEIGHT; + } + /** */ @Override public void performAction(SiteNode node) { diff --git a/addOns/spiderAjax/src/main/java/org/zaproxy/zap/extension/spiderAjax/internal/PopupMenuItemSpiderDialogWithContext.java b/addOns/spiderAjax/src/main/java/org/zaproxy/zap/extension/spiderAjax/internal/PopupMenuItemSpiderDialogWithContext.java index ce09f5af01e..d2c38a637c4 100644 --- a/addOns/spiderAjax/src/main/java/org/zaproxy/zap/extension/spiderAjax/internal/PopupMenuItemSpiderDialogWithContext.java +++ b/addOns/spiderAjax/src/main/java/org/zaproxy/zap/extension/spiderAjax/internal/PopupMenuItemSpiderDialogWithContext.java @@ -19,6 +19,7 @@ */ package org.zaproxy.zap.extension.spiderAjax.internal; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.extension.spiderAjax.ExtensionAjax; import org.zaproxy.zap.extension.stdmenus.PopupContextTreeMenu; import org.zaproxy.zap.model.Context; @@ -44,4 +45,8 @@ public PopupMenuItemSpiderDialogWithContext(ExtensionAjax extension) { extension.showScanDialog(new Target(context)); }); } + + public int getWeight() { + return MenuWeights.MENU_CONTEXT_AJAX_WEIGHT; + } } diff --git a/addOns/websocket/CHANGELOG.md b/addOns/websocket/CHANGELOG.md index 808d8dfc944..8c8b4d1d7b4 100644 --- a/addOns/websocket/CHANGELOG.md +++ b/addOns/websocket/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Added +- Support for menu weights (Issue 8369) ### Changed - Maintenance changes. diff --git a/addOns/websocket/src/main/java/org/zaproxy/zap/extension/websocket/ui/PopupExcludeWebSocketContextMenu.java b/addOns/websocket/src/main/java/org/zaproxy/zap/extension/websocket/ui/PopupExcludeWebSocketContextMenu.java index e318272da28..7a03705eef8 100644 --- a/addOns/websocket/src/main/java/org/zaproxy/zap/extension/websocket/ui/PopupExcludeWebSocketContextMenu.java +++ b/addOns/websocket/src/main/java/org/zaproxy/zap/extension/websocket/ui/PopupExcludeWebSocketContextMenu.java @@ -22,6 +22,7 @@ import java.awt.Component; import org.parosproxy.paros.Constant; import org.parosproxy.paros.extension.ExtensionPopupMenuItem; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.model.Context; import org.zaproxy.zap.view.popup.PopupMenuItemContextExclude; @@ -37,6 +38,10 @@ public String getParentMenuName() { return MENU_NAME; } + public int getParentWeight() { + return MenuWeights.MENU_EXC_CHANNEL_CONTEXT_WEIGHT; + } + @Override public boolean isEnableForComponent(Component invoker) { String invokerName = invoker.getName(); diff --git a/addOns/websocket/src/main/java/org/zaproxy/zap/extension/websocket/ui/PopupIncludeWebSocketContextMenu.java b/addOns/websocket/src/main/java/org/zaproxy/zap/extension/websocket/ui/PopupIncludeWebSocketContextMenu.java index 969aed8093e..1467feb5710 100644 --- a/addOns/websocket/src/main/java/org/zaproxy/zap/extension/websocket/ui/PopupIncludeWebSocketContextMenu.java +++ b/addOns/websocket/src/main/java/org/zaproxy/zap/extension/websocket/ui/PopupIncludeWebSocketContextMenu.java @@ -22,6 +22,7 @@ import java.awt.Component; import org.parosproxy.paros.Constant; import org.parosproxy.paros.extension.ExtensionPopupMenuItem; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.model.Context; import org.zaproxy.zap.view.popup.PopupMenuItemContextInclude; @@ -37,6 +38,10 @@ public String getParentMenuName() { return MENU_NAME; } + public int getParentWeight() { + return MenuWeights.MENU_INC_CHANNEL_CONTEXT_WEIGHT; + } + @Override public boolean isEnableForComponent(Component invoker) { String invokerName = invoker.getName(); diff --git a/addOns/websocket/websocket.gradle.kts b/addOns/websocket/websocket.gradle.kts index e294e4b5608..82a933b794d 100644 --- a/addOns/websocket/websocket.gradle.kts +++ b/addOns/websocket/websocket.gradle.kts @@ -39,6 +39,13 @@ zapAddOn { } } } + dependencies { + addOns { + register("commonlib") { + version.set(">=1.23.0") + } + } + } } apiClientGen { @@ -48,6 +55,7 @@ zapAddOn { } dependencies { + zapAddOn("commonlib") zapAddOn("fuzz") zapAddOn("requester") diff --git a/addOns/zest/CHANGELOG.md b/addOns/zest/CHANGELOG.md index fda52a92aae..8ad01fbf039 100644 --- a/addOns/zest/CHANGELOG.md +++ b/addOns/zest/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this add-on will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Unreleased +### Added +- Support for menu weights (Issue 8369) + ### Changed - Update minimum Scripts add-on version to 45. - Maintenance changes. diff --git a/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestAddToScriptMenu.java b/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestAddToScriptMenu.java index 12537cc7d22..50868b6584d 100644 --- a/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestAddToScriptMenu.java +++ b/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestAddToScriptMenu.java @@ -23,6 +23,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.network.HttpMessage; import org.parosproxy.paros.view.View; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.extension.script.ScriptNode; import org.zaproxy.zap.extension.zest.ExtensionZest; import org.zaproxy.zap.view.popup.ExtensionPopupMenuComponent; @@ -56,6 +57,10 @@ public String getParentMenuName() { return Constant.messages.getString("zest.addto.popup"); } + public int getParentWeight() { + return MenuWeights.MENU_SCRIPT_ZEST_ADD_WEIGHT; + } + @Override public boolean isSubMenu() { return true; diff --git a/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestAddToScriptPopupMenu.java b/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestAddToScriptPopupMenu.java index f0c180696e6..12528e73da7 100644 --- a/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestAddToScriptPopupMenu.java +++ b/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestAddToScriptPopupMenu.java @@ -25,6 +25,7 @@ import org.parosproxy.paros.extension.ExtensionPopupMenuItem; import org.parosproxy.paros.model.HistoryReference; import org.parosproxy.paros.view.View; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.extension.script.ScriptNode; import org.zaproxy.zap.extension.script.ScriptType; import org.zaproxy.zap.extension.zest.ExtensionZest; @@ -52,6 +53,10 @@ public String getParentMenuName() { return Constant.messages.getString("zest.addto.popup", true); } + public int getParentWeight() { + return MenuWeights.MENU_SCRIPT_ZEST_ADD_WEIGHT; + } + @Override public boolean isSubMenu() { return true; diff --git a/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestRecordFromNodePopupMenu.java b/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestRecordFromNodePopupMenu.java index 39382bf686c..f26d0740d86 100644 --- a/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestRecordFromNodePopupMenu.java +++ b/addOns/zest/src/main/java/org/zaproxy/zap/extension/zest/menu/ZestRecordFromNodePopupMenu.java @@ -21,6 +21,7 @@ import org.parosproxy.paros.Constant; import org.parosproxy.paros.model.SiteNode; +import org.zaproxy.addon.commonlib.MenuWeights; import org.zaproxy.zap.extension.zest.ExtensionZest; import org.zaproxy.zap.view.popup.PopupMenuItemSiteNodeContainer; @@ -46,4 +47,8 @@ public boolean isSafe() { protected void performAction(SiteNode node) { extension.getDialogManager().showZestRecordScriptDialog(node); } + + public int getWeight() { + return MenuWeights.MENU_SCRIPT_ZEST_RECORD_WEIGHT; + } } diff --git a/addOns/zest/zest.gradle.kts b/addOns/zest/zest.gradle.kts index 66564dbf77c..1cf93d7593a 100644 --- a/addOns/zest/zest.gradle.kts +++ b/addOns/zest/zest.gradle.kts @@ -23,7 +23,7 @@ zapAddOn { dependencies { addOns { register("commonlib") { - version.set(">=1.16.0") + version.set(">=1.23.0") } register("network") { version.set(">=0.2.0")