Search in sources :

Example 6 with Target

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

the class ExtensionActiveScan method getMenuItemCustomScan.

private ZapMenuItem getMenuItemCustomScan() {
    if (menuItemCustomScan == null) {
        menuItemCustomScan = new ZapMenuItem("menu.tools.ascanadv", getView().getMenuShortcutKeyStroke(KeyEvent.VK_A, KeyEvent.ALT_DOWN_MASK, false));
        menuItemCustomScan.setEnabled(Control.getSingleton().getMode() != Mode.safe);
        menuItemCustomScan.addActionListener(e -> showCustomScanDialog((Target) null));
    }
    return menuItemCustomScan;
}
Also used : Target(org.zaproxy.zap.model.Target) ZapMenuItem(org.zaproxy.zap.view.ZapMenuItem)

Example 7 with Target

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

the class ExtensionActiveScan method startScanAllInScope.

public void startScanAllInScope() {
    SiteNode snroot = Model.getSingleton().getSession().getSiteTree().getRoot();
    this.startScan(new Target(snroot, null, true, true));
}
Also used : Target(org.zaproxy.zap.model.Target) SiteNode(org.parosproxy.paros.model.SiteNode) StructuralSiteNode(org.zaproxy.zap.model.StructuralSiteNode)

Example 8 with Target

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

the class NodeSelectDialog method showDialog.

public Target showDialog(Target defaultTarget) {
    // Assume Contexts can be selected
    this.getTreeContext().setVisible(true);
    SiteNode siteRoot = Model.getSingleton().getSession().getSiteTree().getRoot();
    populateContexts((SiteNode) this.contextTree.getRoot());
    if (defaultTarget != null) {
        populateNode(siteRoot, (SiteNode) this.siteTree.getRoot(), defaultTarget.getStartNode());
    } else {
        populateNode(siteRoot, (SiteNode) this.siteTree.getRoot(), null);
    }
    if (selectedSiteNode != null) {
        // Found the default node, select it
        TreePath path = new TreePath(this.siteTree.getPathToRoot(selectedSiteNode));
        this.getTreeSite().setExpandsSelectedPaths(true);
        this.getTreeSite().setSelectionPath(path);
        this.getTreeSite().scrollPathToVisible(path);
        this.getTreeSite().expandPath(path);
    } else {
        // no default path, just expand the top level
        TreePath path = new TreePath(this.siteTree.getPathToRoot((TreeNode) this.siteTree.getRoot()));
        this.getTreeSite().expandPath(path);
    }
    this.setVisible(true);
    // The dialog is modal so this wont return until the dialog visibility is unset
    if (selectedSiteNode != null) {
        return new Target(selectedSiteNode);
    }
    return selectedTarget;
}
Also used : Target(org.zaproxy.zap.model.Target) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 9 with Target

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

the class StandardFieldsDialog method addTargetSelectField.

/**
 * Add a 'node select' field to a non tabbed dialog. This includes a button for showing a Node
 * Select Dialog and a field for showing the selected node.
 *
 * @param fieldLabel the {@code I18N} key for the field label, should not be null
 * @param value the selected {@code Target} to show, can be null
 * @param editable whether the field showing selected {@code Target} is editable or not
 * @param allowRoot whether to allow root {@code SiteNode} to be selected as {@code Target}
 *     value or not
 * @since 2.8.0
 * @see #addTargetSelectField(int, String, Target, boolean, boolean)
 */
public void addTargetSelectField(final String fieldLabel, final Target value, final boolean editable, final boolean allowRoot) {
    validateNotTabbed();
    final ZapTextField text = new ZapTextField();
    text.setEditable(editable);
    this.setTextTarget(text, value);
    JButton selectButton = new JButton(Constant.messages.getString("all.button.select"));
    selectButton.setIcon(// Globe icon
    new ImageIcon(View.class.getResource("/resource/icon/16/094.png")));
    selectButton.addActionListener(new java.awt.event.ActionListener() {

        // Keep a local copy so that we can always select the last node chosen
        Target target = value;

        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            NodeSelectDialog nsd = new NodeSelectDialog(StandardFieldsDialog.this);
            nsd.setAllowRoot(allowRoot);
            target = nsd.showDialog(target);
            setTextTarget(text, target);
            targetSelected(fieldLabel, target);
        }
    });
    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    panel.add(text, LayoutHelper.getGBC(0, 0, 1, 1.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4)));
    panel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4)));
    this.addField(fieldLabel, text, panel, 0.0D);
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) ActionEvent(java.awt.event.ActionEvent) Target(org.zaproxy.zap.model.Target) ZapTextField(org.zaproxy.zap.utils.ZapTextField)

Example 10 with Target

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

the class HistoryReference method notifyEvent.

private void notifyEvent(String event) {
    Map<String, String> map = new HashMap<>();
    map.put(HistoryReferenceEventPublisher.FIELD_HISTORY_REFERENCE_ID, Integer.toString(historyId));
    ZAP.getEventBus().publishSyncEvent(HistoryReferenceEventPublisher.getPublisher(), new Event(HistoryReferenceEventPublisher.getPublisher(), event, new Target(getSiteNode()), map));
}
Also used : Target(org.zaproxy.zap.model.Target) HashMap(java.util.HashMap) Event(org.zaproxy.zap.eventBus.Event)

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