Skip to content

Commit

Permalink
Merge pull request #5321 from psiinon/ui/menu-restructure
Browse files Browse the repository at this point in the history
Menu Restructure
  • Loading branch information
thc202 authored Mar 1, 2024
2 parents 67b7f7a + de344bb commit 50b7ba0
Show file tree
Hide file tree
Showing 65 changed files with 437 additions and 33 deletions.
3 changes: 2 additions & 1 deletion addOns/bruteforce/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion addOns/bruteforce/bruteforce.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion addOns/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion addOns/client/client.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ zapAddOn {
register("network") {
version.set(">=0.8.0")
}
register("commonlib")
register("commonlib") {
version.set(">=1.23.0")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions addOns/commonlib/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
3 changes: 2 additions & 1 deletion addOns/diff/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions addOns/diff/diff.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
2 changes: 2 additions & 0 deletions addOns/encoder/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
9 changes: 9 additions & 0 deletions addOns/encoder/encoder.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
}
}

Expand All @@ -21,5 +28,7 @@ crowdin {
}

dependencies {
zapAddOn("commonlib")

testImplementation(project(":testutils"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions addOns/exim/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion addOns/exim/exim.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -71,4 +72,8 @@ public boolean isSafe() {
public void lostOwnership(Clipboard clipboard, Transferable contents) {
// Ignore
}

public int getWeight() {
return MenuWeights.MENU_COPY_URLS_WEIGHT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -89,4 +90,9 @@ private void getOutputSet(Context ctx, SortedSet<String> outputSet) {
outputSet.add(node.getHistoryReference().getURI().toString());
}
}

@Override
public int getWeight() {
return MenuWeights.MENU_CONTEXT_EXPORT_URLS_WEIGHT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -79,4 +80,9 @@ private SortedSet<String> getOutputSet(TreePath[] startingPoints) {
}
return outputSet;
}

@Override
public int getWeight() {
return MenuWeights.MENU_SAVE_URLS_WEIGHT;
}
}
Loading

0 comments on commit 50b7ba0

Please sign in to comment.