Search in sources :

Example 6 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 7 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 8 with AlertThreshold

use of org.parosproxy.paros.core.scanner.Plugin.AlertThreshold in project zaproxy by zaproxy.

the class CategoryTableModel method setPluginsEnabled.

private void setPluginsEnabled(List<Plugin> plugins, boolean enabled) {
    AlertThreshold alertThreshold = enabled ? defaultThreshold : AlertThreshold.OFF;
    for (Plugin plugin : plugins) {
        plugin.setEnabled(enabled);
        plugin.setAlertThreshold(alertThreshold);
        if (plugin.getCategory() == category) {
            int rowDep = getPluginRow(plugin);
            if (rowDep != -1) {
                fireTableCellUpdated(rowDep, 1);
            }
        }
    }
}
Also used : AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold) Plugin(org.parosproxy.paros.core.scanner.Plugin)

Example 9 with AlertThreshold

use of org.parosproxy.paros.core.scanner.Plugin.AlertThreshold in project zaproxy by zaproxy.

the class PolicyAllCategoryPanel method getTableTest.

/**
     * This method initializes tableTest
     *
     * @return javax.swing.JTable
     */
private JTable getTableTest() {
    if (tableTest == null) {
        tableTest = new JTable();
        tableTest.setModel(getAllCategoryTableModel());
        tableTest.setRowHeight(DisplayUtils.getScaledSize(18));
        tableTest.setIntercellSpacing(new java.awt.Dimension(1, 1));
        tableTest.setAutoCreateRowSorter(true);
        //Default sort by name (column 0)
        List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(1);
        sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
        tableTest.getRowSorter().setSortKeys(sortKeys);
        for (int i = 0; i < tableTest.getColumnCount() - 1; i++) {
            TableColumn column = tableTest.getColumnModel().getColumn(i);
            column.setPreferredWidth(width[i]);
        }
        JComboBox<String> jcb1 = new JComboBox<>();
        // Always show a blank one for where they are not all the same
        jcb1.addItem("");
        for (AlertThreshold level : AlertThreshold.values()) {
            jcb1.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase()));
        }
        tableTest.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1));
        JComboBox<String> jcb2 = new JComboBox<>();
        // Always show a blank one for where they are not all the same
        jcb2.addItem("");
        for (AttackStrength level : AttackStrength.values()) {
            jcb2.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase()));
        }
        tableTest.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(jcb2));
    }
    return tableTest;
}
Also used : RowSorter(javax.swing.RowSorter) JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) TableColumn(javax.swing.table.TableColumn) AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold) DefaultCellEditor(javax.swing.DefaultCellEditor) JTable(javax.swing.JTable) AttackStrength(org.parosproxy.paros.core.scanner.Plugin.AttackStrength)

Example 10 with AlertThreshold

use of org.parosproxy.paros.core.scanner.Plugin.AlertThreshold in project zaproxy by zaproxy.

the class PolicyCategoryPanel method getTableTest.

/**
	 * This method initializes tableTest
	 *
	 * @return javax.swing.JTable
	 */
private JTable getTableTest() {
    if (tableTest == null) {
        tableTest = new JTable();
        tableTest.setModel(getCategoryTableModel());
        tableTest.setRowHeight(DisplayUtils.getScaledSize(18));
        tableTest.setIntercellSpacing(new java.awt.Dimension(1, 1));
        tableTest.setAutoCreateRowSorter(true);
        //Default sort by name (column 0)
        List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>(1);
        sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
        tableTest.getRowSorter().setSortKeys(sortKeys);
        for (int i = 0; i < tableTest.getColumnCount() - 1; i++) {
            TableColumn column = tableTest.getColumnModel().getColumn(i);
            column.setPreferredWidth(width[i]);
        }
        JComboBox<String> jcb1 = new JComboBox<>();
        for (AlertThreshold level : AlertThreshold.values()) {
            jcb1.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase()));
        }
        tableTest.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(jcb1));
        JComboBox<String> jcb2 = new JComboBox<>();
        for (AttackStrength level : AttackStrength.values()) {
            jcb2.addItem(Constant.messages.getString("ascan.policy.level." + level.name().toLowerCase()));
        }
        tableTest.getColumnModel().getColumn(2).setCellEditor(new DefaultCellEditor(jcb2));
    }
    return tableTest;
}
Also used : RowSorter(javax.swing.RowSorter) JComboBox(javax.swing.JComboBox) ArrayList(java.util.ArrayList) TableColumn(javax.swing.table.TableColumn) AlertThreshold(org.parosproxy.paros.core.scanner.Plugin.AlertThreshold) DefaultCellEditor(javax.swing.DefaultCellEditor) JTable(javax.swing.JTable) AttackStrength(org.parosproxy.paros.core.scanner.Plugin.AttackStrength)

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