use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class ExtensionAlert method updateAlert.
public void updateAlert(Alert alert) throws HttpMalformedHeaderException, DatabaseException {
logger.debug("updateAlert " + alert.getName() + " " + alert.getUri());
HistoryReference hRef = hrefs.get(alert.getSourceHistoryId());
if (hRef != null) {
updateAlertInDB(alert);
hRef.updateAlert(alert);
publishAlertEvent(alert, AlertEventPublisher.ALERT_CHANGED_EVENT);
updateAlertInTree(alert, alert);
}
}
use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class ExtensionAlert method deleteAlertFromDisplayEventHandler.
private void deleteAlertFromDisplayEventHandler(Alert alert) {
synchronized (this.getTreeModel()) {
this.getTreeModel().deletePath(alert);
this.getFilteredTreeModel().deletePath(alert);
List<HistoryReference> toDelete = new ArrayList<>();
for (HistoryReference href : hrefs.values()) {
if (href.hasAlert(alert)) {
href.deleteAlert(alert);
if (!href.hasAlerts()) {
toDelete.add(href);
}
}
}
for (HistoryReference href : toDelete) {
hrefs.remove(Integer.valueOf(href.getHistoryId()));
}
}
this.recalcAlerts();
}
use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class ExtensionAlert method deleteAllAlerts.
public void deleteAllAlerts() {
try {
getModel().getDb().getTableAlert().deleteAllAlerts();
} catch (DatabaseException e) {
logger.error(e.getMessage(), e);
}
SiteMap siteTree = this.getModel().getSession().getSiteTree();
((SiteNode) siteTree.getRoot()).deleteAllAlerts();
for (HistoryReference href : hrefs.values()) {
href.deleteAllAlerts();
}
ZAP.getEventBus().publishSyncEvent(AlertEventPublisher.getPublisher(), new Event(AlertEventPublisher.getPublisher(), AlertEventPublisher.ALL_ALERTS_REMOVED_EVENT, null));
hrefs = new HashMap<>();
treeModel = null;
filteredTreeModel = null;
setTreeModel(getTreeModel());
}
use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class ExtensionBreak method getMenuAddHttpBreakpoint.
private ZapMenuItem getMenuAddHttpBreakpoint() {
if (menuHttpBreakpoint == null) {
menuHttpBreakpoint = new ZapMenuItem("menu.tools.brk.custom", KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(), false));
menuHttpBreakpoint.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
// Check to see if anything is selected in the main tabs
String url = "";
Component c = View.getSingleton().getMainFrame().getFocusOwner();
if (c != null) {
if (c instanceof JList) {
// Handles the history list and similar
@SuppressWarnings("rawtypes") Object sel = ((JList) c).getSelectedValue();
try {
if (sel != null && sel instanceof HistoryReference && ((HistoryReference) sel).getURI() != null) {
url = ((HistoryReference) sel).getURI().toString();
}
} catch (Exception e1) {
// Ignore
}
} else if (c instanceof JTree) {
// Handles the Sites tree
TreePath path = ((JTree) c).getSelectionPath();
try {
if (path != null && path.getLastPathComponent() instanceof SiteNode) {
url = ((SiteNode) path.getLastPathComponent()).getHistoryReference().getURI().toString();
}
} catch (Exception e1) {
// Ignore
}
}
}
httpBreakpoints.handleAddBreakpoint(url);
}
});
}
return menuHttpBreakpoint;
}
use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class HttpPanelSender method handleSendMessage.
@Override
public void handleSendMessage(Message aMessage) throws IllegalArgumentException, IOException {
final HttpMessage httpMessage = (HttpMessage) aMessage;
try {
final ModeRedirectionValidator redirectionValidator = new ModeRedirectionValidator();
if (getButtonFollowRedirects().isSelected()) {
getDelegate().sendAndReceive(httpMessage, redirectionValidator);
} else {
getDelegate().sendAndReceive(httpMessage, false);
}
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
if (!httpMessage.getResponseHeader().isEmpty()) {
// Indicate UI new response arrived
responsePanel.updateContent();
try {
Session session = Model.getSingleton().getSession();
HistoryReference ref = new HistoryReference(session, HistoryReference.TYPE_ZAP_USER, httpMessage);
final ExtensionHistory extHistory = getHistoryExtension();
if (extHistory != null) {
extHistory.addHistory(ref);
}
SessionStructure.addPath(session, ref, httpMessage);
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
if (!redirectionValidator.isRequestValid()) {
View.getSingleton().showWarningDialog(Constant.messages.getString("manReq.outofscope.redirection.warning", redirectionValidator.getInvalidRedirection()));
}
}
}
});
ZapGetMethod method = (ZapGetMethod) httpMessage.getUserObject();
notifyPersistentConnectionListener(httpMessage, null, method);
} catch (final HttpMalformedHeaderException mhe) {
throw new IllegalArgumentException("Malformed header error.", mhe);
} catch (final UnknownHostException uhe) {
throw new IOException("Error forwarding to an Unknown host: " + uhe.getMessage(), uhe);
} catch (final SSLException sslEx) {
throw sslEx;
} catch (final IOException ioe) {
throw new IOException("IO error in sending request: " + ioe.getClass() + ": " + ioe.getMessage(), ioe);
} catch (final Exception e) {
logger.error(e.getMessage(), e);
}
}
Aggregations