Search in sources :

Example 1 with StructuralSiteNode

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

the class PopupExcludeFromProxyMenu method performAction.

@Override
public void performAction(SiteNode sn) {
    try {
        Session session = Model.getSingleton().getSession();
        session.getExcludeFromProxyRegexs().add(new StructuralSiteNode(sn).getRegexPattern());
        SiteMap map = (SiteMap) View.getSingleton().getSiteTreePanel().getTreeSite().getModel();
        ExtensionHistory extHistory = Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.class);
        if (extHistory != null) {
            extHistory.purge(map, sn);
        }
    } catch (DatabaseException e) {
    // Ignore
    }
}
Also used : StructuralSiteNode(org.zaproxy.zap.model.StructuralSiteNode) SiteMap(org.parosproxy.paros.model.SiteMap) ExtensionHistory(org.parosproxy.paros.extension.history.ExtensionHistory) DatabaseException(org.parosproxy.paros.db.DatabaseException) Session(org.parosproxy.paros.model.Session)

Example 2 with StructuralSiteNode

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

the class PopupExcludeFromScanMenu method performAction.

@Override
public void performAction(SiteNode sn) {
    try {
        Session session = Model.getSingleton().getSession();
        session.getExcludeFromScanRegexs().add(new StructuralSiteNode(sn).getRegexPattern());
    } catch (DatabaseException e) {
    // Ignore
    }
}
Also used : StructuralSiteNode(org.zaproxy.zap.model.StructuralSiteNode) DatabaseException(org.parosproxy.paros.db.DatabaseException) Session(org.parosproxy.paros.model.Session)

Example 3 with StructuralSiteNode

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

the class ContextCreateDialog method save.

@Override
public void save() {
    Context ctx = Model.getSingleton().getSession().getNewContext(this.getStringValue(NAME_FIELD));
    ctx.setDescription(this.getStringValue(DESC_FIELD));
    ctx.setInScope(this.getBoolValue(IN_SCOPE_FIELD));
    if (topNode != null) {
        try {
            ctx.addIncludeInContextRegex(new StructuralSiteNode(topNode).getRegexPattern());
        } catch (DatabaseException e) {
        // Ignore
        }
    }
    Model.getSingleton().getSession().saveContext(ctx);
}
Also used : Context(org.zaproxy.zap.model.Context) StructuralSiteNode(org.zaproxy.zap.model.StructuralSiteNode) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 4 with StructuralSiteNode

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

the class ExtensionActiveScan method startScan.

@Override
public int startScan(String name, Target target, User user, Object[] contextSpecificObjects) {
    if (name == null) {
        name = target.getDisplayName();
    }
    switch(Control.getSingleton().getMode()) {
        case safe:
            throw new InvalidParameterException("Scans are not allowed in Safe mode");
        case protect:
            List<StructuralNode> nodes = target.getStartNodes();
            if (nodes != null) {
                for (StructuralNode node : nodes) {
                    if (node instanceof StructuralSiteNode) {
                        SiteNode siteNode = ((StructuralSiteNode) node).getSiteNode();
                        if (!siteNode.isIncludedInScope()) {
                            throw new InvalidParameterException("Scans are not allowed on nodes not in scope Protected mode " + target.getStartNode().getHierarchicNodeName());
                        }
                    }
                }
            }
            // No problem
            break;
        case standard:
            // No problem
            break;
        case attack:
            // No problem
            break;
    }
    int id = this.ascanController.startScan(name, target, user, contextSpecificObjects);
    if (hasView()) {
        ActiveScan scanner = this.ascanController.getScan(id);
        // So the UI get updated
        scanner.addScannerListener(getActiveScanPanel());
        this.getActiveScanPanel().scannerStarted(scanner);
        this.getActiveScanPanel().switchView(scanner);
        if (isPanelSwitch()) {
            this.getActiveScanPanel().setTabFocus();
        }
    }
    return id;
}
Also used : StructuralSiteNode(org.zaproxy.zap.model.StructuralSiteNode) InvalidParameterException(java.security.InvalidParameterException) StructuralNode(org.zaproxy.zap.model.StructuralNode) SiteNode(org.parosproxy.paros.model.SiteNode) StructuralSiteNode(org.zaproxy.zap.model.StructuralSiteNode)

Example 5 with StructuralSiteNode

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

the class SpiderDialog method validateFields.

@Override
public String validateFields() {
    if (Control.Mode.safe == Control.getSingleton().getMode()) {
        // The dialogue shouldn't be shown when in safe mode but if it is warn.
        return Constant.messages.getString("spider.custom.notSafe.error");
    }
    if (this.isEmptyField(FIELD_START)) {
        return Constant.messages.getString("spider.custom.nostart.error");
    }
    boolean noStartUri = true;
    if (!getStringValue(FIELD_START).equals(getTargetText(target))) {
        String url = this.getStringValue(FIELD_START);
        try {
            // Need both constructors as they catch slightly different issues ;)
            new URI(url, true);
            new URL(url);
        } catch (Exception e) {
            return Constant.messages.getString("spider.custom.nostart.error");
        }
        if (Control.getSingleton().getMode() == Control.Mode.protect) {
            if (!extension.isTargetUriInScope(url)) {
                return Constant.messages.getString("spider.custom.targetNotInScope.error", url);
            }
        }
        noStartUri = false;
    }
    if (this.target != null) {
        if (!this.target.isValid()) {
            return Constant.messages.getString("spider.custom.nostart.error");
        }
        if (Control.getSingleton().getMode() == Control.Mode.protect) {
            String uri = extension.getTargetUriOutOfScope(target);
            if (uri != null) {
                return Constant.messages.getString("spider.custom.targetNotInScope.error", uri);
            }
        }
        List<StructuralNode> nodes = target.getStartNodes();
        if (nodes != null) {
            for (StructuralNode node : nodes) {
                if (node instanceof StructuralSiteNode) {
                    noStartUri = false;
                    break;
                }
            }
        }
    }
    if (getBoolValue(FIELD_SUBTREE_ONLY) && noStartUri) {
        return Constant.messages.getString("spider.custom.noStartSubtreeOnly.error");
    }
    return null;
}
Also used : StructuralSiteNode(org.zaproxy.zap.model.StructuralSiteNode) StructuralNode(org.zaproxy.zap.model.StructuralNode) URI(org.apache.commons.httpclient.URI) URL(java.net.URL)

Aggregations

StructuralSiteNode (org.zaproxy.zap.model.StructuralSiteNode)8 DatabaseException (org.parosproxy.paros.db.DatabaseException)5 Session (org.parosproxy.paros.model.Session)3 StructuralNode (org.zaproxy.zap.model.StructuralNode)3 InvalidParameterException (java.security.InvalidParameterException)2 SiteNode (org.parosproxy.paros.model.SiteNode)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 URI (org.apache.commons.httpclient.URI)1 ExtensionHistory (org.parosproxy.paros.extension.history.ExtensionHistory)1 SiteMap (org.parosproxy.paros.model.SiteMap)1 HttpMessage (org.parosproxy.paros.network.HttpMessage)1 Context (org.zaproxy.zap.model.Context)1