Search in sources :

Example 6 with HistoryReference

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);
    }
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference)

Example 7 with HistoryReference

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();
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) ArrayList(java.util.ArrayList)

Example 8 with HistoryReference

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());
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) SiteMap(org.parosproxy.paros.model.SiteMap) Event(org.zaproxy.zap.eventBus.Event) DatabaseException(org.parosproxy.paros.db.DatabaseException) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 9 with HistoryReference

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;
}
Also used : InvalidParameterException(java.security.InvalidParameterException) MalformedURLException(java.net.MalformedURLException) HistoryReference(org.parosproxy.paros.model.HistoryReference) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem) Component(java.awt.Component) JList(javax.swing.JList) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 10 with HistoryReference

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);
    }
}
Also used : ZapGetMethod(org.zaproxy.zap.ZapGetMethod) UnknownHostException(java.net.UnknownHostException) ExtensionHistory(org.parosproxy.paros.extension.history.ExtensionHistory) IOException(java.io.IOException) SSLException(javax.net.ssl.SSLException) HttpMalformedHeaderException(org.parosproxy.paros.network.HttpMalformedHeaderException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) SSLException(javax.net.ssl.SSLException) HistoryReference(org.parosproxy.paros.model.HistoryReference) HttpMalformedHeaderException(org.parosproxy.paros.network.HttpMalformedHeaderException) HttpMessage(org.parosproxy.paros.network.HttpMessage) Session(org.parosproxy.paros.model.Session)

Aggregations

HistoryReference (org.parosproxy.paros.model.HistoryReference)36 DatabaseException (org.parosproxy.paros.db.DatabaseException)11 SiteNode (org.parosproxy.paros.model.SiteNode)10 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)7 ArrayList (java.util.ArrayList)6 Alert (org.parosproxy.paros.core.scanner.Alert)6 HttpMessage (org.parosproxy.paros.network.HttpMessage)6 JTree (javax.swing.JTree)5 ExtensionHistory (org.parosproxy.paros.extension.history.ExtensionHistory)5 TreePath (javax.swing.tree.TreePath)4 IOException (java.io.IOException)3 TreeSet (java.util.TreeSet)3 Session (org.parosproxy.paros.model.Session)3 SiteMap (org.parosproxy.paros.model.SiteMap)3 Component (java.awt.Component)2 MalformedURLException (java.net.MalformedURLException)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 URIException (org.apache.commons.httpclient.URIException)2 Event (org.zaproxy.zap.eventBus.Event)2 AlertNode (org.zaproxy.zap.extension.alert.AlertNode)2