Skip to content

Commit 72bf80e

Browse files
authored
Merge branch 'main' into test/passive-package-coverage
2 parents 8274f43 + 6743dd8 commit 72bf80e

File tree

91 files changed

+4474
-20
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+4474
-20
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ updates:
1313
interval: "daily"
1414
open-pull-requests-limit: 20
1515
registries: "*"
16+
groups:
17+
internal:
18+
patterns:
19+
- "de.rub.nds*"

pom.xml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>de.rub.nds</groupId>
66
<artifactId>protocol-toolkit-bom</artifactId>
7-
<version>6.0.1</version>
7+
<version>6.2.1</version>
88
</parent>
99

1010
<artifactId>scanner-core</artifactId>
@@ -145,7 +145,7 @@
145145
<spacesPerTab>4</spacesPerTab>
146146
</indent>
147147
<googleJavaFormat>
148-
<version>1.25.2</version>
148+
<version>${plugin.spotless-maven-plugin.google-java-format.version}</version>
149149
<style>AOSP</style>
150150
</googleJavaFormat>
151151
<licenseHeader>
@@ -185,9 +185,7 @@
185185
<configuration>
186186
<source>${maven.compiler.source}</source>
187187
<target>${maven.compiler.target}</target>
188-
<compilerArgs>
189-
<compilerArg>-proc:full</compilerArg>
190-
</compilerArgs>
188+
<proc>full</proc>
191189
</configuration>
192190
</plugin>
193191
<!-- Execute unit tests -->
@@ -279,6 +277,9 @@
279277
<plugin>
280278
<groupId>com.github.spotbugs</groupId>
281279
<artifactId>spotbugs-maven-plugin</artifactId>
280+
<configuration>
281+
<excludeFilterFile>${project.basedir}/spotbugs-exclude.xml</excludeFilterFile>
282+
</configuration>
282283
</plugin>
283284
<plugin>
284285
<groupId>org.apache.maven.plugins</groupId>

spotbugs-exclude.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<FindBugsFilter>
3+
<!-- Exclude EI_EXPOSE_REP and EI_EXPOSE_REP2 globally -->
4+
<Match>
5+
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2" />
6+
</Match>
7+
</FindBugsFilter>

src/main/java/de/rub/nds/scanner/core/config/ExecutorConfig.java

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,108 +66,233 @@ public ExecutorConfig() {
6666
// Default constructor
6767
}
6868

69+
/**
70+
* Returns a copy of the list of probe types that are excluded from scanning.
71+
*
72+
* @return a new list containing the excluded probe types
73+
*/
6974
public List<ProbeType> getExcludedProbes() {
7075
return new LinkedList<>(excludedProbes);
7176
}
7277

78+
/**
79+
* Sets the list of probe types to be excluded from scanning.
80+
*
81+
* @param excludedProbes the list of probe types to exclude
82+
*/
7383
public void setExcludedProbes(List<ProbeType> excludedProbes) {
7484
this.excludedProbes = new LinkedList<>(excludedProbes);
7585
}
7686

87+
/**
88+
* Returns the scanner detail level for the scan operation.
89+
*
90+
* @return the current scanner detail level
91+
*/
7792
public ScannerDetail getScanDetail() {
7893
return scanDetail;
7994
}
8095

96+
/**
97+
* Sets the scanner detail level for the scan operation.
98+
*
99+
* @param scanDetail the scanner detail level to set
100+
*/
81101
public void setScanDetail(ScannerDetail scanDetail) {
82102
this.scanDetail = scanDetail;
83103
}
84104

105+
/**
106+
* Returns the scanner detail level for post-analysis operations.
107+
*
108+
* @return the current post-analysis detail level
109+
*/
85110
public ScannerDetail getPostAnalysisDetail() {
86111
return postAnalysisDetail;
87112
}
88113

114+
/**
115+
* Sets the scanner detail level for post-analysis operations.
116+
*
117+
* @param postAnalysisDetail the post-analysis detail level to set
118+
*/
89119
public void setPostAnalysisDetail(ScannerDetail postAnalysisDetail) {
90120
this.postAnalysisDetail = postAnalysisDetail;
91121
}
92122

123+
/**
124+
* Returns the scanner detail level for report generation.
125+
*
126+
* @return the current report detail level
127+
*/
93128
public ScannerDetail getReportDetail() {
94129
return reportDetail;
95130
}
96131

132+
/**
133+
* Sets the scanner detail level for report generation.
134+
*
135+
* @param reportDetail the report detail level to set
136+
*/
97137
public void setReportDetail(ScannerDetail reportDetail) {
98138
this.reportDetail = reportDetail;
99139
}
100140

141+
/**
142+
* Checks if colored text output is disabled.
143+
*
144+
* @return true if colored text is disabled, false otherwise
145+
*/
101146
public boolean isNoColor() {
102147
return noColor;
103148
}
104149

150+
/**
151+
* Sets whether colored text output should be disabled.
152+
*
153+
* @param noColor true to disable colored text, false to enable it
154+
*/
105155
public void setNoColor(boolean noColor) {
106156
this.noColor = noColor;
107157
}
108158

159+
/**
160+
* Returns a copy of the list of probe types to be executed.
161+
*
162+
* @return a new list containing the probe types, or null if not set
163+
*/
109164
public List<ProbeType> getProbes() {
110165
return probes == null ? null : new LinkedList<>(probes);
111166
}
112167

168+
/**
169+
* Sets the list of probe types to be executed.
170+
*
171+
* @param probes the list of probe types to execute, or null to clear
172+
*/
113173
public void setProbes(List<ProbeType> probes) {
114174
this.probes = probes == null ? null : new LinkedList<>(probes);
115175
}
116176

177+
/**
178+
* Sets the probe types to be executed using a varargs parameter.
179+
*
180+
* @param probes the probe types to execute
181+
*/
117182
public void setProbes(ProbeType... probes) {
118183
this.probes = Arrays.asList(probes);
119184
}
120185

186+
/**
187+
* Adds additional probe types to the existing list of probes to be executed.
188+
*
189+
* @param probes the list of probe types to add
190+
*/
121191
public void addProbes(List<ProbeType> probes) {
122192
if (this.probes == null) {
123193
this.probes = new LinkedList<>();
124194
}
125195
this.probes.addAll(probes);
126196
}
127197

198+
/**
199+
* Adds additional probe types to the existing list using a varargs parameter.
200+
*
201+
* @param probes the probe types to add
202+
*/
128203
public void addProbes(ProbeType... probes) {
129204
if (this.probes == null) {
130205
this.probes = new LinkedList<>();
131206
}
132207
this.probes.addAll(Arrays.asList(probes));
133208
}
134209

210+
/**
211+
* Returns the timeout value for each probe execution in milliseconds.
212+
*
213+
* @return the probe timeout in milliseconds
214+
*/
135215
public int getProbeTimeout() {
136216
return probeTimeout;
137217
}
138218

219+
/**
220+
* Sets the timeout value for each probe execution in milliseconds.
221+
*
222+
* @param probeTimeout the probe timeout in milliseconds
223+
*/
139224
public void setProbeTimeout(int probeTimeout) {
140225
this.probeTimeout = probeTimeout;
141226
}
142227

228+
/**
229+
* Checks if the report should be written to a file.
230+
*
231+
* @return true if an output file is specified, false otherwise
232+
*/
143233
public boolean isWriteReportToFile() {
144234
return outputFile != null;
145235
}
146236

237+
/**
238+
* Returns the path to the output file for the report.
239+
*
240+
* @return the output file path, or null if not specified
241+
*/
147242
public String getOutputFile() {
148243
return outputFile;
149244
}
150245

246+
/**
247+
* Sets the path to the output file for the report.
248+
*
249+
* @param outputFile the output file path
250+
*/
151251
public void setOutputFile(String outputFile) {
152252
this.outputFile = outputFile;
153253
}
154254

255+
/**
256+
* Returns the number of threads used for executing different probes in parallel.
257+
*
258+
* @return the number of parallel probe threads
259+
*/
155260
public int getParallelProbes() {
156261
return parallelProbes;
157262
}
158263

264+
/**
265+
* Sets the number of threads used for executing different probes in parallel.
266+
*
267+
* @param parallelProbes the number of parallel probe threads
268+
*/
159269
public void setParallelProbes(int parallelProbes) {
160270
this.parallelProbes = parallelProbes;
161271
}
162272

273+
/**
274+
* Returns the maximum number of threads used to execute probes.
275+
*
276+
* @return the maximum number of overall threads
277+
*/
163278
public int getOverallThreads() {
164279
return overallThreads;
165280
}
166281

282+
/**
283+
* Sets the maximum number of threads used to execute probes.
284+
*
285+
* @param overallThreads the maximum number of overall threads
286+
*/
167287
public void setOverallThreads(int overallThreads) {
168288
this.overallThreads = overallThreads;
169289
}
170290

291+
/**
292+
* Checks if the scanner is configured to run in multithreaded mode.
293+
*
294+
* @return true if either parallel probes or overall threads is greater than 1
295+
*/
171296
public boolean isMultithreaded() {
172297
return parallelProbes > 1 || overallThreads > 1;
173298
}

src/main/java/de/rub/nds/scanner/core/config/ScannerDetail.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,21 @@ public enum ScannerDetail {
2020
this.levelValue = levelValue;
2121
}
2222

23+
/**
24+
* Returns the numeric level value associated with this scanner detail level.
25+
*
26+
* @return the level value as an integer
27+
*/
2328
public int getLevelValue() {
2429
return levelValue;
2530
}
2631

32+
/**
33+
* Checks if this scanner detail level is greater than or equal to the specified detail level.
34+
*
35+
* @param detail the scanner detail level to compare against
36+
* @return true if this level is greater than or equal to the specified level, false otherwise
37+
*/
2738
public boolean isGreaterEqualTo(ScannerDetail detail) {
2839
return levelValue >= detail.getLevelValue();
2940
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,32 @@
1212
import java.util.concurrent.ThreadFactory;
1313
import java.util.concurrent.atomic.AtomicInteger;
1414

15+
/**
16+
* A thread factory that creates threads with custom names. This factory is useful for identifying
17+
* threads in thread dumps and monitoring tools.
18+
*/
1519
public class NamedThreadFactory implements ThreadFactory {
1620

1721
private AtomicInteger number = new AtomicInteger(1);
1822

1923
private final String prefix;
2024

25+
/**
26+
* Creates a new NamedThreadFactory with the specified name prefix.
27+
*
28+
* @param prefix the prefix to use for thread names. Threads will be named as "prefix-number"
29+
*/
2130
public NamedThreadFactory(String prefix) {
2231
this.prefix = prefix;
2332
}
2433

34+
/**
35+
* Creates a new thread with a custom name. The thread name will be in the format
36+
* "prefix-number" where number increments for each new thread.
37+
*
38+
* @param r the runnable to be executed by the new thread
39+
* @return a newly created thread with a custom name
40+
*/
2541
@Override
2642
public Thread newThread(Runnable r) {
2743
Thread newThread = Executors.defaultThreadFactory().newThread(r);

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414
import java.util.LinkedList;
1515
import java.util.List;
1616

17+
/**
18+
* Represents a collection of probes and after-probes to be executed during a scan. A scan job
19+
* encapsulates the work to be performed as part of a scanning operation.
20+
*
21+
* @param <ReportT> the type of scan report
22+
* @param <ProbeT> the type of scanner probe
23+
* @param <AfterProbeT> the type of after-probe
24+
* @param <StateT> the type of state object used by probes
25+
*/
1726
public class ScanJob<
1827
ReportT extends ScanReport,
1928
ProbeT extends ScannerProbe<ReportT, StateT>,
@@ -23,15 +32,31 @@ public class ScanJob<
2332
private final List<ProbeT> probeList;
2433
private final List<AfterProbeT> afterList;
2534

35+
/**
36+
* Creates a new scan job with the specified probes and after-probes.
37+
*
38+
* @param probeList the list of probes to execute
39+
* @param afterList the list of after-probes to execute after all probes complete
40+
*/
2641
public ScanJob(List<ProbeT> probeList, List<AfterProbeT> afterList) {
2742
this.probeList = new LinkedList<>(probeList);
2843
this.afterList = new LinkedList<>(afterList);
2944
}
3045

46+
/**
47+
* Returns a copy of the probe list.
48+
*
49+
* @return a new list containing all probes in this scan job
50+
*/
3151
public List<ProbeT> getProbeList() {
3252
return new LinkedList<>(probeList);
3353
}
3454

55+
/**
56+
* Returns a copy of the after-probe list.
57+
*
58+
* @return a new list containing all after-probes in this scan job
59+
*/
3560
public List<AfterProbeT> getAfterList() {
3661
return new LinkedList<>(afterList);
3762
}

0 commit comments

Comments
 (0)