Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
  public void savePolicy(ScanPolicy policy, String previousName) throws ConfigurationException {
    logger.debug("Save policy " + policy.getName());

    File file = new File(Constant.getPoliciesDir(), policy.getName() + POLICY_EXTENSION);

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

    if (previousName != null && previousName.length() > 0) {
      allPolicyNames.remove(previousName);
    }
    if (!allPolicyNames.contains(policy.getName())) {
      allPolicyNames.add(policy.getName());
      Collections.sort(allPolicyNames);
    }
  }