Skip to content

Commit 13428cb

Browse files
authored
Added ProgressSpinner to show which probes are currently executing (#143)
1 parent aacd6bb commit 13428cb

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@
9898
<artifactId>protocol-attacker</artifactId>
9999
<version>2.1.0</version>
100100
</dependency>
101+
<dependency>
102+
<groupId>de.rub.nds</groupId>
103+
<artifactId>terminal-utils</artifactId>
104+
<version>1.0.0</version>
105+
</dependency>
101106
<dependency>
102107
<groupId>jakarta.xml.bind</groupId>
103108
<artifactId>jakarta.xml.bind-api</artifactId>

src/main/java/de/rub/nds/scanner/core/execution/Scanner.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import de.rub.nds.scanner.core.report.ScanReport;
1818
import de.rub.nds.scanner.core.report.rating.ScoreReport;
1919
import de.rub.nds.scanner.core.report.rating.SiteReportRater;
20+
import de.rub.nds.terminalutils.ProgressSpinner;
2021
import java.io.FileNotFoundException;
2122
import java.io.FileOutputStream;
2223
import java.io.IOException;
@@ -152,7 +153,7 @@ public ReportT scan() {
152153

153154
// Check Scan Prerequisites
154155
if (!checkScanPrerequisites(report)) {
155-
LOGGER.debug("Scan cannot be performed due to prerequisites not being fulfilled");
156+
LOGGER.info("Scan cannot be performed due to prerequisites not being fulfilled");
156157
return report;
157158
}
158159

@@ -165,15 +166,18 @@ public ReportT scan() {
165166
scanJob,
166167
executorConfig.getParallelProbes(),
167168
"ScannerProbeExecutor " + report.getRemoteName())) {
169+
ProgressSpinner.startSpinnerTask("Executing:");
168170
report.setScanStartTime(System.currentTimeMillis());
169171
scanJobExecutor.execute(report);
170172
} catch (InterruptedException e) {
171173
LOGGER.warn("Scan execution interrupted");
172174
report.setScanEndTime(System.currentTimeMillis());
173175
Thread.currentThread().interrupt();
176+
ProgressSpinner.stopSpinner();
174177
return report;
175178
}
176179
LOGGER.debug("Scan execution complete");
180+
ProgressSpinner.stopSpinner();
177181

178182
// Rating
179183
LOGGER.debug("Retrieving site report rater for score evaluation");

src/main/java/de/rub/nds/scanner/core/execution/ThreadedScanJobExecutor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ private void executeProbesTillNoneCanBeExecuted(ReportT report) throws Interrupt
147147
probeResult = result.get();
148148
LOGGER.info(
149149
"[{}/{}] {} probe executed",
150-
currentFinishedProbes,
151-
probeCount,
150+
String.format("%2d", currentFinishedProbes),
151+
String.format("%2d", probeCount),
152152
probeResult.getType().getName());
153153
} catch (ExecutionException e) {
154154
LOGGER.error("Some probe execution failed", e);

src/main/java/de/rub/nds/scanner/core/probe/ScannerProbe.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import de.rub.nds.scanner.core.probe.result.*;
1414
import de.rub.nds.scanner.core.report.PerformanceData;
1515
import de.rub.nds.scanner.core.report.ScanReport;
16+
import de.rub.nds.terminalutils.ProgressSpinner;
1617
import java.math.BigInteger;
1718
import java.util.HashMap;
1819
import java.util.List;
@@ -41,8 +42,10 @@ public ScannerProbe(ProbeType type) {
4142
@Override
4243
public ScannerProbe<ReportT, StateT> call() {
4344
LOGGER.debug("Executing: {}", getProbeName());
45+
ProgressSpinner.startSpinnerTask(getProbeName() + " probe");
4446
this.startTime = System.currentTimeMillis();
4547
executeTest();
48+
ProgressSpinner.stopSpinnerTask(getProbeName() + " probe");
4649
this.stopTime = System.currentTimeMillis();
4750

4851
LOGGER.debug("Finished {} - Took {}s", getProbeName(), (stopTime - startTime) / 1000);

0 commit comments

Comments
 (0)