Skip to content

Commit f2ab32a

Browse files
committed
Add dependency used by a script. Minor tweaks to a few scripts.
1 parent 57e3859 commit f2ab32a

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,13 @@
10951095
</executions>
10961096
</plugin>
10971097

1098+
<!-- used by some of the scripts. This forces the plugin to be downloaded, so it doesn't need to when the script runs. -->
1099+
<plugin>
1100+
<groupId>org.apache.maven.plugins</groupId>
1101+
<artifactId>maven-help-plugin</artifactId>
1102+
<version>3.2.0</version>
1103+
</plugin>
1104+
10981105
<plugin>
10991106
<groupId>org.apache.maven.plugins</groupId>
11001107
<artifactId>maven-install-plugin</artifactId>

scripts/getBenchmarkVersion.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/usr/bin/env sh
22

3-
# run and ignore output completely to prevent installation logs output on first run
4-
mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version > /dev/null
3+
mvn org.apache.maven.plugins:maven-help-plugin:evaluate -Dexpression=project.version | grep -v '[INFO]'
54

6-
mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '[INFO]'

scripts/requireCommand.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ requireCommand() {
77
exit 1
88
fi
99
}
10+

src/main/java/org/owasp/benchmark/score/parsers/SonarQubeJsonReader.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ private TestCaseResult parseSonarQubeQualityIssue(JSONObject finding) {
105105
if (filename.contains(BenchmarkScore.TESTCASENAME)) {
106106
String testNumber =
107107
filename.substring(
108-
BenchmarkScore.TESTCASENAME.length() + 1, filename.length() - 5);
108+
BenchmarkScore.TESTCASENAME.length() + 1,
109+
filename.lastIndexOf('.'));
109110
tcr.setNumber(Integer.parseInt(testNumber));
110111
String rule = finding.getString("rule");
111112
String squid = rule.substring(rule.indexOf(":") + 1);
@@ -153,7 +154,8 @@ private TestCaseResult parseSonarQubeHotSpotIssue(JSONObject finding) {
153154
if (filename.contains(BenchmarkScore.TESTCASENAME)) {
154155
String testNumber =
155156
filename.substring(
156-
BenchmarkScore.TESTCASENAME.length() + 1, filename.length() - 5);
157+
BenchmarkScore.TESTCASENAME.length() + 1,
158+
filename.lastIndexOf('.'));
157159
tcr.setNumber(Integer.parseInt(testNumber));
158160
String secCat = finding.getString("securityCategory");
159161
if (secCat == null || secCat.equals("none")) {
@@ -185,12 +187,10 @@ private TestCaseResult parseSonarQubeHotSpotIssue(JSONObject finding) {
185187
*/
186188
public static int securityCategoryCWELookup(String secCat, String message) {
187189
// Not sure where to look up all the possible security categories in SonarQube, but the
188-
// mappings
189-
// seem obvious enough.
190+
// mappings seem obvious enough.
190191

191-
// Given their horrible mapping scheme, we check each message to detect whether their might
192-
// be a new
193-
// 'message' mapped to an existing CWE (that might be wrong).
192+
// Given their horrible mapping scheme, we check each message to detect whether there might
193+
// be a new 'message' mapped to an existing CWE (that might be wrong).
194194
if (!("Make sure that using this pseudorandom number generator is safe here."
195195
.equals(message)
196196
|| "Ensure that string concatenation is required and safe for this SQL query."

tools/Contrast/runBenchmark_wContrast.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ echo "==========================================================================
3939
cd ../..
4040
mvn clean package cargo:run -Pdeploywcontrast
4141

42+
benchmark_version=$(scripts/getBenchmarkVersion.sh)
43+
4244
echo
4345
echo "Copying Contrast report to results directory"
4446
cd tools/Contrast
45-
cp ./working/contrast.log ../../results/Benchmark_1.2-Contrast.log
47+
result_file="../../results/Benchmark_$benchmark_version-Contrast.log"
48+
cp ./working/contrast.log "$result_file"
4649
echo
4750
echo " 5. You can generate a scorecard by running createScorecards.sh in the Benchmark root directory."
4851
echo

0 commit comments

Comments
 (0)