Search in sources :

Example 6 with StructuralSiteNode

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

the class HttpBreakpointsUiManagerInterface method showAddDialog.

private void showAddDialog(Message aMessage) {
    HttpBreakpointMessage.Match match = HttpBreakpointMessage.Match.regex;
    HttpMessage msg = (HttpMessage) aMessage;
    String regex = "";
    if (msg.getHistoryRef() != null && msg.getHistoryRef().getSiteNode() != null) {
        try {
            regex = new StructuralSiteNode(msg.getHistoryRef().getSiteNode()).getRegexPattern(false);
        } catch (DatabaseException e) {
        // Ignore
        }
    }
    if (regex.length() == 0 && msg.getRequestHeader().getURI() != null) {
        // Just use the escaped url
        regex = msg.getRequestHeader().getURI().toString();
        match = HttpBreakpointMessage.Match.contains;
    }
    this.showAddDialog(regex, match);
}
Also used : StructuralSiteNode(org.zaproxy.zap.model.StructuralSiteNode) HttpMessage(org.parosproxy.paros.network.HttpMessage) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 7 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)

Example 8 with StructuralSiteNode

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

the class PopupExcludeFromSpiderMenu method performAction.

@Override
public void performAction(SiteNode sn) {
    try {
        Session session = Model.getSingleton().getSession();
        session.getExcludeFromSpiderRegexs().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)

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