use of org.zaproxy.zap.extension.alert.ExtensionAlert in project zaproxy by zaproxy.
the class AlertAddDialog method getBtnOk.
/**
* This method initializes btnStart
*
* @return javax.swing.JButton
*/
private JButton getBtnOk() {
if (btnOk == null) {
btnOk = new JButton();
btnOk.setText(Constant.messages.getString("alert.add.button.save"));
btnOk.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
Alert alert = alertViewPanel.getAlert();
try {
ExtensionAlert extAlert = (ExtensionAlert) Control.getSingleton().getExtensionLoader().getExtension(ExtensionAlert.NAME);
if (alert.getAlertId() >= 0) {
// Its an existing alert so save it
if (extAlert != null) {
extAlert.updateAlert(alert);
} else if (historyRef != null) {
// Update history tree
historyRef.updateAlert(alert);
extension.notifyHistoryItemChanged(historyRef);
}
} else {
if (httpMessage != null) {
historyRef = new HistoryReference(Model.getSingleton().getSession(), historyType, httpMessage);
}
alert.setSource(Alert.Source.MANUAL);
// Raise it
if (extAlert != null) {
extAlert.alertFound(alert, historyRef);
} else {
historyRef.addAlert(alert);
extension.notifyHistoryItemChanged(historyRef);
}
}
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
}
clearAndCloseDialog();
}
});
}
return btnOk;
}
use of org.zaproxy.zap.extension.alert.ExtensionAlert in project zaproxy by zaproxy.
the class ExtensionHistory method purge.
public void purge(SiteMap map, SiteNode node) {
SiteNode child = null;
synchronized (map) {
while (node.getChildCount() > 0) {
try {
child = (SiteNode) node.getChildAt(0);
purge(map, child);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
if (node.isRoot()) {
return;
}
// delete reference in node
removeFromHistoryList(node.getHistoryReference());
ExtensionAlert extAlert = Control.getSingleton().getExtensionLoader().getExtension(ExtensionAlert.class);
if (node.getHistoryReference() != null) {
deleteAlertsFromExtensionAlert(extAlert, node.getHistoryReference());
node.getHistoryReference().delete();
map.removeHistoryReference(node.getHistoryReference().getHistoryId());
}
// delete past reference in node
while (node.getPastHistoryReference().size() > 0) {
HistoryReference ref = node.getPastHistoryReference().get(0);
deleteAlertsFromExtensionAlert(extAlert, ref);
removeFromHistoryList(ref);
delete(ref);
node.getPastHistoryReference().remove(0);
map.removeHistoryReference(ref.getHistoryId());
}
map.removeNodeFromParent(node);
}
}
use of org.zaproxy.zap.extension.alert.ExtensionAlert in project zaproxy by zaproxy.
the class ExtensionHistory method purgeHistory.
private void purgeHistory(HistoryReference href) {
if (href == null) {
return;
}
removeFromHistoryList(href);
ExtensionAlert extAlert = Control.getSingleton().getExtensionLoader().getExtension(ExtensionAlert.class);
if (extAlert != null) {
extAlert.deleteHistoryReferenceAlerts(href);
}
SiteNode node = href.getSiteNode();
if (node != null) {
SiteMap map = Model.getSingleton().getSession().getSiteTree();
if (node.getHistoryReference() != href) {
node.getPastHistoryReference().remove(href);
} else if (!node.getPastHistoryReference().isEmpty()) {
node.setHistoryReference(node.getPastHistoryReference().remove(0));
node.getPastHistoryReference().remove(href);
} else {
if (node.isLeaf()) {
SiteNode parent = node.getParent();
map.removeNodeFromParent(node);
purgeTemporaryParents(map, parent);
} else {
try {
node.setHistoryReference(map.createReference(node, href, href.getHttpMessage()));
} catch (URIException | HttpMalformedHeaderException | NullPointerException | DatabaseException e) {
logger.error("Failed to create temporary node:", e);
}
}
}
map.removeHistoryReference(href.getHistoryId());
}
delete(href);
}
use of org.zaproxy.zap.extension.alert.ExtensionAlert in project zaproxy by zaproxy.
the class ExtensionHistory method showAlertAddDialog.
/**
* @deprecated (2.7.0) Use {@link ExtensionAlert#showAlertEditDialog(Alert)} instead.
* @param alert the alert to edit
*/
@Deprecated
public void showAlertAddDialog(Alert alert) {
ExtensionAlert extAlert = Control.getSingleton().getExtensionLoader().getExtension(ExtensionAlert.class);
if (extAlert == null) {
return;
}
extAlert.showAlertEditDialog(alert);
}
Aggregations