Search in sources :

Example 11 with HistoryReference

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

the class ExtensionHistory method buildHistory.

private void buildHistory(List<Integer> dbList, HistoryFilter historyFilter) {
    HistoryReference historyRef = null;
    synchronized (historyTableModel) {
        if (getView() != null) {
            getLogPanel().setModel(EMPTY_MODEL);
        }
        historyTableModel.clear();
        for (int i = 0; i < dbList.size(); i++) {
            int historyId = (dbList.get(i)).intValue();
            try {
                SiteNode sn = getModel().getSession().getSiteTree().getSiteNode(historyId);
                if (sn != null && sn.getHistoryReference() != null && sn.getHistoryReference().getHistoryId() == historyId) {
                    historyRef = sn.getHistoryReference();
                } else {
                    historyRef = getHistoryReference(historyId);
                    if (sn != null) {
                        sn.setHistoryReference(historyRef);
                    }
                }
                final String uri = historyRef.getURI().toString();
                if (this.showJustInScope && !getModel().getSession().isInScope(uri)) {
                    // Not in scope
                    continue;
                } else if (linkWithSitesTree && linkWithSitesTreeBaseUri != null && !uri.startsWith(linkWithSitesTreeBaseUri)) {
                    // Not under the selected node
                    continue;
                }
                if (historyFilter != null && !historyFilter.matches(historyRef)) {
                    // Not in filter
                    continue;
                }
                historyRef.loadAlerts();
                historyTableModel.addHistoryReference(historyRef);
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }
        if (getView() != null) {
            getLogPanel().setModel(historyTableModel);
        }
    }
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) DatabaseException(org.parosproxy.paros.db.DatabaseException) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 12 with HistoryReference

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

the class SpiderMessagesTableModel method addHistoryReference.

@Override
public void addHistoryReference(HistoryReference historyReference) {
    HistoryReference latestHistoryReference = historyReference;
    if (extensionHistory != null) {
        latestHistoryReference = extensionHistory.getHistoryReference(historyReference.getHistoryId());
    }
    super.addHistoryReference(latestHistoryReference);
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference)

Example 13 with HistoryReference

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

the class PopupMenuCopyUrls method performHistoryReferenceActions.

@Override
protected void performHistoryReferenceActions(List<HistoryReference> hrefs) {
    StringBuilder sb = new StringBuilder();
    for (HistoryReference href : hrefs) {
        sb.append(href.getURI().toString());
        sb.append("\n");
    }
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents(new StringSelection(sb.toString()), this);
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) Clipboard(java.awt.datatransfer.Clipboard) StringSelection(java.awt.datatransfer.StringSelection)

Example 14 with HistoryReference

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

the class Context method checkNode.

private boolean checkNode(SiteNode sn) {
    // Loop backwards through the children TODO change for lowmem!
    // log.debug("checkNode " + sn.getHierarchicNodeName());		// Useful for debugging
    int origChildren = sn.getChildCount();
    int movedChildren = 0;
    for (SiteNode childNode : getChildren(sn)) {
        if (checkNode(childNode)) {
            movedChildren++;
        }
    }
    if (this.isInContext(sn)) {
        SiteMap sitesTree = this.session.getSiteTree();
        HistoryReference href = sn.getHistoryReference();
        try {
            SiteNode sn2;
            if (HttpRequestHeader.POST.equals(href.getMethod())) {
                // Have to go to the db as POST data can be used in the name
                sn2 = sitesTree.findNode(href.getHttpMessage());
            } else {
                // This is better as it doesnt require a db read
                sn2 = sitesTree.findNode(href.getURI());
            }
            if (sn2 == null || !sn.getHierarchicNodeName().equals(sn2.getHierarchicNodeName())) {
                if (!sn.isDataDriven()) {
                    moveNode(sitesTree, sn);
                    return true;
                }
            }
            if (movedChildren > 0 && movedChildren == origChildren && sn.getChildCount() == 0) {
                if (href.getHistoryType() == HistoryReference.TYPE_TEMPORARY) {
                    // Remove temp old node, no need to add new one in - 
                    // that will happen when moving child nodes (if required)
                    deleteNode(sitesTree, sn);
                    return true;
                }
            }
        // log.debug("Didnt need to move " + sn.getHierarchicNodeName());	// Useful for debugging
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    return false;
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference) SiteMap(org.parosproxy.paros.model.SiteMap) PatternSyntaxException(java.util.regex.PatternSyntaxException) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 15 with HistoryReference

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

the class SpiderThread method readURI.

@Override
public void readURI(final HttpMessage msg) {
    // Add the read message to the Site Map (tree or db structure)
    try {
        final HistoryReference historyRef = new HistoryReference(extension.getModel().getSession(), HistoryReference.TYPE_SPIDER, msg);
        addMessageToSitesTree(historyRef, msg);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : HistoryReference(org.parosproxy.paros.model.HistoryReference)

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