Button to clean history

98 views
Skip to first unread message

Antonio Cota

unread,
Sep 23, 2022, 6:12:29 PM9/23/22
to OWASP ZAP User Group
Hi,

Is there a button to clean all the history under the History tab? It would be very useful. Currently I have to double click Ctrl + A and then Del.

Thank you

kingthorin+owaspzap

unread,
Sep 23, 2022, 6:35:18 PM9/23/22
to OWASP ZAP User Group
Clearing history clears the site tree, you may as well right click the root and delete from there.

Antonio Cota

unread,
Sep 23, 2022, 6:38:57 PM9/23/22
to OWASP ZAP User Group
I've just deleted the history under the history tab and the site tree was touched, nothing was removed from the site tree. 

kingthorin+owaspzap

unread,
Sep 24, 2022, 9:33:26 AM9/24/22
to OWASP ZAP User Group
You're totally right. I was headed to bed at the time and rushing. I was only considering proxied traffic not all ZAP functionality.

Sorry!

Rick

Antonio Cota

unread,
Sep 25, 2022, 2:31:24 PM9/25/22
to OWASP ZAP User Group
I think I could be something nice to have, don't you?

Simon Bennetts

unread,
Sep 26, 2022, 3:47:41 AM9/26/22
to OWASP ZAP User Group
Is there any reason why you dont want to start a new session?
That will clear the History and the Sites Tree :)
We already have a button for that...

Antonio Cota

unread,
Sep 26, 2022, 4:06:33 AM9/26/22
to OWASP ZAP User Group
If I start a new session then I will loss all the contexts that I've set. You could say "re-open the stored session", but if I do so then I will also bring back the history which is something I wanted to delete

kingthorin+owaspzap

unread,
Sep 26, 2022, 8:34:50 AM9/26/22
to OWASP ZAP User Group

Here's an extender script you can use to add a broom button to the main tool bar to clear the history table:



var jbutton = Java.type("javax.swing.JButton");
var button = new jbutton();

var control
if (!control) control = Java.type("org.parosproxy.paros.control.Control").getSingleton()

extHist = control.getExtensionLoader().getExtension(
org.parosproxy.paros.extension.history.ExtensionHistory.NAME)

function install(helper) {
if (helper.getView()) {
var imageicon = Java.type("javax.swing.ImageIcon");
// The icons bundled with ZAP are listed here https://github.com/zaproxy/zaproxy/tree/main/zap/src/main/resources/resource
button.setIcon(org.zaproxy.zap.utils.DisplayUtils.getScaledIcon(
new imageicon(org.zaproxy.zap.ZAP.class.getResource("/resource/icon/fugue/broom.png"))));
button.setToolTipText("Clear History");
button.addActionListener(new java.awt.event.ActionListener() {
actionPerformed: function(event) {
helper.getView().showWarningDialog("Clearing all history may also cause Sites Tree nodes to be removed.");
print("Clearing history");
extHist.getHistoryReferencesTable().selectAll();
extHist.purgeHistory(extHist.getSelectedHistoryReferences());
print("Done clearing history");
}
});
helper.getView().addMainToolbarButton(button)
helper.getView().getMainFrame().getMainToolbarPanel().revalidate();
}
}

function uninstall(helper) {
if (helper.getView()) {
// If revalidate isnt called then the button appear to stay on the toolbar
helper.getView().getMainFrame().getMainToolbarPanel().revalidate();
helper.getView().removeMainToolbarButton(button);
}
}
Reply all
Reply to author
Forward
0 new messages