Skip to content

Commit c3f4581

Browse files
authored
Merge pull request zaproxy#9349 from psiinon/getstartnodes
Expose HostProcess startNodes
2 parents 0f3519a + a4e6bd5 commit c3f4581

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

zap/src/main/java/org/parosproxy/paros/core/scanner/HostProcess.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,14 @@
106106
// ZAP: 2022/09/21 Use format specifiers instead of concatenation when logging.
107107
// ZAP: 2023/01/10 Tidy up logger.
108108
// ZAP: 2023/05/17 Skip rules that reach the maximum number of alerts.
109+
// ZAP: 2026/05/28 From now on we will not be recording changes here as the files have changed so
110+
// much.
109111
package org.parosproxy.paros.core.scanner;
110112

111113
import java.io.IOException;
112114
import java.text.DecimalFormat;
113115
import java.util.ArrayList;
116+
import java.util.Collections;
114117
import java.util.HashMap;
115118
import java.util.HashSet;
116119
import java.util.Iterator;
@@ -330,6 +333,16 @@ public void addStartNode(StructuralNode startNode) {
330333
this.startNodes.add(startNode);
331334
}
332335

336+
/**
337+
* Gets the start nodes.
338+
*
339+
* @return the start nodes
340+
* @since 2.18.0
341+
*/
342+
public List<StructuralNode> getStartNodes() {
343+
return Collections.unmodifiableList(this.startNodes);
344+
}
345+
333346
/** Stop the current scanning process */
334347
public void stop() {
335348
isStop = true;

zap/src/test/java/org/parosproxy/paros/core/scanner/HostProcessUnitTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ void shouldScanStartNodeSet() {
224224
hostProcess.run();
225225
// Then
226226
assertThat(hostProcess.getTestTotalCount(), is(equalTo(1)));
227+
assertThat(hostProcess.getStartNodes().size(), is(1));
228+
assertThat(
229+
hostProcess.getStartNodes().get(0).getURI().toString(),
230+
is("http://localhost/file"));
227231
}
228232

229233
@Test
@@ -237,6 +241,13 @@ void shouldScanStartNodesAdded() {
237241
hostProcess.run();
238242
// Then
239243
assertThat(hostProcess.getTestTotalCount(), is(equalTo(2)));
244+
assertThat(hostProcess.getStartNodes().size(), is(2));
245+
assertThat(
246+
hostProcess.getStartNodes().get(0).getURI().toString(),
247+
is("http://localhost/file1"));
248+
assertThat(
249+
hostProcess.getStartNodes().get(1).getURI().toString(),
250+
is("http://localhost/file2"));
240251
}
241252

242253
@Test

0 commit comments

Comments
 (0)