PortSwigger / burp-extensions-montoya-api

Burp Extensions Api
Other
125 stars 3 forks source link

Listening for HttpRequestEditor updates #74

Closed CoreyD97 closed 11 months ago

CoreyD97 commented 11 months ago

Currently, there's no way to subscribe to updates to a HttpRequestEditor. The ability to do this would be useful for a number of reasons, like responding to changes in the editor dynamically, rather than waiting for another event (e.g. Clicking a button) then fetching the current contents manually.

In some cases, such as where a one-way relationship between the UI and functionality exists the aforementioned option isn't possible so this would be a great improvement.

For example, in Stepper 2.0, the the UI and each step is very loosely coupled. The UI is used to update the step, but the step cannot fetch the current contents of the editor for concurrency reasons.

I appreciate this may be a very niche issue though, so happy to discuss :)

Hannah-PortSwigger commented 11 months ago

Hi.

Are you able to provide some more information on the functionality you are looking for?

Are you referring to an extension-provided HttpRequestEditor, or a native editor with an extension-provided tab?

CoreyD97 commented 11 months ago

Hi Hannah!

This isn't related to a specific tab, but the request editor as a whole. i.e., the editor provided via the createHttpRequestEditor (doc) method.

For example, the following code could be used to trigger a specific action when the request is updated (Either via the editor or a setRequest method call)

HttpRequestEditor editor = montoya.userInterface().createHttpRequestEditor();
editor.setRequest(myRequest);
editor.addChangeListener((newRequest, source) => {
  if(source == EDITOR){ //If the user 
    //Do something with the modified request in response to the user changing the request body (newRequest)
  }else{
    //Do something if request was changed from code
  }
});
Hannah-PortSwigger commented 11 months ago

Thank you for the additional information!

We've raised a feature request for this functionality, to be discussed further internally.

If there's anything else we can help with, then please let us know.