Skip to content

Commit 379232b

Browse files
committed
Refactoring of scorecard generation code and add some scorecard generation enhancements. Upgrade a few libraries.
1 parent f93565d commit 379232b

35 files changed

+2157
-1058
lines changed

createAnonScorecards.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
mvn validate -Pscorecard -Dexec.args="expectedresults-1.2.csv results none anonymous"
1+
mvn validate -Pscorecard -Dexec.args="-cr anonymousScoringConfig.yaml"
22

createScorecards.bat

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
call mvn validate -Pscorecard -Dexec.args="expectedresults-1.2.csv results"
1+
call mvn validate -Pscorecard
2+

createScorecards.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
mvn validate -Pscorecard -Dexec.args="expectedresults-1.2.csv results"
1+
mvn validate -Pscorecard
22

pom.xml

+8-2
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@
884884
<dependency>
885885
<groupId>org.bouncycastle</groupId>
886886
<artifactId>bcprov-jdk15on</artifactId>
887-
<version>1.68</version>
887+
<version>1.69</version>
888888
</dependency>
889889

890890
<!-- Kevin's fix for jar version conflicts. For future Benchmark 1.3 -->
@@ -1010,6 +1010,12 @@
10101010
<version>${version.springframework}</version>
10111011
</dependency>
10121012

1013+
<dependency>
1014+
<groupId>org.yaml</groupId>
1015+
<artifactId>snakeyaml</artifactId>
1016+
<version>1.29</version>
1017+
</dependency>
1018+
10131019
<dependency>
10141020
<groupId>xml-apis</groupId>
10151021
<artifactId>xml-apis</artifactId>
@@ -1381,7 +1387,7 @@
13811387
<version.exec.maven>1.6.0</version.exec.maven>
13821388
<version.hibernate>3.6.10.Final</version.hibernate>
13831389
<version.jersey>1.19.4</version.jersey>
1384-
<version.slf4j>1.7.30</version.slf4j>
1390+
<version.slf4j>1.7.31</version.slf4j>
13851391
<version.spotbugs.maven>4.2.3</version.spotbugs.maven>
13861392
<version.spotbugs>4.2.3</version.spotbugs>
13871393
<version.spotless>2.10.1</version.spotless>

runBenchmark.bat

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
call mvn clean package cargo:run -Pdeploy
1+
call mvn initialize
2+
call mvn clean package cargo:run -Pdeploy
3+

runBenchmark.sh

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#!/bin/sh
22

3-
chmod 755 src/main/resources/insecureCmd.sh
4-
53
case "$1" in
64
-q|--quiet) quiet="-D-Dorg.owasp.esapi.logSpecial.discard=true"; shift ;;
75
*) quiet="" ;;
86
esac
7+
mvn ${quiet} initialize
98
mvn ${quiet} clean package cargo:run -Pdeploy

runCrawler.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/sh
22
mvn compile -Pcrawler
3+

runRemoteAccessibleBenchmark.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
#!/bin/sh
22

3-
chmod 755 src/main/resources/insecureCmd.sh
4-
mvn clean package cargo:run -Pdeploy -Drunenv=remote
3+
case "$1" in
4+
-q|--quiet) quiet="-D-Dorg.owasp.esapi.logSpecial.discard=true"; shift ;;
5+
*) quiet="" ;;
6+
esac
7+
mvn ${quiet} initialize
8+
mvn ${quiet} clean package cargo:run -Pdeploy -Drunenv=remote
9+

src/main/java/org/owasp/benchmark/helpers/Categories.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ private void load(File file) throws ParserConfigurationException, SAXException,
8989
isInjection =
9090
Boolean.parseBoolean(isInjectionNodeList.item(0).getTextContent());
9191
}
92-
Category category = new Category(id, name, cwe, isInjection);
92+
String shortname =
93+
eElement.getElementsByTagName("shortname").item(0).getTextContent();
94+
Category category = new Category(id, name, cwe, isInjection, shortname);
9395
idToCategoryMap.put(id, category);
9496
nameToCategoryMap.put(name, category);
9597
}

src/main/java/org/owasp/benchmark/helpers/Category.java

+15-27
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@
1919

2020
/** This class contains a single vulnerability category. */
2121
public class Category {
22-
private String id;
2322

24-
private String name;
25-
26-
private int cwe;
27-
28-
private boolean isInjection;
23+
private final String id; // e.g., pathtraver
24+
private final String name; // e.g., Path Traversal
25+
private final int CWE;
26+
private final boolean isInjection;
27+
private final String shortName; // PATH
2928

3029
/**
3130
* Create a vuln category.
@@ -35,43 +34,32 @@ public class Category {
3534
* @param cwe The associated CWE number.
3635
* @param isInjection Whether this vuln category is a type of injection attack.
3736
*/
38-
public Category(String id, String name, int cwe, boolean isInjection) {
37+
public Category(String id, String name, int cwe, boolean isInjection, String shortname) {
3938
this.id = id;
4039
this.name = name;
41-
this.cwe = cwe;
40+
this.CWE = cwe;
4241
this.isInjection = isInjection;
42+
this.shortName = shortname;
4343
}
4444

4545
public String getId() {
46-
return id;
47-
}
48-
49-
public void setId(String id) {
50-
this.id = id;
46+
return this.id;
5147
}
5248

5349
public String getName() {
54-
return name;
50+
return this.name;
5551
}
5652

57-
public void setName(String name) {
58-
this.name = name;
59-
}
60-
61-
public int getCwe() {
62-
return cwe;
63-
}
64-
65-
public void setCwe(int cwe) {
66-
this.cwe = cwe;
53+
public int getCWE() {
54+
return this.CWE;
6755
}
6856

6957
public boolean isInjection() {
70-
return isInjection;
58+
return this.isInjection;
7159
}
7260

73-
public void setInjection(boolean isInjection) {
74-
this.isInjection = isInjection;
61+
public String getShortName() {
62+
return this.shortName;
7563
}
7664

7765
@Override

src/main/java/org/owasp/benchmark/helpers/Utils.java

+3
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ public class Utils {
161161
e.printStackTrace();
162162
}
163163
}
164+
165+
// The target script is exploded out of the WAR file. When this occurs, the file
166+
// loses its execute permissions. So this hack adds the required execute permissions back.
164167
if (!System.getProperty("os.name").contains("Windows")) {
165168
File script = getFileFromClasspath("insecureCmd.sh", Utils.class.getClassLoader());
166169
Set<PosixFilePermission> perms = new HashSet<PosixFilePermission>();

0 commit comments

Comments
 (0)