Search in sources :

Example 46 with SiteNode

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

the class Context method fillNodesInContext.

/**
	 * Fills a given list with nodes in scope, searching recursively.
	 * 
	 * @param rootNode the root node
	 * @param nodesList the nodes list
	 */
private void fillNodesInContext(SiteNode rootNode, List<SiteNode> nodesList) {
    @SuppressWarnings("unchecked") Enumeration<SiteNode> en = rootNode.children();
    while (en.hasMoreElements()) {
        SiteNode sn = en.nextElement();
        if (isInContext(sn)) {
            nodesList.add(sn);
        }
        fillNodesInContext(sn, nodesList);
    }
}
Also used : SiteNode(org.parosproxy.paros.model.SiteNode)

Example 47 with SiteNode

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

the class SessionStructure method find.

public static StructuralNode find(long sessionId, URI uri, String method, String postData) throws DatabaseException, URIException {
    Model model = Model.getSingleton();
    if (!Constant.isLowMemoryOptionSet()) {
        SiteNode node = model.getSession().getSiteTree().findNode(uri, method, postData);
        if (node == null) {
            return null;
        }
        return new StructuralSiteNode(node);
    }
    String nodeName = getNodeName(sessionId, uri, method, postData);
    RecordStructure rs = model.getDb().getTableStructure().find(sessionId, nodeName, method);
    if (rs == null) {
        return null;
    }
    return new StructuralTableNode(rs);
}
Also used : RecordStructure(org.parosproxy.paros.db.RecordStructure) Model(org.parosproxy.paros.model.Model) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 48 with SiteNode

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

the class SiteMapPanel method getTreeContext.

private JTree getTreeContext() {
    if (treeContext == null) {
        reloadContextTree();
        treeContext = new JTree(this.contextTree);
        treeContext.setShowsRootHandles(true);
        treeContext.setName(CONTEXT_TREE_COMPONENT_NAME);
        treeContext.setToggleClickCount(1);
        treeContext.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        treeContext.addMouseListener(new java.awt.event.MouseAdapter() {

            @Override
            public void mousePressed(java.awt.event.MouseEvent e) {
            }

            @Override
            public void mouseReleased(java.awt.event.MouseEvent e) {
                mouseClicked(e);
            }

            @Override
            public void mouseClicked(java.awt.event.MouseEvent e) {
                if (treeSite.getLastSelectedPathComponent() != null) {
                    // They selected a context node, deselect any context
                    getTreeSite().clearSelection();
                }
                if (e.getClickCount() > 1) {
                    // Its a double click - show the relevant context dialog
                    SiteNode node = (SiteNode) treeContext.getLastSelectedPathComponent();
                    if (node != null && node.getUserObject() != null) {
                        Target target = (Target) node.getUserObject();
                        getView().showSessionDialog(Model.getSingleton().getSession(), ContextGeneralPanel.getPanelName(target.getContext()));
                    }
                }
            }
        });
        treeContext.setComponentPopupMenu(new ContextsCustomPopupMenu());
        treeContext.setCellRenderer(new ContextsTreeCellRenderer());
    }
    return treeContext;
}
Also used : JTree(javax.swing.JTree) Target(org.zaproxy.zap.model.Target) ContextsTreeCellRenderer(org.zaproxy.zap.view.ContextsTreeCellRenderer) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 49 with SiteNode

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

the class SiteMapPanel method reloadContextTree.

public void reloadContextTree() {
    SiteNode root;
    if (this.contextTree == null) {
        root = new SiteNode(null, -1, Constant.messages.getString("context.list"));
        this.contextTree = new DefaultTreeModel(root);
    } else {
        root = (SiteNode) this.contextTree.getRoot();
        root.removeAllChildren();
    }
    for (Context ctx : Model.getSingleton().getSession().getContexts()) {
        if (ctx.isInScope() || !this.getScopeButton().isSelected()) {
            // Add all in scope contexts, and out of scope ones if scope button not pressed
            SiteNode node = new SiteNode(null, HistoryReference.TYPE_PROXIED, ctx.getName());
            node.setUserObject(new Target(ctx));
            root.add(node);
        }
    }
    this.contextTree.nodeStructureChanged(root);
}
Also used : Context(org.zaproxy.zap.model.Context) Target(org.zaproxy.zap.model.Target) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 50 with SiteNode

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

the class SiteMapPanel method contextChanged.

public void contextChanged(Context c) {
    getTreeContext();
    SiteNode root = (SiteNode) this.contextTree.getRoot();
    for (int i = 0; i < root.getChildCount(); i++) {
        SiteNode node = (SiteNode) root.getChildAt(i);
        Target target = (Target) node.getUserObject();
        if (c.getIndex() == target.getContext().getIndex()) {
            target.setContext(c);
            if (node.getNodeName().equals(c.getName())) {
                this.contextTree.nodeChanged(node);
            } else {
                this.reloadContextTree();
            }
            break;
        }
    }
}
Also used : Target(org.zaproxy.zap.model.Target) 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