use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class ScanPolicyUnitTest method shouldUseValidDefaultScannerStrengthFromConfig.
@Test
void shouldUseValidDefaultScannerStrengthFromConfig() throws Exception {
// Given
ZapXmlConfiguration conf = new ZapXmlConfiguration();
conf.setProperty(DEFAULT_SCANNER_STRENGTH_KEY, Plugin.AttackStrength.LOW.name());
// When
ScanPolicy scanPolicy = new ScanPolicy(conf);
// Then
assertThat(scanPolicy.getDefaultStrength(), is(equalTo(Plugin.AttackStrength.LOW)));
}
use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class ScanPolicyUnitTest method shouldUseMediumIfInvalidDefaultScannerStrengthFromConfig.
@Test
void shouldUseMediumIfInvalidDefaultScannerStrengthFromConfig() throws Exception {
// Given
ZapXmlConfiguration conf = new ZapXmlConfiguration();
conf.setProperty(DEFAULT_SCANNER_STRENGTH_KEY, "NotValid");
// When
ScanPolicy scanPolicy = new ScanPolicy(conf);
// Then
assertThat(scanPolicy.getDefaultStrength(), is(equalTo(Plugin.AttackStrength.MEDIUM)));
}
use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class ScanPolicyUnitTest method shouldUseValidDefaultScannerLevelFromConfig.
@Test
void shouldUseValidDefaultScannerLevelFromConfig() throws Exception {
// Given
ZapXmlConfiguration conf = new ZapXmlConfiguration();
conf.setProperty(DEFAULT_SCANNER_LEVEL_KEY, Plugin.AlertThreshold.HIGH.name());
// When
ScanPolicy scanPolicy = new ScanPolicy(conf);
// Then
assertThat(scanPolicy.getDefaultThreshold(), is(equalTo(Plugin.AlertThreshold.HIGH)));
}
use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class ExtensionParamUnitTest method createMalformedTestConfig.
private static FileConfiguration createMalformedTestConfig() {
ZapXmlConfiguration config = new ZapXmlConfiguration();
for (int i = 0; i < 3; ++i) {
String elementBaseKey = "extensions.extension(" + i + ").";
config.setProperty(elementBaseKey, null);
config.setProperty(elementBaseKey + "enabled", "X");
}
return config;
}
use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class VulnerabilitiesLoader method loadVulnerabilitiesFile.
private List<Vulnerability> loadVulnerabilitiesFile(Path file) {
ZapXmlConfiguration config;
try {
config = new ZapXmlConfiguration(file.toFile());
} catch (ConfigurationException e) {
logger.error(e.getMessage(), e);
return null;
}
String[] test;
try {
test = config.getStringArray("vuln_items");
} catch (ConversionException e) {
logger.error(e.getMessage(), e);
return null;
}
final int numberOfVulns = test.length;
List<Vulnerability> tempVulns = new ArrayList<>(numberOfVulns);
String name;
List<String> references;
for (String item : test) {
name = "vuln_item_" + item;
try {
references = new ArrayList<>(Arrays.asList(config.getStringArray(name + ".reference")));
} catch (ConversionException e) {
logger.error(e.getMessage(), e);
references = new ArrayList<>(0);
}
Vulnerability v = new Vulnerability(item, config.getString(name + ".alert"), config.getString(name + ".desc"), config.getString(name + ".solution"), references);
tempVulns.add(v);
}
return tempVulns;
}
Aggregations