zap-hud icon indicating copy to clipboard operation
zap-hud copied to clipboard

Show/Enable (and comments) tool not updated when added

Open psiinon opened this issue 6 years ago • 5 comments

The show/enable tool (and the new comments one) is not updated when added to the HUD.

psiinon avatar Aug 28 '19 10:08 psiinon

@dscrobonia thoughts on how this should work?

psiinon avatar Aug 28 '19 11:08 psiinon

The way buttons get their data, label, icon set when they're newly added to a panel is by pulling what has been saved/cached in indexedDb. In the case of showComments, there is nothing there for it to pull out because the count data is not being stored in indexeddb, but locally in memory "per tab".

Here is what happens when we add a tool to a panel. you can see we "load" the tool (which pulls the data from indexeddb) and then shuffle it to the panel.

dscrobonia avatar Aug 30 '19 15:08 dscrobonia

@dscrobonia so how about we add a callback when a tool gets added to a panel? Then the tool can do any extra things it needs to do...

psiinon avatar Aug 30 '19 15:08 psiinon

that is what the getTool function is supposed to be for, and that is used when the tools are loaded in the panel. Seems like it would make sense to call that function as well when we add a button to the panel... Should be easy to do!

btw I'm not sure that leaving the comment variables in memory works between FF & Chrome. Per the RFC here is only supposed to be a single serviceworker process / browser. that means there should only be one instance of your variables per browser.

FF has had a bug where they have a service worker process / tab, where chrome followed the RFC and had a single process / browser. This is what had caused lotsa issues with multi tabs.

Briefly testing against Chrome I believe I saw some buggy behavior in the count with multiple tabs. I'd check that.

I'll think about solutions on my train ride to work ;)

dscrobonia avatar Aug 30 '19 15:08 dscrobonia

@dscrobonia so how about we add a callback when a tool gets added to a panel?

I think running this function (https://github.com/zaproxy/zap-hud/blob/develop/src/main/zapHomeFiles/hud/panel.js#L172) at this spot (https://github.com/zaproxy/zap-hud/blob/develop/src/main/zapHomeFiles/hud/panel.js#L188) should do the trick!

dscrobonia avatar Aug 30 '19 15:08 dscrobonia