Search in sources :

Example 6 with Alert

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

the class PopupMenuItemAlert method getAlertNodes.

private Set<Alert> getAlertNodes() {
    TreePath[] paths = this.extAlert.getAlertPanel().getTreeAlert().getSelectionPaths();
    if (paths == null || paths.length == 0) {
        return Collections.emptySet();
    }
    HashSet<Alert> alertNodes = new HashSet<Alert>();
    if (!isMultiSelect()) {
        DefaultMutableTreeNode alertNode = (DefaultMutableTreeNode) paths[0].getLastPathComponent();
        alertNodes.add((Alert) alertNode.getUserObject());
        return alertNodes;
    }
    for (int i = 0; i < paths.length; i++) {
        DefaultMutableTreeNode alertNode = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
        if (alertNode.getChildCount() == 0) {
            alertNodes.add((Alert) alertNode.getUserObject());
            continue;
        }
        for (int j = 0; j < alertNode.getChildCount(); j++) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) alertNode.getChildAt(j);
            alertNodes.add((Alert) node.getUserObject());
        }
    }
    return alertNodes;
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) Alert(org.parosproxy.paros.core.scanner.Alert) ExtensionAlert(org.zaproxy.zap.extension.alert.ExtensionAlert) HashSet(java.util.HashSet)

Example 7 with Alert

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

the class SiteNode method calculateHighestAlert.

/**
     * Calculates the highest alert.
     * <p>
     * After a call to this method the {@link #highestAlert} will have the highest alert (or {@code null} if none) and the flag
     * {@link #calculateHighestAlert} will have the value {@code false}.
     * 
     * @see #isHighestAlert(Alert)
     */
private void calculateHighestAlert() {
    synchronized (alerts) {
        highestAlert = null;
        for (Alert alert : alerts) {
            if (isHighestAlert(alert)) {
                highestAlert = alert;
            }
        }
        calculateHighestAlert = false;
    }
}
Also used : Alert(org.parosproxy.paros.core.scanner.Alert)

Example 8 with Alert

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

the class HistoryReference method updateAlert.

public synchronized void updateAlert(Alert alert) {
    //If there are no alerts yet
    if (alerts == null) {
        return;
    }
    for (Alert a : alerts) {
        if (a.getAlertId() == alert.getAlertId()) {
            // Have to use the alertId instead of 'equals' as any of the
            // other params might have changed
            this.alerts.remove(a);
            this.alerts.add(alert);
            if (this.siteNode != null) {
                siteNode.updateAlert(alert);
            }
            return;
        }
    }
}
Also used : RecordAlert(org.parosproxy.paros.db.RecordAlert) TableAlert(org.parosproxy.paros.db.TableAlert) Alert(org.parosproxy.paros.core.scanner.Alert)

Example 9 with Alert

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

the class ExtensionAlertUnitTest method shouldAppendAlertDescCorrectly.

@Test
public void shouldAppendAlertDescCorrectly() {
    extAlert.setAlertOverrideProperty("1.description", "+" + NEW_DESC);
    Alert alert1 = newAlert(1);
    extAlert.applyOverrides(alert1);
    // When/Then
    assertEquals(ORIGINAL_NAME, alert1.getName());
    assertEquals(ORIGINAL_DESC + NEW_DESC, alert1.getDescription());
    assertEquals(ORIGINAL_SOLN, alert1.getSolution());
    assertEquals(ORIGINAL_OTHER, alert1.getOtherInfo());
    assertEquals(ORIGINAL_REF, alert1.getReference());
    // Check other alerts are not affected
    Alert alert2 = newAlert(2);
    extAlert.applyOverrides(alert2);
    // When/Then
    assertEquals(ORIGINAL_NAME, alert2.getName());
    assertEquals(ORIGINAL_DESC, alert2.getDescription());
    assertEquals(ORIGINAL_SOLN, alert2.getSolution());
    assertEquals(ORIGINAL_OTHER, alert2.getOtherInfo());
    assertEquals(ORIGINAL_REF, alert2.getReference());
}
Also used : Alert(org.parosproxy.paros.core.scanner.Alert) Test(org.junit.Test)

Example 10 with Alert

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

the class ExtensionAlertUnitTest method shouldPrependAlertNameCorrectly.

@Test
public void shouldPrependAlertNameCorrectly() {
    extAlert.setAlertOverrideProperty("1.name", "-" + NEW_NAME);
    Alert alert1 = newAlert(1);
    extAlert.applyOverrides(alert1);
    // When/Then
    assertEquals(NEW_NAME + ORIGINAL_NAME, alert1.getName());
    assertEquals(ORIGINAL_DESC, alert1.getDescription());
    assertEquals(ORIGINAL_SOLN, alert1.getSolution());
    assertEquals(ORIGINAL_OTHER, alert1.getOtherInfo());
    assertEquals(ORIGINAL_REF, alert1.getReference());
    // Check other alerts are not affected
    Alert alert2 = newAlert(2);
    extAlert.applyOverrides(alert2);
    // When/Then
    assertEquals(ORIGINAL_NAME, alert2.getName());
    assertEquals(ORIGINAL_DESC, alert2.getDescription());
    assertEquals(ORIGINAL_SOLN, alert2.getSolution());
    assertEquals(ORIGINAL_OTHER, alert2.getOtherInfo());
    assertEquals(ORIGINAL_REF, alert2.getReference());
}
Also used : Alert(org.parosproxy.paros.core.scanner.Alert) Test(org.junit.Test)

Aggregations

Alert (org.parosproxy.paros.core.scanner.Alert)37 Test (org.junit.Test)15 ArrayList (java.util.ArrayList)7 RecordAlert (org.parosproxy.paros.db.RecordAlert)7 TableAlert (org.parosproxy.paros.db.TableAlert)7 HistoryReference (org.parosproxy.paros.model.HistoryReference)6 SiteNode (org.parosproxy.paros.model.SiteNode)6 ExtensionAlert (org.zaproxy.zap.extension.alert.ExtensionAlert)5 DatabaseException (org.parosproxy.paros.db.DatabaseException)4 TreePath (javax.swing.tree.TreePath)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 Session (org.parosproxy.paros.model.Session)2 SiteMap (org.parosproxy.paros.model.SiteMap)2 AlertNode (org.zaproxy.zap.extension.alert.AlertNode)2 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1 HeadlessException (java.awt.HeadlessException)1 Point (java.awt.Point)1 MouseEvent (java.awt.event.MouseEvent)1 Enumeration (java.util.Enumeration)1