Search in sources :

Example 11 with DomainMatcher

use of org.zaproxy.zap.network.DomainMatcher in project zaproxy by zaproxy.

the class DialogAddProxyExcludedDomain method performAction.

@Override
protected void performAction() {
    String value = getDomainTextField().getText();
    if (getRegexCheckBox().isSelected()) {
        Pattern pattern = DomainMatcher.createPattern(value);
        proxyExcludedDomain = new DomainMatcher(pattern);
    } else {
        proxyExcludedDomain = new DomainMatcher(value);
    }
    proxyExcludedDomain.setEnabled(getEnabledCheckBox().isSelected());
}
Also used : Pattern(java.util.regex.Pattern) DomainMatcher(org.zaproxy.zap.network.DomainMatcher)

Example 12 with DomainMatcher

use of org.zaproxy.zap.network.DomainMatcher in project zaproxy by zaproxy.

the class ConnectionParam method loadProxyExcludedDomains.

private void loadProxyExcludedDomains() {
    List<HierarchicalConfiguration> fields = ((HierarchicalConfiguration) getConfig()).configurationsAt(ALL_PROXY_EXCLUDED_DOMAINS_KEY);
    this.proxyExcludedDomains = new ArrayList<>(fields.size());
    ArrayList<DomainMatcher> excludedDomainsEnabled = new ArrayList<>(fields.size());
    for (HierarchicalConfiguration sub : fields) {
        String value = sub.getString(PROXY_EXCLUDED_DOMAIN_VALUE_KEY, "");
        if (value.isEmpty()) {
            log.warn("Failed to read an outgoing proxy excluded domain entry, required value is empty.");
            continue;
        }
        DomainMatcher excludedDomain = null;
        boolean regex = sub.getBoolean(PROXY_EXCLUDED_DOMAIN_REGEX_KEY, false);
        if (regex) {
            try {
                Pattern pattern = DomainMatcher.createPattern(value);
                excludedDomain = new DomainMatcher(pattern);
            } catch (IllegalArgumentException e) {
                log.error("Failed to read an outgoing proxy excluded domain entry with regex: " + value, e);
            }
        } else {
            excludedDomain = new DomainMatcher(value);
        }
        if (excludedDomain != null) {
            excludedDomain.setEnabled(sub.getBoolean(PROXY_EXCLUDED_DOMAIN_ENABLED_KEY, true));
            proxyExcludedDomains.add(excludedDomain);
            if (excludedDomain.isEnabled()) {
                excludedDomainsEnabled.add(excludedDomain);
            }
        }
    }
    excludedDomainsEnabled.trimToSize();
    this.proxyExcludedDomainsEnabled = excludedDomainsEnabled;
}
Also used : Pattern(java.util.regex.Pattern) ArrayList(java.util.ArrayList) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration) DomainMatcher(org.zaproxy.zap.network.DomainMatcher)

Aggregations

DomainMatcher (org.zaproxy.zap.network.DomainMatcher)12 ArrayList (java.util.ArrayList)6 Pattern (java.util.regex.Pattern)5 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)4 ConnectionParam (org.parosproxy.paros.network.ConnectionParam)2 File (java.io.File)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 JSONException (net.sf.json.JSONException)1 JSONObject (net.sf.json.JSONObject)1 URI (org.apache.commons.httpclient.URI)1 URIException (org.apache.commons.httpclient.URIException)1 Mode (org.parosproxy.paros.control.Control.Mode)1 DatabaseException (org.parosproxy.paros.db.DatabaseException)1 Session (org.parosproxy.paros.model.Session)1 SiteMap (org.parosproxy.paros.model.SiteMap)1