The Burp Suite User Forum was discontinued on the 1st November 2024.

Burp Suite User Forum

For support requests, go to the Support Center. To discuss with other Burp users, head to our Discord page.

SUPPORT CENTER DISCORD

Context menu text missing when using an Action

Michel | Last updated: Aug 22, 2023 09:41AM UTC

When I add a JMenuItem to the context menu without an action the text displays properly ("Do action"). But when I set an action (menuItem.setAction(action)), the text is empty. Note that the action properly defines its NAME, I tried also defining SHORT_DESCRIPTION and LONG_DESCRIPTION, but the JMenuItem text remain empty. Do I do something wrong? Or is this a bug? The code is below: public class HeaderInspector implements BurpExtension, ContextMenuItemsProvider { @Override public void initialize(MontoyaApi api) { api.userInterface().registerContextMenuItemsProvider(this); } public List<Component> provideMenuItems(ContextMenuEvent event) { List<Component> itemList = new LinkedList<Component>(); CustomAction action = new CustomAction();// extends javax.swing.AbstractAction Component menuItem = new JMenuItem("Do action"); menuItem.setAction(action); // with this line, the text is empty, without it shows "Do action" itemList.add(menuItem); return itemList; } public List<Component> provideMenuItems(WebSocketContextMenuEvent event) { return null; } public List<Component> provideMenuItems(AuditIssueContextMenuEvent event) { return null; } } class CustomAction extends AbstractAction { CustomAction(){ super("CustomAction: Do action"); // sets Action.NAME } public void actionPerformed(ActionEvent e) { ... } }

Michel | Last updated: Aug 22, 2023 09:43AM UTC

Note: the goal is to do: Component menuItem = new JMenuItem(action); The code above is more explicit about when the text works, and when not.

Hannah, PortSwigger Agent | Last updated: Aug 22, 2023 03:46PM UTC

Thanks for posting! We'll do some testing to try and replicate this behavior. Typically when providing context menu actions, we recommend adding an action listener. You can see this in our example code here: https://github.com/PortSwigger/burp-extensions-montoya-api-examples/tree/main/contextmenu

Hannah, PortSwigger Agent | Last updated: Aug 24, 2023 12:36PM UTC