File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
src/org/zaproxy/zap/extension/alert Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 2020package org .zaproxy .zap .extension .alert ;
2121
2222import java .awt .EventQueue ;
23+ import java .util .ArrayList ;
2324import java .util .Comparator ;
25+ import java .util .Enumeration ;
26+ import java .util .List ;
2427
2528import javax .swing .tree .DefaultTreeModel ;
2629
@@ -196,6 +199,25 @@ public synchronized void deletePath(Alert alert) {
196199 this .nodeChanged (parent );
197200 }
198201 }
202+
203+ public List <Alert > getAlerts (String cleanNodeName ) {
204+ ArrayList <Alert > alerts = new ArrayList <>();
205+ @ SuppressWarnings ("unchecked" )
206+ Enumeration <AlertNode > groupAlertNodes = ((AlertNode ) getRoot ()).children ();
207+ while (groupAlertNodes .hasMoreElements ()) {
208+ AlertNode groupAlertNode = groupAlertNodes .nextElement ();
209+ @ SuppressWarnings ("unchecked" )
210+ Enumeration <AlertNode > alertNodes = groupAlertNode .children ();
211+ while (alertNodes .hasMoreElements ()) {
212+ AlertNode alertNode = alertNodes .nextElement ();
213+ if (alertNode .getUserObject ().getHistoryRef ().getURI ().toString ().startsWith (cleanNodeName )) {
214+ alerts .add (alertNode .getUserObject ());
215+ }
216+ }
217+ }
218+ alerts .trimToSize ();
219+ return alerts ;
220+ }
199221
200222 private static class GroupAlertChildNodeComparator implements Comparator <AlertNode > {
201223
Original file line number Diff line number Diff line change @@ -662,7 +662,7 @@ public List<Alert> getAllAlerts() {
662662 public String getXml (SiteNode site ) {
663663 StringBuilder xml = new StringBuilder ();
664664 xml .append ("<alerts>" );
665- List <Alert > alerts = site .getAlerts ();
665+ List <Alert > alerts = treeModel .getAlerts (site . getCleanNodeName () );
666666 SortedSet <String > handledAlerts = new TreeSet <String >();
667667
668668 for (int i =0 ; i < alerts .size (); i ++) {
You can’t perform that action at this time.
0 commit comments