File tree 5 files changed +26
-23
lines changed
library/src/main/java/org/owasp/benchmarkutils/helpers
main/java/org/owasp/benchmarkutils/score
test/java/org/owasp/benchmarkutils/score/report/html 5 files changed +26
-23
lines changed Original file line number Diff line number Diff line change
1
+ --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
2
+
Original file line number Diff line number Diff line change @@ -46,6 +46,20 @@ public class Categories {
46
46
47
47
private static Categories _instance ; // The Singleton instance of this class
48
48
49
+ // Statically load the categories definitions from the config file to instantiate the Category
50
+ // singleton
51
+ static {
52
+ try {
53
+ InputStream categoriesFileStream =
54
+ Categories .class .getClassLoader ().getResourceAsStream (Categories .FILENAME );
55
+ new Categories (categoriesFileStream );
56
+ } catch (ParserConfigurationException | SAXException | IOException e1 ) {
57
+ System .out .println ("ERROR: couldn't load categories from categories config file." );
58
+ e1 .printStackTrace ();
59
+ System .exit (-1 );
60
+ }
61
+ }
62
+
49
63
/**
50
64
* Initialize all the categories from the InputStream connected to the target XML file.
51
65
*
Original file line number Diff line number Diff line change 36
36
import java .util .Set ;
37
37
import java .util .TreeMap ;
38
38
import java .util .TreeSet ;
39
- import javax .xml .parsers .ParserConfigurationException ;
40
39
import org .apache .commons .io .FileUtils ;
41
40
import org .apache .commons .io .IOUtils ;
42
41
import org .apache .maven .plugin .AbstractMojo ;
58
57
import org .owasp .benchmarkutils .score .report .html .VulnerabilityStatsTable ;
59
58
import org .owasp .benchmarkutils .score .service .ExpectedResultsProvider ;
60
59
import org .owasp .benchmarkutils .score .service .ResultsFileCreator ;
61
- import org .xml .sax .SAXException ;
62
60
63
61
@ Mojo (name = "create-scorecard" , requiresProject = false , defaultPhase = LifecyclePhase .COMPILE )
64
62
public class BenchmarkScore extends AbstractMojo {
@@ -161,17 +159,6 @@ public static void main(String[] args) {
161
159
System .exit (-1 );
162
160
}
163
161
164
- // Load in the categories definitions from the config file.
165
- try {
166
- InputStream categoriesFileStream =
167
- BenchmarkScore .class .getClassLoader ().getResourceAsStream (Categories .FILENAME );
168
- new Categories (categoriesFileStream );
169
- } catch (ParserConfigurationException | SAXException | IOException e1 ) {
170
- System .out .println ("ERROR: couldn't load categories from categories config file." );
171
- e1 .printStackTrace ();
172
- System .exit (-1 );
173
- }
174
-
175
162
// Step 0: Make sure the results file or directory exists before doing anything.
176
163
File resultsFileOrDir = new File (config .resultsFileOrDirName );
177
164
if (!resultsFileOrDir .exists ()) {
Original file line number Diff line number Diff line change @@ -55,16 +55,16 @@ public static TestSuiteResults parse(ResultFile resultFile) throws IOException {
55
55
if (record .get (TEST_NAME ).startsWith (tr .getTestSuiteName () + BenchmarkScore .TEST )) {
56
56
TestCaseResult tcr = new TestCaseResult ();
57
57
58
- tcr .setTestCaseName (record .get (TEST_NAME ));
59
- tcr .setCategory (record .get (CATEGORY ));
60
- tcr .setTruePositive (parseBoolean (record .get (REAL_VULNERABILITY )));
61
- tcr .setCWE (parseInt (record .get (CWE )));
62
- tcr .setNumber (testNumber (record .get (TEST_NAME ), testCaseName ));
58
+ tcr .setTestCaseName (record .get (TEST_NAME ). trim () );
59
+ tcr .setCategory (record .get (CATEGORY ). trim () );
60
+ tcr .setTruePositive (parseBoolean (record .get (REAL_VULNERABILITY ). trim () ));
61
+ tcr .setCWE (parseInt (record .get (CWE ). trim () ));
62
+ tcr .setNumber (testNumber (record .get (TEST_NAME ). trim () , testCaseName ));
63
63
64
64
if (isExtendedResultsFile (parser )) {
65
- tcr .setSource (record .get (SOURCE ));
66
- tcr .setDataFlow (record .get (DATA_FLOW ));
67
- tcr .setSink (record .get (SINK ));
65
+ tcr .setSource (record .get (SOURCE ). trim () );
66
+ tcr .setDataFlow (record .get (DATA_FLOW ). trim () );
67
+ tcr .setSink (record .get (SINK ). trim () );
68
68
}
69
69
70
70
tr .put (tcr );
Original file line number Diff line number Diff line change @@ -114,10 +114,10 @@ public String filenameFor(Tool tool) {
114
114
assertFalse (file .contains ("${vulnmenu}" ));
115
115
assertTrue (
116
116
file .contains (
117
- "<li><a href=\" Benchmark_v1.2_Scorecard_for_Path_Traversal.html\" >Path Traversal</a></li>\n " ));
117
+ "<li><a href=\" Benchmark_v1.2_Scorecard_for_Path_Traversal.html\" >Path Traversal</a></li>" ));
118
118
assertTrue (
119
119
file .contains (
120
- "<li><a href=\" Benchmark_v1.2_Scorecard_for_Command_Injection.html\" >Command Injection</a></li>\n " ));
120
+ "<li><a href=\" Benchmark_v1.2_Scorecard_for_Command_Injection.html\" >Command Injection</a></li>" ));
121
121
122
122
assertFalse (file .contains ("${testsuite}" ));
123
123
assertTrue (file .contains ("testsuite=OWASP Benchmark" ));
You can’t perform that action at this time.
0 commit comments