PortSwigger / burp-extensions-montoya-api

Burp Extensions Api
Other
125 stars 3 forks source link

Declare Burp Pro-Only features as Optional #60

Closed floyd-fuh closed 1 year ago

floyd-fuh commented 1 year ago

When I use the following code:

val collab: Collaborator = api.collaborator()
val client = collab.createClient()
logging.raiseInfoEvent(client.secretKey.toString())

on community edition I get: java.lang.NullPointerException: Cannot invoke "burp.api.montoya.collaborator.CollaboratorClient.getSecretKey()" because "client" is null

I guess the best would be if api.collaborator() would declare to return Optional<Collaborator> rather than Collaborator:

https://github.com/PortSwigger/burp-extensions-montoya-api/blob/8b6d0c237c29e4821fd7e6595719e1761a75e272/src/main/java/burp/api/montoya/MontoyaApi.java#L51

And obviously for all other Pro-Only functions it should return an Optional<>, right?

Hannah-PortSwigger commented 1 year ago

Hi Floyd

Thank you for raising this. We're looking into this and will be considering some solutions to handle this in a better way.

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

floyd-fuh commented 1 year ago

Please also fix the same issue with the PersistedObject functions, it says in the Javadoc that it might return null, but doesn't declare it as Optional, why? For example:

https://github.com/PortSwigger/burp-extensions-montoya-api/blob/8b6d0c237c29e4821fd7e6595719e1761a75e272/src/main/java/burp/api/montoya/persistence/PersistedObject.java#LL70C5-L70C11

Not knowing when things could be null makes developing a trial and error process. I much rather have the IDE remind me that things could be null and I factor that in from the beginning.

Hannah-PortSwigger commented 1 year ago

Hi Floyd

We'll be reviewing this behavior for all Pro-only functionality (Scanner, Collaborator, Persistable objects), and looking into if there's anything we can do to make this easier for you (as suggested on the other raised issue, possibly adding additional annotations).