Search in sources :

Example 31 with SiteNode

use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.

the class PopupMenuExportURLs method performAction.

protected void performAction() {
    File file = getOutputFile();
    if (file == null) {
        return;
    }
    writeURLs(file, getOutputSet((SiteNode) extension.getView().getSiteTreePanel().getTreeSite().getModel().getRoot()));
}
Also used : File(java.io.File) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 32 with SiteNode

use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.

the class PopupMenuPurgeHistory method purgeHistory.

private void purgeHistory(HistoryReference ref) {
    if (ref == null) {
        return;
    }
    extension.removeFromHistoryList(ref);
    ExtensionAlert extAlert = (ExtensionAlert) Control.getSingleton().getExtensionLoader().getExtension(ExtensionAlert.NAME);
    if (extAlert != null) {
        extAlert.deleteHistoryReferenceAlerts(ref);
    }
    extension.delete(ref);
    SiteNode node = ref.getSiteNode();
    if (node == null) {
        return;
    }
    SiteMap map = Model.getSingleton().getSession().getSiteTree();
    if (node.getHistoryReference() == ref) {
        // same active Node
        extension.purge(map, node);
    } else {
        node.getPastHistoryReference().remove(ref);
        map.removeHistoryReference(ref.getHistoryId());
    }
}
Also used : SiteMap(org.parosproxy.paros.model.SiteMap) ExtensionAlert(org.zaproxy.zap.extension.alert.ExtensionAlert) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 33 with SiteNode

use of org.parosproxy.paros.model.SiteNode 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);
    }
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) DatabaseException(org.parosproxy.paros.db.DatabaseException) ExtensionAlert(org.zaproxy.zap.extension.alert.ExtensionAlert) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 34 with SiteNode

use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.

the class PopupMenuHistoryReference method getSelectedHistoryReference.

private HistoryReference getSelectedHistoryReference() {
    HistoryReference ref = null;
    try {
        switch(lastInvoker) {
            case sites:
                SiteNode sNode = (SiteNode) treeInvoker.getLastSelectedPathComponent();
                ref = sNode.getHistoryReference();
                break;
            case ascan:
            case history:
            case bruteforce:
            case search:
            case fuzz:
                ref = hrefsTableInvoker.getSelectedHistoryReference();
                break;
            case alerts:
                AlertNode aNode = (AlertNode) treeInvoker.getLastSelectedPathComponent();
                if (aNode.getUserObject() != null) {
                    Alert alert = aNode.getUserObject();
                    ref = alert.getHistoryRef();
                }
                break;
            case hreftable:
                ref = hrefTableInvoker.getSelectedHistoryReference();
                break;
        }
    } catch (Exception e2) {
        log.error(e2.getMessage(), e2);
    }
    return ref;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) AlertNode(org.zaproxy.zap.extension.alert.AlertNode) Alert(org.parosproxy.paros.core.scanner.Alert) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 35 with SiteNode

use of org.parosproxy.paros.model.SiteNode in project zaproxy by zaproxy.

the class PopupMenuHistoryReference method getSelectedHistoryReferences.

private List<HistoryReference> getSelectedHistoryReferences() {
    List<HistoryReference> refs = new ArrayList<>();
    TreePath[] treePaths = null;
    try {
        switch(lastInvoker) {
            case sites:
                treePaths = treeInvoker.getSelectionPaths();
                if (treePaths != null) {
                    for (TreePath path : treePaths) {
                        SiteNode node = (SiteNode) path.getLastPathComponent();
                        refs.add(node.getHistoryReference());
                    }
                }
                break;
            case ascan:
            case history:
            case bruteforce:
            case fuzz:
            case search:
                refs = hrefsTableInvoker.getSelectedHistoryReferences();
                break;
            case alerts:
                // Only support single items
                AlertNode aNode = (AlertNode) treeInvoker.getLastSelectedPathComponent();
                if (aNode.getUserObject() != null) {
                    Alert alert = aNode.getUserObject();
                    refs.add(alert.getHistoryRef());
                }
                break;
            case hreftable:
                refs = hrefTableInvoker.getSelectedHistoryReferences();
                break;
        }
    } catch (Exception e2) {
        log.error(e2.getMessage(), e2);
    }
    return refs;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) TreePath(javax.swing.tree.TreePath) ArrayList(java.util.ArrayList) AlertNode(org.zaproxy.zap.extension.alert.AlertNode) Alert(org.parosproxy.paros.core.scanner.Alert) SiteNode(org.parosproxy.paros.model.SiteNode)

Aggregations

SiteNode (org.parosproxy.paros.model.SiteNode)53 DatabaseException (org.parosproxy.paros.db.DatabaseException)10 HistoryReference (org.parosproxy.paros.model.HistoryReference)10 JTree (javax.swing.JTree)9 Target (org.zaproxy.zap.model.Target)8 SiteMap (org.parosproxy.paros.model.SiteMap)7 ArrayList (java.util.ArrayList)6 TreePath (javax.swing.tree.TreePath)6 Alert (org.parosproxy.paros.core.scanner.Alert)6 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)4 Context (org.zaproxy.zap.model.Context)4 StructuralSiteNode (org.zaproxy.zap.model.StructuralSiteNode)4 IOException (java.io.IOException)3 InvalidParameterException (java.security.InvalidParameterException)3 List (java.util.List)3 PatternSyntaxException (java.util.regex.PatternSyntaxException)3 ImageIcon (javax.swing.ImageIcon)3 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)3 URIException (org.apache.commons.httpclient.URIException)3 Session (org.parosproxy.paros.model.Session)3