PortSwigger / burp-extensions-montoya-api

Burp Extensions Api
Other
139 stars 5 forks source link

ExtensionHttpRequestEditor tab content not showing #19

Closed blafois closed 1 year ago

blafois commented 1 year ago

Hello team !

I'm developing an extension which aims to pretty-print a binary encoded protocol, but I'm not able to show the tab content. The new tab is created and its caption can be seen, but there is no content pane. I could not find sample code using the ExtensionHttpRequest editor.

Code which has been tried without success:

ExtensionHttpRequestEditor requestEditor = new ExtensionHttpRequestEditor(){
...
            @Override
            public Component uiComponent() {
                JPanel jp = new JPanel();
                jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS));
                jp.add(new JLabel("Test Label"));
               return jp;
            }
...
}

userInterface.registerHttpRequestEditorProvider(new ExtensionHttpRequestEditorProvider() {
            @Override
            public ExtensionHttpRequestEditor provideHttpRequestEditor(HttpRequestResponse httpRequestResponse, EditorMode editorMode) {
                if (matchesConditions(httpRequestResponse)) {
                    return requestEditor;
                }
                return null;
            }
        });

I've also tried:

Any help / sample would be appreciated !

Thanks

SeanBurnsUK commented 1 year ago

Hi @blafois,

You are right, this should work. I have created a bug on our end to get this fixed. In the meantime there is a work around. You need to return the same component in the uiComponent() method (configure it in a constructor or holding class).

eg for your example.

JPanel jp = new JPanel();
jp.setLayout(new BoxLayout(jp, BoxLayout.PAGE_AXIS));
jp.add(new JLabel("Test Label"));

ExtensionHttpRequestEditor requestEditor = new ExtensionHttpRequestEditor(){
...
            @Override
            public Component uiComponent() {
                 return jp;
            }
...
}
SeanBurnsUK commented 1 year ago

This should be fixed in 2023.2, Closing.