Search in sources :

Example 1 with AlertThreshold

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;
    }
}
Also used : ArrayList(java.util.ArrayList) Plugin(org.parosproxy.paros.core.scanner.Plugin) AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold)

Example 2 with AlertThreshold

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;
    }
}
Also used : AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold)

Example 3 with AlertThreshold

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)));
}
Also used : AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold) Test(org.junit.Test)

Example 4 with AlertThreshold

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.
}
Also used : AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold) Test(org.junit.Test)

Example 5 with AlertThreshold

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);
}
Also used : AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold)

Aggregations

AlertThreshold (org.parosproxy.paros.core.scanner.Plugin.AlertThreshold)14 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 Plugin (org.parosproxy.paros.core.scanner.Plugin)4 DefaultCellEditor (javax.swing.DefaultCellEditor)3 JComboBox (javax.swing.JComboBox)3 JTable (javax.swing.JTable)3 RowSorter (javax.swing.RowSorter)3 TableColumn (javax.swing.table.TableColumn)3 AttackStrength (org.parosproxy.paros.core.scanner.Plugin.AttackStrength)2 ScannerParamFilter (org.parosproxy.paros.core.scanner.ScannerParamFilter)2 Session (org.parosproxy.paros.model.Session)2 ApiException (org.zaproxy.zap.extension.api.ApiException)2 ApiResponseElement (org.zaproxy.zap.extension.api.ApiResponseElement)2 GenericScanner2 (org.zaproxy.zap.model.GenericScanner2)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 JSONException (net.sf.json.JSONException)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1