use of org.zaproxy.zap.network.DomainMatcher in project zaproxy by zaproxy.
the class ConnectionParam method setProxyExcludedDomains.
/**
* Sets the domains that will be excluded from the outgoing proxy.
*
* @param proxyExcludedDomains the domains that will be excluded.
* @since 2.3.0
* @see #getProxyExcludedDomains()
* @see #getProxyExcludedDomainsEnabled()
*/
public void setProxyExcludedDomains(List<DomainMatcher> proxyExcludedDomains) {
if (proxyExcludedDomains == null || proxyExcludedDomains.isEmpty()) {
((HierarchicalConfiguration) getConfig()).clearTree(ALL_PROXY_EXCLUDED_DOMAINS_KEY);
this.proxyExcludedDomains = Collections.emptyList();
this.proxyExcludedDomainsEnabled = Collections.emptyList();
return;
}
this.proxyExcludedDomains = new ArrayList<>(proxyExcludedDomains);
((HierarchicalConfiguration) getConfig()).clearTree(ALL_PROXY_EXCLUDED_DOMAINS_KEY);
int size = proxyExcludedDomains.size();
ArrayList<DomainMatcher> enabledExcludedDomains = new ArrayList<>(size);
for (int i = 0; i < size; ++i) {
String elementBaseKey = ALL_PROXY_EXCLUDED_DOMAINS_KEY + "(" + i + ").";
DomainMatcher excludedDomain = proxyExcludedDomains.get(i);
getConfig().setProperty(elementBaseKey + PROXY_EXCLUDED_DOMAIN_VALUE_KEY, excludedDomain.getValue());
getConfig().setProperty(elementBaseKey + PROXY_EXCLUDED_DOMAIN_REGEX_KEY, Boolean.valueOf(excludedDomain.isRegex()));
getConfig().setProperty(elementBaseKey + PROXY_EXCLUDED_DOMAIN_ENABLED_KEY, Boolean.valueOf(excludedDomain.isEnabled()));
if (excludedDomain.isEnabled()) {
enabledExcludedDomains.add(excludedDomain);
}
}
enabledExcludedDomains.trimToSize();
this.proxyExcludedDomainsEnabled = enabledExcludedDomains;
}
use of org.zaproxy.zap.network.DomainMatcher in project zaproxy by zaproxy.
the class CoreAPI method setProxyChainExcludedDomainsEnabled.
private void setProxyChainExcludedDomainsEnabled(boolean enabled) {
ConnectionParam connectionParam = Model.getSingleton().getOptionsParam().getConnectionParam();
List<DomainMatcher> domains = connectionParam.getProxyExcludedDomains();
for (DomainMatcher domain : domains) {
domain.setEnabled(enabled);
}
connectionParam.setProxyExcludedDomains(domains);
}
use of org.zaproxy.zap.network.DomainMatcher in project zaproxy by zaproxy.
the class DialogAddPermittedAddress method performAction.
@Override
protected void performAction() {
String value = getAddressTextField().getText();
if (getRegexCheckBox().isSelected()) {
Pattern pattern = DomainMatcher.createPattern(value);
address = new DomainMatcher(pattern);
} else {
address = new DomainMatcher(value);
}
address.setEnabled(getEnabledCheckBox().isSelected());
}
use of org.zaproxy.zap.network.DomainMatcher in project zaproxy by zaproxy.
the class OptionsParamApi method loadPermittedAddresses.
private void loadPermittedAddresses() {
List<HierarchicalConfiguration> fields = ((HierarchicalConfiguration) getConfig()).configurationsAt(ADDRESS_KEY);
this.permittedAddresses = new ArrayList<>(fields.size());
ArrayList<DomainMatcher> addrsEnabled = new ArrayList<>(fields.size());
for (HierarchicalConfiguration sub : fields) {
String value = sub.getString(ADDRESS_VALUE_KEY, "");
if (value.isEmpty()) {
LOGGER.warn("Failed to read a permitted address entry, required value is empty.");
continue;
}
DomainMatcher addr = null;
boolean regex = sub.getBoolean(ADDRESS_REGEX_KEY, false);
if (regex) {
try {
Pattern pattern = DomainMatcher.createPattern(value);
addr = new DomainMatcher(pattern);
} catch (IllegalArgumentException e) {
LOGGER.error("Failed to read a permitted address entry with regex: " + value, e);
}
} else {
addr = new DomainMatcher(value);
}
if (addr != null) {
addr.setEnabled(sub.getBoolean(ADDRESS_ENABLED_KEY, true));
permittedAddresses.add(addr);
if (addr.isEnabled()) {
addrsEnabled.add(addr);
}
}
}
addrsEnabled.trimToSize();
if (permittedAddresses.size() == 0) {
// None specified - add in the defaults (which can then be disabled)
DomainMatcher addr = new DomainMatcher("127.0.0.1");
permittedAddresses.add(addr);
addrsEnabled.add(addr);
addr = new DomainMatcher("localhost");
permittedAddresses.add(addr);
addrsEnabled.add(addr);
addr = new DomainMatcher("zap");
permittedAddresses.add(addr);
addrsEnabled.add(addr);
}
this.permittedAddressesEnabled = addrsEnabled;
}
use of org.zaproxy.zap.network.DomainMatcher in project zaproxy by zaproxy.
the class PermittedAddressesTableModel method setAddresses.
public void setAddresses(List<DomainMatcher> addrs) {
this.addresses = new ArrayList<>(addrs.size());
for (DomainMatcher addr : addrs) {
this.addresses.add(new DomainMatcher(addr));
}
fireTableDataChanged();
}
Aggregations