Search in sources :

Example 11 with Target

use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.

the class ExtensionActiveScan method showCustomScanDialog.

public void showCustomScanDialog(SiteNode node) {
    if (customScanDialog == null) {
        // Work out the tabs 
        String[] tabs = CustomScanDialog.STD_TAB_LABELS;
        if (this.customScanPanels.size() > 0) {
            List<String> tabList = new ArrayList<String>();
            for (String str : CustomScanDialog.STD_TAB_LABELS) {
                tabList.add(str);
            }
            for (CustomScanPanel csp : customScanPanels) {
                tabList.add(csp.getLabel());
            }
            tabs = tabList.toArray(new String[tabList.size()]);
        }
        customScanDialog = new CustomScanDialog(this, tabs, this.customScanPanels, View.getSingleton().getMainFrame(), new Dimension(700, 500));
    }
    if (customScanDialog.isVisible()) {
        customScanDialog.requestFocus();
        // Its behind you! Actually not needed no the window is alwaysOnTop, but keeping in case we change that ;)
        customScanDialog.toFront();
        return;
    }
    if (node != null) {
        customScanDialog.init(new Target(node));
    } else {
        // Keep the previously selected target
        customScanDialog.init(null);
    }
    customScanDialog.setVisible(true);
}
Also used : Target(org.zaproxy.zap.model.Target) ArrayList(java.util.ArrayList) Dimension(java.awt.Dimension)

Example 12 with Target

use of org.zaproxy.zap.model.Target 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.getId() == target.getContext().getId()) {
            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)

Example 13 with Target

use of org.zaproxy.zap.model.Target 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.DISCONTIGUOUS_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) {
                TreePath path = treeContext.getClosestPathForLocation(e.getX(), e.getY());
                if (treeSite.getLastSelectedPathComponent() != null) {
                    getTreeSite().clearSelection();
                }
                if (path != null) {
                    if (((SiteNode) path.getLastPathComponent()).isRoot()) {
                        treeContext.removeSelectionPath(path);
                    }
                }
                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();
                        String panelName = ContextGeneralPanel.getPanelName(target.getContext());
                        getView().getSessionDialog().expandParamPanelNode(panelName);
                        if (getView().getSessionDialog().isParamPanelOrChildSelected(panelName)) {
                            panelName = null;
                        }
                        getView().showSessionDialog(Model.getSingleton().getSession(), panelName);
                    }
                }
            }
        });
        treeContext.setComponentPopupMenu(new ContextsCustomPopupMenu());
        treeContext.setCellRenderer(new ContextsTreeCellRenderer());
        DeleteContextAction delContextAction = new DeleteContextAction() {

            private static final long serialVersionUID = 1L;

            @Override
            protected List<Context> getContexts() {
                return getSelectedContexts();
            }

            @Override
            protected Context getContext() {
                return getSelectedContext();
            }
        };
        treeContext.getInputMap().put((KeyStroke) delContextAction.getValue(DeleteContextAction.ACCELERATOR_KEY), DeleteContextAction.ACTION_NAME);
        treeContext.getActionMap().put(DeleteContextAction.ACTION_NAME, delContextAction);
    }
    return treeContext;
}
Also used : Context(org.zaproxy.zap.model.Context) ContextsTreeCellRenderer(org.zaproxy.zap.view.ContextsTreeCellRenderer) JTree(javax.swing.JTree) Target(org.zaproxy.zap.model.Target) TreePath(javax.swing.tree.TreePath) DeleteContextAction(org.zaproxy.zap.view.DeleteContextAction) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 14 with Target

use of org.zaproxy.zap.model.Target 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 15 with Target

use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.

the class ActiveScanPanel method getNewScanButton.

@Override
public JButton getNewScanButton() {
    if (scanButton == null) {
        scanButton = new JButton(Constant.messages.getString("ascan.toolbar.button.new"));
        scanButton.setIcon(DisplayUtils.getScaledIcon(new ImageIcon(ActiveScanPanel.class.getResource("/resource/icon/16/093.png"))));
        scanButton.addActionListener(e -> extension.showCustomScanDialog((Target) null));
    }
    return scanButton;
}
Also used : ImageIcon(javax.swing.ImageIcon) Target(org.zaproxy.zap.model.Target) JButton(javax.swing.JButton)

Aggregations

Target (org.zaproxy.zap.model.Target)25 SiteNode (org.parosproxy.paros.model.SiteNode)9 ArrayList (java.util.ArrayList)4 ImageIcon (javax.swing.ImageIcon)3 JButton (javax.swing.JButton)3 TreePath (javax.swing.tree.TreePath)3 URI (org.apache.commons.httpclient.URI)3 Context (org.zaproxy.zap.model.Context)3 StructuralNode (org.zaproxy.zap.model.StructuralNode)3 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 HashMap (java.util.HashMap)2 JPanel (javax.swing.JPanel)2 JTree (javax.swing.JTree)2 JSONObject (net.sf.json.JSONObject)2 URIException (org.apache.commons.httpclient.URIException)2 Event (org.zaproxy.zap.eventBus.Event)2 ApiException (org.zaproxy.zap.extension.api.ApiException)2