use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class PolicyManager method importPolicy.
public void importPolicy(File file) throws ConfigurationException, IOException {
logger.debug("Import policy from " + file.getAbsolutePath());
ScanPolicy policy = new ScanPolicy(new ZapXmlConfiguration(file));
String baseName = file.getName();
if (baseName.endsWith(POLICY_EXTENSION)) {
// Stip off the extension for the 'friendly name' and if we need to prevent overwriting
// an existing one
baseName = baseName.substring(0, baseName.indexOf(POLICY_EXTENSION));
}
String finalName = baseName;
File newFile = new File(Constant.getPoliciesDir(), finalName + POLICY_EXTENSION);
int i = 2;
while (newFile.exists()) {
finalName = baseName + i;
newFile = new File(Constant.getPoliciesDir(), finalName + POLICY_EXTENSION);
i++;
}
policy.setName(finalName);
this.savePolicy(policy);
}
use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class PolicyManager method exportPolicy.
public void exportPolicy(ScanPolicy policy, File file) throws ConfigurationException {
logger.debug("Export policy to " + file.getAbsolutePath());
ZapXmlConfiguration conf = new ZapXmlConfiguration();
conf.setProperty("policy", policy.getName());
conf.setProperty("scanner.level", policy.getDefaultThreshold().name());
conf.setProperty("scanner.strength", policy.getDefaultStrength().name());
policy.getPluginFactory().saveTo(conf);
conf.save(file);
}
use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class SpiderParserTestUtils method createSpiderParamWithConfig.
protected static SpiderParam createSpiderParamWithConfig() {
SpiderParam spiderParam = new SpiderParam();
spiderParam.load(new ZapXmlConfiguration());
return spiderParam;
}
use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class AddOnCollectionUnitTest method shouldAcceptAddOnsWithoutDependencyIssues.
@Test
void shouldAcceptAddOnsWithoutDependencyIssues() throws Exception {
// Given
ZapXmlConfiguration zapVersions = createConfiguration("ZapVersions-deps.xml");
// When
AddOnCollection addOnCollection = new AddOnCollection(zapVersions, Platform.daily, false);
// Then
assertThat(addOnCollection.getAddOns().size(), is(equalTo(9)));
assertThat(addOnCollection.getAddOn("AddOn1"), is(notNullValue()));
assertThat(addOnCollection.getAddOn("AddOn2"), is(notNullValue()));
assertThat(addOnCollection.getAddOn("AddOn3"), is(notNullValue()));
assertThat(addOnCollection.getAddOn("AddOn4"), is(notNullValue()));
assertThat(addOnCollection.getAddOn("AddOn5"), is(notNullValue()));
assertThat(addOnCollection.getAddOn("AddOn6"), is(notNullValue()));
assertThat(addOnCollection.getAddOn("AddOn7"), is(notNullValue()));
assertThat(addOnCollection.getAddOn("AddOn8"), is(notNullValue()));
assertThat(addOnCollection.getAddOn("AddOn9"), is(notNullValue()));
}
use of org.zaproxy.zap.utils.ZapXmlConfiguration in project zaproxy by zaproxy.
the class AddOnUnitTest method shouldNotDirectlyDependOnNonDirectDependencies.
@Test
void shouldNotDirectlyDependOnNonDirectDependencies() throws Exception {
// Given
ZapXmlConfiguration zapVersionsXml = createZapVersionsXml();
AddOn addOn = createAddOn("AddOn1", zapVersionsXml);
AddOn nonDependency = createAddOn("AddOn9", zapVersionsXml);
AddOn nonDirectDependency = createAddOn("AddOn8", zapVersionsXml);
Collection<AddOn> addOns = Arrays.asList(new AddOn[] { nonDependency, nonDirectDependency });
// When
boolean depends = addOn.dependsOn(addOns);
// Then
assertThat(depends, is(equalTo(false)));
}
Aggregations