From 924eeebc2ecef421aba1a2d8034eb893faa0894c Mon Sep 17 00:00:00 2001 From: mattiaformenti Date: Mon, 13 Oct 2025 11:40:04 +0400 Subject: [PATCH 1/8] WIP --- .../nds/scanner/core/execution/Scanner.java | 17 ++++++++++++++ .../execution/ThreadedScanJobExecutor.java | 23 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/main/java/de/rub/nds/scanner/core/execution/Scanner.java b/src/main/java/de/rub/nds/scanner/core/execution/Scanner.java index 6bce239..711013a 100644 --- a/src/main/java/de/rub/nds/scanner/core/execution/Scanner.java +++ b/src/main/java/de/rub/nds/scanner/core/execution/Scanner.java @@ -49,6 +49,9 @@ public abstract class Scanner< private final List afterList; private final boolean fillProbeListsAtScanStart; + // Optional callback for probe progress updates + private ProbeProgressCallback progressCallback = ProbeProgressCallback.noOp(); + /** * Creates a new scanner instance. * @@ -131,6 +134,18 @@ protected List> getGuidelines() { return List.of(); } + /** + * Sets the progress callback to be invoked when probes complete during scanning. This allows + * external components to receive real-time updates about scan progress and partial results. + * + * @param progressCallback the callback to invoke on probe completion, or null to disable + * callbacks + */ + public void setProgressCallback(ProbeProgressCallback progressCallback) { + this.progressCallback = + progressCallback != null ? progressCallback : ProbeProgressCallback.noOp(); + } + /** * Performs the scan. It will take care of all the necessary steps to perform a scan, including * filling the probe list by calling {@link #fillProbeLists}, checking the scan prerequisites by @@ -166,6 +181,8 @@ public ReportT scan() { scanJob, executorConfig.getParallelProbes(), "ScannerProbeExecutor " + report.getRemoteName())) { + // Set the progress callback on the executor + scanJobExecutor.setProgressCallback(progressCallback); ProgressSpinner.startSpinnerTask("Executing:"); report.setScanStartTime(System.currentTimeMillis()); scanJobExecutor.execute(report); diff --git a/src/main/java/de/rub/nds/scanner/core/execution/ThreadedScanJobExecutor.java b/src/main/java/de/rub/nds/scanner/core/execution/ThreadedScanJobExecutor.java index a27e2fa..e2b9973 100644 --- a/src/main/java/de/rub/nds/scanner/core/execution/ThreadedScanJobExecutor.java +++ b/src/main/java/de/rub/nds/scanner/core/execution/ThreadedScanJobExecutor.java @@ -60,6 +60,9 @@ public class ThreadedScanJobExecutor< private volatile int probeCount; private final AtomicInteger finishedProbes = new AtomicInteger(0); + // Callback for probe progress updates (optional) + private ProbeProgressCallback progressCallback = ProbeProgressCallback.noOp(); + /** * Creates a new ThreadedScanJobExecutor with a custom thread pool. * @@ -103,6 +106,18 @@ public ThreadedScanJobExecutor( this.futureResults = new LinkedList<>(); } + /** + * Sets the progress callback to be invoked when probes complete. This allows external + * components to receive real-time updates about scan progress. + * + * @param progressCallback the callback to invoke on probe completion, or null to disable + * callbacks + */ + public void setProgressCallback(ProbeProgressCallback progressCallback) { + this.progressCallback = + progressCallback != null ? progressCallback : ProbeProgressCallback.noOp(); + } + /** * Executes the scan job by running probes concurrently and populating the report with results. * This method manages probe dependencies and ensures probes are executed in the correct order. @@ -157,6 +172,14 @@ private void executeProbesTillNoneCanBeExecuted(ReportT report) throws Interrupt finishedFutures.add(result); probeResult.merge(report); report.markProbeAsExecuted(probeResult); + + // Notify progress callback + try { + progressCallback.onProbeCompleted( + probeResult, report, currentFinishedProbes, probeCount); + } catch (Exception e) { + LOGGER.warn("Progress callback threw exception, continuing scan", e); + } } } futureResults.removeAll(finishedFutures); From 3dacbf8b5ab91201ca9fbe8704623b6942a123ab Mon Sep 17 00:00:00 2001 From: mattiaformenti Date: Mon, 13 Oct 2025 11:48:07 +0400 Subject: [PATCH 2/8] WIP --- .../core/execution/ProbeProgressCallback.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main/java/de/rub/nds/scanner/core/execution/ProbeProgressCallback.java diff --git a/src/main/java/de/rub/nds/scanner/core/execution/ProbeProgressCallback.java b/src/main/java/de/rub/nds/scanner/core/execution/ProbeProgressCallback.java new file mode 100644 index 0000000..ef9f9be --- /dev/null +++ b/src/main/java/de/rub/nds/scanner/core/execution/ProbeProgressCallback.java @@ -0,0 +1,52 @@ +/* + * Scanner Core - A Modular Framework for Probe Definition, Execution, and Result Analysis. + * + * Copyright 2017-2023 Ruhr University Bochum, Paderborn University, Technology Innovation Institute, and Hackmanit GmbH + * + * Licensed under Apache License, Version 2.0 + * http://www.apache.org/licenses/LICENSE-2.0.txt + */ +package de.rub.nds.scanner.core.execution; + +import de.rub.nds.scanner.core.probe.ScannerProbe; +import de.rub.nds.scanner.core.report.ScanReport; + +/** + * Callback interface for receiving probe execution progress updates. This interface allows external + * components to be notified when individual probes complete during a scan, enabling real-time + * progress monitoring and streaming of partial results. + * + * @param the type of scan report + * @param the type of state object used by probes + */ +@FunctionalInterface +public interface ProbeProgressCallback { + + /** + * Called when a probe has completed execution and merged its results into the report. + * + * @param probe the probe that completed execution + * @param report the scan report with the probe's results merged in + * @param completedProbes the number of probes that have completed so far + * @param totalProbes the total number of probes scheduled for this scan + */ + void onProbeCompleted( + ScannerProbe probe, + ReportT report, + int completedProbes, + int totalProbes); + + /** + * Creates a no-op callback that does nothing when probes complete. Useful as a default when no + * progress tracking is needed. + * + * @param the type of scan report + * @param the type of state object + * @return a callback that performs no operations + */ + static ProbeProgressCallback noOp() { + return (probe, report, completedProbes, totalProbes) -> { + // No operation + }; + } +} From 828d7dd2947ad4f447265b742d29bceca4b0b567 Mon Sep 17 00:00:00 2001 From: mattiaformenti Date: Thu, 16 Oct 2025 11:14:32 +0400 Subject: [PATCH 3/8] update pom files and dependencies --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ed9e1db..917250d 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ scanner-core - 6.2.2 + 6.2.2-webapp Scanner Core A generic scanner framework which can execute a set of probes and combine the results into a report. From 49e66f1d4a30ba2265ad35490a5a0602f8c432e9 Mon Sep 17 00:00:00 2001 From: mattiaformenti Date: Thu, 16 Oct 2025 12:02:42 +0400 Subject: [PATCH 4/8] Remove -webapp suffix from version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed version from 6.2.2-webapp to 6.2.2 to align with standard Nexus artifacts while maintaining local development compatibility through dependencyManagement in dependent projects. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 917250d..ed9e1db 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ scanner-core - 6.2.2-webapp + 6.2.2 Scanner Core A generic scanner framework which can execute a set of probes and combine the results into a report. From 982940b690c2115494483538d88317136ea5839d Mon Sep 17 00:00:00 2001 From: mattiaformenti Date: Thu, 16 Oct 2025 13:59:49 +0400 Subject: [PATCH 5/8] changed version to 6.2.2-webapp --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ed9e1db..917250d 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ scanner-core - 6.2.2 + 6.2.2-webapp Scanner Core A generic scanner framework which can execute a set of probes and combine the results into a report. From 9e96300c4478c40e2685fba3cbdd3ef925119a53 Mon Sep 17 00:00:00 2001 From: mattiaformenti Date: Tue, 21 Oct 2025 10:26:14 +0400 Subject: [PATCH 6/8] Add scan target to probe execution log messages - Include report.getRemoteName() in probe execution logs - Format: [target] [X/Y] probe_name probe executed - Helps identify which target is being scanned during bulk scans --- .../nds/scanner/core/execution/ThreadedScanJobExecutor.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/rub/nds/scanner/core/execution/ThreadedScanJobExecutor.java b/src/main/java/de/rub/nds/scanner/core/execution/ThreadedScanJobExecutor.java index e2b9973..17abfc5 100644 --- a/src/main/java/de/rub/nds/scanner/core/execution/ThreadedScanJobExecutor.java +++ b/src/main/java/de/rub/nds/scanner/core/execution/ThreadedScanJobExecutor.java @@ -161,7 +161,8 @@ private void executeProbesTillNoneCanBeExecuted(ReportT report) throws Interrupt try { probeResult = result.get(); LOGGER.info( - "[{}/{}] {} probe executed", + "[{}] [{}/{}] {} probe executed", + report.getRemoteName(), String.format("%2d", currentFinishedProbes), String.format("%2d", probeCount), probeResult.getType().getName()); From bc64347b2ef43e75b5ba4c2acdeb3ffd21e3c354 Mon Sep 17 00:00:00 2001 From: mattiaformenti Date: Tue, 21 Oct 2025 11:00:29 +0400 Subject: [PATCH 7/8] update pom files --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 917250d..ed9e1db 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ scanner-core - 6.2.2-webapp + 6.2.2 Scanner Core A generic scanner framework which can execute a set of probes and combine the results into a report. From bd1798e9f5dc55033070623346b737984f93e9b5 Mon Sep 17 00:00:00 2001 From: mattiaformenti Date: Thu, 30 Oct 2025 14:28:03 +0400 Subject: [PATCH 8/8] Fixed version number in the pom file to sync with crawler-core's pom file --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 7825112..79b4913 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ scanner-core - 6.2.4-SNAPSHOT + 6.2.3 Scanner Core A generic scanner framework which can execute a set of probes and combine the results into a report.