Burp Suite User Forum

Create new post

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

Hi Thank you for your patience. After doing some testing, we've replicated the issue and found the cause. Currently, we are unable to support Action in Burp, so we would recommend using an ActionListener instead. Due to how we wrap extension methods in exception handling code, we remove the properties of the Action. We'll raise a feature request to add support for this functionality, as it looks like it would be useful. If there's anything else we can help with, then please let us know.

You must be an existing, logged-in customer to reply to a thread. Please email us for additional support.