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;
}
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;
}
}
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;
}
}
}
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());
}
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());
}
Aggregations