use of org.parosproxy.paros.core.scanner.Plugin.AlertThreshold in project zaproxy by zaproxy.
the class CategoryTableModel method setValueAt.
@Override
public void setValueAt(Object value, int row, int col) {
Plugin test = listTestCategory.get(row).getPlugin();
switch(col) {
case 0:
break;
case 1:
AlertThreshold af = AlertThreshold.valueOf(i18nToStr((String) value));
boolean enable = !AlertThreshold.OFF.equals(af);
if (test.isEnabled() != enable) {
if (enable) {
String[] dependencies = test.getDependency();
if (dependencies != null && dependencies.length != 0) {
List<Plugin> allDeps = new ArrayList<>(dependencies.length);
if (!pluginFactory.addAllDependencies(test, allDeps)) {
View.getSingleton().showWarningDialog(Constant.messages.getString("ascan.policy.unfulfilled.dependencies"));
return;
}
List<Plugin> disabledDependencies = new ArrayList<>();
for (Plugin plugin : allDeps) {
if (!plugin.isEnabled()) {
disabledDependencies.add(plugin);
}
}
if (!disabledDependencies.isEmpty()) {
setPluginsEnabled(disabledDependencies, true);
}
}
} else {
List<Plugin> enabledDependents = new ArrayList<>();
for (Plugin plugin : pluginFactory.getDependentPlugins(test)) {
if (plugin.isEnabled()) {
enabledDependents.add(plugin);
}
}
if (!enabledDependents.isEmpty()) {
setPluginsEnabled(enabledDependents, false);
}
}
}
test.setAlertThreshold(af);
test.setEnabled(enable);
fireTableCellUpdated(row, col);
break;
case 2:
test.setAttackStrength(AttackStrength.valueOf(i18nToStr((String) value)));
fireTableCellUpdated(row, col);
break;
}
}
use of org.parosproxy.paros.core.scanner.Plugin.AlertThreshold in project zaproxy by zaproxy.
the class PolicyPassiveScanTableModel method setValueAt.
/**
*
* @param value
* @param row
* @param col
*/
@Override
public void setValueAt(Object value, int row, int col) {
ScannerWrapper test = listScanners.get(row);
switch(col) {
case 0:
break;
case 1:
AlertThreshold af = AlertThreshold.valueOf(i18nToStr((String) value));
test.setThreshold(af);
fireTableCellUpdated(row, col);
break;
}
}
use of org.parosproxy.paros.core.scanner.Plugin.AlertThreshold in project zaproxy by zaproxy.
the class PluginPassiveScannerUnitTest method shouldSetValidDefaultLevel.
@Test
public void shouldSetValidDefaultLevel() {
// Given
scanner.setLevel(AlertThreshold.DEFAULT);
AlertThreshold level = AlertThreshold.HIGH;
// When
scanner.setDefaultLevel(level);
// Then
assertThat(scanner.getLevel(), is(equalTo(level)));
}
use of org.parosproxy.paros.core.scanner.Plugin.AlertThreshold in project zaproxy by zaproxy.
the class PluginPassiveScannerUnitTest method shouldFailToSetDefaultToDefaultLevel.
@Test(expected = IllegalArgumentException.class)
public void shouldFailToSetDefaultToDefaultLevel() {
// Given
AlertThreshold level = AlertThreshold.DEFAULT;
// When
scanner.setDefaultLevel(level);
// Then = IllegalArgumentException.
}
use of org.parosproxy.paros.core.scanner.Plugin.AlertThreshold in project zaproxy by zaproxy.
the class ActiveScanAPI method isAlertThresholdChanged.
private boolean isAlertThresholdChanged(ScanPolicy policy, JSONObject params) throws ApiException {
if (!isParamExists(params, PARAM_ALERT_THRESHOLD)) {
return false;
}
AlertThreshold updatedAlertThreshold = getAlertThresholdFromParamAlertThreshold(params);
AlertThreshold currentThreshold = policy.getDefaultThreshold();
return !currentThreshold.equals(updatedAlertThreshold);
}
Aggregations