Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
fd0a7ee
Merge pull request #89 from tjarrettveracode/master
davewichers Dec 26, 2019
c5cc852
Slight tweak to Dockerfile
davewichers Dec 27, 2019
8c33bae
Merge branch 'master' of https://github.com/OWASP/benchmark
davewichers Dec 27, 2019
f1f0256
Corrected issue with CWE parsing
cx-nuno-oliveira Jan 7, 2020
4d7c7ba
Merge pull request #91 from pnpo/master
davewichers Jan 10, 2020
94a449a
Merge pull request #1 from OWASP/master
jie-lin Feb 28, 2020
b5eb6fa
add getSonarVersion
jie-lin Feb 28, 2020
64df228
update
jie-lin Feb 28, 2020
7205288
Update WriteTime.java
jie-lin Feb 28, 2020
946124e
Update WriteTime.java
jie-lin Feb 28, 2020
ed98650
Merge pull request #93 from jie-lin/master
davewichers Feb 28, 2020
ec6e542
Update Acunetix parser to handle new Acunetix results format.
davewichers Mar 2, 2020
fb0eecd
Ensure HdivReader understands both date formats (w/o date)
manuel-alvarez-alvarez Mar 3, 2020
7a9ed29
Merge pull request #95 from hdiv/feature/hdiv-date-format
davewichers Mar 3, 2020
b1c1d72
Merge pull request #1 from OWASP/master
jasonkhooch-github Mar 5, 2020
a1e9d04
added CheckmarxIASTReader.java for CxIAST parser
jasonkhooch-github Mar 5, 2020
f6a1929
added CheckmarxIASTReader.java for CxIAST parser
jasonkhooch-github Mar 5, 2020
e93a0b0
update the BenchmarkScore.java to include the CheckmarxIASTReader.java
jasonkhooch-github Mar 5, 2020
59339f2
Corrected spelling.
rewtd Mar 6, 2020
68418cf
Added Seeker config and runners to Benchmark
rewtd Mar 6, 2020
b42ceb7
Added CHeckmarx IAST config and runners to Benchmark
rewtd Mar 6, 2020
00bda15
Brackets need escaping in batch files.
rewtd Mar 6, 2020
a16d0e2
COrrected variable names.
rewtd Mar 6, 2020
afe8919
Corrected variable names.
rewtd Mar 6, 2020
ba28952
Merge pull request #98 from cx-jason/master
davewichers Mar 6, 2020
9bc517a
Minor formatting cleanup on recently changed files. Change Benchmark …
davewichers Mar 6, 2020
a0cf837
Clean up before CxIAST run
rewtd Mar 7, 2020
9b3b49f
Clean up before Seeker run
rewtd Mar 7, 2020
2601cdf
Merge remote-tracking branch 'upstream/master'
rewtd Mar 9, 2020
02491c2
Update BenchmarkScore.java
davewichers Mar 9, 2020
4545691
Update BenchmarkScore.java
davewichers Mar 9, 2020
d47d3ad
Merge pull request #99 from rewtd/master
davewichers Mar 10, 2020
2cbdd02
Upgrade FindSecBugs plugin and minor improvement to Findbugs scorecard
davewichers Mar 13, 2020
a748a50
Merge pull request #2 from OWASP/master
jasonkhooch-github Mar 18, 2020
c41dade
Add files via upload
jasonkhooch-github Mar 18, 2020
c98791a
Add files via upload
jasonkhooch-github Mar 18, 2020
01ae48b
Delete runBenchmark_wCxIAST_v2.bat
jasonkhooch-github Mar 18, 2020
e9d4285
Merge pull request #101 from cx-jason/master
davewichers Mar 18, 2020
57c406e
Fix some OWASP site links to point to new OWASP site.
davewichers Mar 24, 2020
9b71f9d
Update Benchmark to address issue #92. Replaces the 3 crypto algorith…
davewichers Mar 25, 2020
020212e
Reorganize pom some. Eliminate use of several -all dependencies to el…
davewichers Mar 26, 2020
556f2b1
Upgrade some dependencies. Fix some convergence issues. Make sure
davewichers Mar 27, 2020
c0762f8
Add scan time extraction from scan file name for 3 parsers that were …
davewichers Mar 30, 2020
964546a
Add missing comment for last change.
davewichers Mar 30, 2020
c845792
Upgrade to Spring Framework 4.3.26 and update test cases that used de…
davewichers Apr 2, 2020
ea56f6d
Comment out 2 unused beans in resources/context.xml. Without these two
davewichers Apr 3, 2020
547552d
Upgrade jfreechart to 1.5.0 and fix API changes.
davewichers Apr 3, 2020
b1d0d93
Eliminate debug use of swing.JFrame class in various chart generation
davewichers Apr 3, 2020
f2c3e4c
Enhance LDAP test cases to always output something even if the LDAP
davewichers Apr 3, 2020
ce66006
Improve scoring for Rapid7 AppSpider scorecard generation.
davewichers Apr 6, 2020
ac1cc06
Merge two helper classes. Improve AcunetixReader to report 'new'
davewichers Apr 9, 2020
a6b9626
Fix WriteTime and pom.xml to properly calculate scan times and add
davewichers Apr 9, 2020
4ea4cfd
Added Unprotected_Cookieis to Irrelevant
LuisVentuzelos Apr 30, 2020
d5867a5
Update CheckmarxReader.java
LuisVentuzelos Apr 30, 2020
acd3888
Merge pull request #106 from LuisVentuzelos/master
davewichers May 11, 2020
b726722
Merge pull request #1 from OWASP/master
evilwan May 14, 2020
e92f740
Added line to install tzdata first because otherwise the build hangs …
evilwan May 14, 2020
3313a11
Merge pull request #107 from evilwan/master
davewichers May 14, 2020
c4752b3
Upgrade some dependencies, mostly plugins. Upgrade Tomcat.
davewichers Jun 30, 2020
7cef422
Add ;charset=UTF-8 to ContentType of response for those test cases
davewichers Jun 30, 2020
ef1712a
Add OpenAPI spec for OWASP Benchmark v1.2 to data folder. This is brand
davewichers Jul 23, 2020
e7ae605
Disable AJP connector as it now requires additional security configur…
davewichers Jul 23, 2020
965b339
Add '-q' or '--quiet' option to quiet ESAPI logSpecial.
kwwall Jul 24, 2020
ba194e9
Update from EsAPI 2.2.0.0 to 2.2.1.0.
kwwall Jul 24, 2020
66b88c9
Add new ESAPI 2.2.1.0 logger properties.
kwwall Jul 24, 2020
9daa808
Add missing mandatory properties file for ESAPI JUL.
kwwall Jul 24, 2020
fc66a0d
Minor cleanup and add comment.
kwwall Jul 24, 2020
12ac8e2
Delete extraneous .jsp files.
davewichers Aug 11, 2020
c3c832b
Merge pull request #109 from kwwall/master
davewichers Aug 11, 2020
bd11aba
Add HttpHeaders security filter to web.xml to automatically set
davewichers Aug 12, 2020
95c8ca2
Create new HttpResponseFilter that adds CSP Response header to all
davewichers Aug 12, 2020
bbad032
Fix CSP headers just asded so styles, fonts, scripts load properly.
davewichers Aug 12, 2020
b17ebd6
Update runBenchmark_wSeeker.sh
dragon040 Aug 13, 2020
96b2b16
Merge pull request #110 from amitsharma2009/patch-1
davewichers Aug 13, 2020
6f8fa20
Update runBenchmark_wSeeker.sh
dragon040 Aug 13, 2020
5c24661
Merge pull request #111 from amitsharma2009/patch-3
davewichers Aug 13, 2020
e7a22eb
Update runBenchmark_wSeeker.bat
dragon040 Aug 14, 2020
981c212
Merge pull request #112 from amitsharma2009/patch-4
davewichers Aug 14, 2020
b23fd11
Add tool type column to Summary of Results by Tool table on
davewichers Aug 21, 2020
1763595
Merge branch 'master' of https://github.com/OWASP/benchmark
davewichers Aug 21, 2020
d8a1b5e
Eliminate some unintentional character set mismatch issues detected
davewichers Aug 25, 2020
5c5e075
Add no-caching directives to all HTTPResponses. Add same-site=strict …
davewichers Aug 25, 2020
c103009
Add missing content type header for test cases generating custom cook…
davewichers Aug 26, 2020
a7406a2
VisualCodeGrepper integration
gitnachogo Aug 29, 2020
1028449
Merge pull request #114 from gitnachogo/VisualCodeGrepper
davewichers Aug 31, 2020
c21cb3e
Add one more vulnerability type to BurpPro reader translate to CWE me…
davewichers Sep 10, 2020
4d926a0
Add Semgrep scorecard generator based on contribution from: Nacho Gui…
davewichers Sep 14, 2020
0e231bd
Add scorecard generator for free DAST tool Wapiti.
davewichers Sep 15, 2020
a884c11
Tweak to Content Security policy settings in HTTPResponseHeaderFilter…
davewichers Oct 2, 2020
e084b03
Update the .html files for test cases that use AJAX to submit the
davewichers Oct 2, 2020
996a5de
Upgrade various dependencies, including 2 w/known CVEs. Add new
davewichers Nov 4, 2020
6bf88e9
Fix some errors in the HTML generated for the scorecards. Add some
davewichers Nov 19, 2020
2076f75
Update Contrast config flags and Contrast readme.txt
zirons1 Nov 24, 2020
ea01466
Upgrade a few dependencies in pom.xml. Add some missing header/license
davewichers Dec 1, 2020
b871998
Fix minor pom.xml error related to antrun plugin. Add/Fix headers in …
davewichers Dec 1, 2020
2844f71
Update headers to point to new OWASP wiki and add missing headers.
davewichers Dec 3, 2020
58baeca
Fix various minor HTML issues in generated UI like illegal character …
davewichers Dec 3, 2020
fa09d91
Remove duplicate path constant to test files directory. Update all te…
davewichers Dec 3, 2020
4a7cb9a
Remove some legacy code and update constants to use ALLCAPS and
davewichers Dec 9, 2020
526355b
Add parser for SonarQube JSON results pulled via SonarQube WebAPI.
davewichers Dec 9, 2020
6a5200e
Merge pull request #129 from zirons1/master
davewichers Dec 14, 2020
3c53b91
Tweak CSP policy again to allow XSS attacks to work via Referer.
davewichers Dec 14, 2020
34d05ce
Update recent Contrast tool configuration change to turn on rules
davewichers Dec 15, 2020
7daeaf2
Add support for Burp Suite Enterprise JSON results file.
davewichers Dec 15, 2020
8c8edfe
Check in changes to BurpReader I forgot to check in to support the
davewichers Dec 15, 2020
ab53cf8
Tweak pom.xml so Contrast config also works with Contrast CE and
davewichers Dec 17, 2020
6fc8073
Another tweak to Contrast scanning config.
davewichers Dec 17, 2020
e1717d1
More pom tweaks.
davewichers Dec 17, 2020
a10332f
Add support for SonarQube HotSpot API JSON results. HotSpots are
davewichers Dec 18, 2020
9a0c25a
Update various IAST scripts to clarify how to use them properly on
davewichers Dec 21, 2020
9b48bf2
Update format of a few test cases. Upgrade a few libs in pom.
davewichers Jan 3, 2021
a686f89
Merge branch 'master' of https://github.com/OWASP/benchmark
davewichers Jan 3, 2021
2909ae2
Add support for Crashtest Security DAST tool scorecard generation.
davewichers Jan 24, 2021
bfe2af6
Fix Crashtest input to scan time calculation to be seconds, not milli…
davewichers Jan 25, 2021
9943e8a
Add CodeQLReader as a parser for parsing CodeQL results
Niweera Jan 30, 2021
40c5a68
Merge pull request #133 from Niweera/master
davewichers Jan 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add support for SonarQube HotSpot API JSON results. HotSpots are
security specific areas of concern identified by SonarQube.
  • Loading branch information
davewichers committed Dec 18, 2020
commit a10332f8d3a86342115cc199ec0076a18ff7fcdc
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
-Dcontrast.application.path=/
-Dcontrast.assess.rules.disabled_rules="autocomplete-missing,cache-controls-missing,clickjacking-control-missing,csrf"
-Dcontrast.assess.threshold.entries=100000
-Dcontrast.defend.enabled=false
-Dcontrast.protect.enable=false
-Dcontrast.level=debug
-Dcontrast.log.daily=true
</cargo.jvmargs>
Expand Down
36 changes: 25 additions & 11 deletions src/main/java/org/owasp/benchmark/score/BenchmarkScore.java
Original file line number Diff line number Diff line change
Expand Up @@ -705,19 +705,33 @@ else if ( line2 != null && line2.contains("Vendor") && line2.contains("Checkmarx
tr = new SemgrepReader().parse( jsonobj );
} catch (JSONException e) {

try {
jsonobj.getJSONArray("issues");
tr = new SonarQubeJsonReader().parse( fileToParse );
} catch (JSONException e2) {

try {
jsonobj.getJSONArray("issue_events");
tr = new BurpJsonReader().parse( fileToParse );
} catch (JSONException e3) {
// Note: Each of the remaining try blocks is nested under the one above, but we shown them
// inline as they would get too deep otherwise
try {
// SonarQube has two different JSON formats, one for standard issues and
// another for 'hotspots' which are securit issues. Both are handled by the same
// parser for SonarQube.
jsonobj.getJSONArray("issues");
tr = new SonarQubeJsonReader().parse( fileToParse );
} catch (JSONException e2) {

try {
jsonobj.getJSONArray("hotspots");
tr = new SonarQubeJsonReader().parse( fileToParse );
} catch (JSONException e3) {

try {
jsonobj.getJSONArray("issue_events");
tr = new BurpJsonReader().parse( fileToParse );

// This is the final catch that says we couldn't find a matching parser
} catch (JSONException e4) {
System.out.println("Error: No matching parser found for JSON file: " + filename);
}
}
}

} // end catch SonarQubeJsonReader - hotspots
} // end catch SonarQubeJsonReader - issues
} // end catch SemgrepReader
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Date;

import org.json.JSONObject;

import org.owasp.benchmark.score.BenchmarkScore;

public class ContrastReader extends Reader {
Expand All @@ -49,11 +50,11 @@ public TestResults parse(File f) throws Exception {
if (line.startsWith("{\"hash\":")) {
parseContrastFinding(tr, line);
} else if (line.contains("Agent Version:")) {
String version = line.substring(line.indexOf("Version:") + 8);
String version = line.substring(line.indexOf("Version:") + "Version:".length());
tr.setToolVersion(version.trim());
// TODO: expand length of "00001" to match length of TESTCASE_NAME rather than exactly 5
} else if (line.contains("DEBUG - >>> [URL") &&
line.contains(BenchmarkScore.TESTCASENAME+"00001")) {
line.contains(BenchmarkScore.TESTCASENAME+"00001")) {
firstLine = line;
} else if (line.contains("DEBUG - >>> [URL")) {
lastLine = line;
Expand Down Expand Up @@ -148,5 +149,4 @@ private String calculateTime(String firstLine, String lastLine) {
}
return null;
}

}
141 changes: 127 additions & 14 deletions src/main/java/org/owasp/benchmark/score/parsers/SonarQubeJsonReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,41 @@
public class SonarQubeJsonReader extends Reader {

public TestResults parse( File f ) throws Exception {

TestResults tr = new TestResults( "SonarQube", false, TestResults.ToolType.SAST);

// If the filename includes an elapsed time in seconds (e.g., TOOLNAME-seconds.xml),
// set the compute time on the score card.
tr.setTime(f);

String content = new String(Files.readAllBytes(Paths.get(f.getPath())));

JSONObject obj = new JSONObject(content);
// int version = obj.getInt( "formatVersion" );
JSONArray arr;

boolean hotSpotIssue = true;

// Figure out if there are quality issues or security hotspots in the JSON file
// Each has a different JSON format.
try {
arr = obj.getJSONArray("issues");
hotSpotIssue = false;
} catch (JSONException e) {
System.out.println("ERROR: Couldn't find 'issues' element in SonarQube JSON results."
+ " Maybe not SonarQube results file?" );
return null;
try {
arr = obj.getJSONArray("hotspots");
} catch (JSONException e2) {
System.out.println("ERROR: Couldn't find 'issues' or 'hotspots' element in SonarQube JSON results."
+ " Maybe not SonarQube results file?" );
return null;
}
}

TestResults tr = new TestResults( "SonarJava", false, TestResults.ToolType.SAST);

// If the filename includes an elapsed time in seconds (e.g., TOOLNAME-seconds.xml),
// set the compute time on the score card.
tr.setTime(f);

int numIssues = arr.length();
for (int i = 0; i < numIssues; i++)
{
TestCaseResult tcr = parseSonarQubeFinding( arr.getJSONObject(i) );
for (int i = 0; i < numIssues; i++) {

TestCaseResult tcr = (hotSpotIssue? parseSonarQubeHotSpotIssue( arr.getJSONObject(i) ) :
parseSonarQubeQualityIssue( arr.getJSONObject(i) ));
if ( tcr != null ) {
tr.put( tcr );
}
Expand All @@ -61,7 +73,7 @@ public TestResults parse( File f ) throws Exception {
return tr;
}

/**
/** -- Example of Quality Issue JSON object
VULNERABILITY",
"tags":["cwe","owasp-a2","owasp-a6"],
"component":"org.owasp:benchmark:src\/main\/java\/org\/owasp\/benchmark\/testcode\/BenchmarkTest02710.java",
Expand All @@ -86,7 +98,10 @@ public TestResults parse( File f ) throws Exception {

**/

private TestCaseResult parseSonarQubeFinding(JSONObject finding ) {
// Quality Issues are normal SonarQube findings that are mostly not relevant to security
// However, there are a small number of security issues that do show up this way so we have
// to support both
private TestCaseResult parseSonarQubeQualityIssue(JSONObject finding ) {
try {
TestCaseResult tcr = new TestCaseResult();
String filename = null;
Expand Down Expand Up @@ -116,5 +131,103 @@ private TestCaseResult parseSonarQubeFinding(JSONObject finding ) {
return null;
}

// The parseSonarQubeQualityIssue() method above relies on the SQUID # mapping method in SonarQubeReader.cweLookup()

/** -- Example of HotSpot Issue JSON object
"hotspots": [
{
"key": "AXYEidyZsoEy1bftafT5",
"component": "owasp-benchmark-sonarce:src/main/java/org/owasp/benchmark/testcode/BenchmarkTest00008.java",
"project": "owasp-benchmark-sonarce",
"securityCategory": "sql-injection",
"vulnerabilityProbability": "HIGH",
"status": "TO_REVIEW",
"line": 58,
"message": "Ensure that string concatenation is required and safe for this SQL query.",
"author": "[email protected]",
"creationDate": "2015-08-26T05:13:42+0200",
"updateDate": "2020-11-26T12:53:38+0100"
},
**/

// Hotspot Issues are SonarQube security findings.
private TestCaseResult parseSonarQubeHotSpotIssue(JSONObject finding ) {
try {
TestCaseResult tcr = new TestCaseResult();
String filename = null;

filename = finding.getString("component");
filename = filename.replaceAll( "\\\\", "/"); // In case there are \ instead of / in the path
filename = filename.substring( filename.lastIndexOf( '/' ) );
if ( filename.contains( BenchmarkScore.TESTCASENAME ) ) {
String testNumber = filename.substring( BenchmarkScore.TESTCASENAME.length() + 1,
filename.length() - 5 );
tcr.setNumber( Integer.parseInt( testNumber ) );
String secCat = finding.getString("securityCategory");
if ( secCat == null || secCat.equals("none") ) {
return null;
}
int cwe = securityCategoryCWELookup(secCat, finding.getString("message"));
tcr.setCWE( cwe );
tcr.setCategory( secCat );
tcr.setEvidence( "vulnerabilityProbability: " + finding.getString("vulnerabilityProbability") );
}

return tcr;
} catch (Exception e ) {
e.printStackTrace();
}
return null;
}

/*
* Some of these findings are badly mapped. For example:
* "securityCategory": "xss",
* "message": "Make sure creating this cookie without the \"HttpOnly\" flag is safe.",
* While HttpOnly is a feature to help defend against XSS, it should really be mapped to
* CWE-1004: Sensitive Cookie Without 'HttpOnly' Flag. So we use the 'message' description
* in some findings to move such issues to the 'right' CWE.
* As such, we specifically look at the message in some cases to fix the mapping.
*/
public static int securityCategoryCWELookup(String secCat, String message) {
// Not sure where to look up all the possible security categories in SonarQube, but the mappings
// seem obvious enough.

// Given their horrible mapping scheme, we check each message to detect whether their might be a new
// 'message' mapped to an existing CWE (that might be wrong).
if ( !("Make sure that using this pseudorandom number generator is safe here.".equals(message) ||
"Ensure that string concatenation is required and safe for this SQL query.".equals(message) ||
"Make sure creating this cookie without the \"secure\" flag is safe here.".equals(message) ||
"Make sure that hashing data is safe here.".equals(message) ||
"Make sure creating this cookie without the \"HttpOnly\" flag is safe.".equals(message)) )
{
System.out.println("WARN: Found new SonarQube HotSpot rule not seen before. Category: "
+ secCat + " with message: '" + message + "'");
}

switch( secCat ) {

case "sql-injection" : return 89; // "Ensure that string concatenation is required and safe for this SQL query."
case "insecure-conf" : return 614; // "Make sure creating this cookie without the \"secure\" flag is safe here."
case "xss" : // "Make sure creating this cookie without the \"HttpOnly\" flag is safe."
{
if (message != null && message.contains("HttpOnly")) return 1004;
else return 79; // Actual XSS CWE
}
case "weak-cryptography" : // "Make sure that using this pseudorandom number generator is safe here."
{ // or "Make sure that hashing data is safe here."
if (message != null) {
if (message.contains("pseudorandom")) return 330;
if (message.contains("hashing")) return 328;
else return 0000;
}
else return 327; // Actual Weak Crypto CWE
}
default: System.out.println( "WARN: Failed to translate SonarQube security category: " + secCat );
}

return -1;
}

// This parser relies on the SQUID # mapping method in SonarQubeReader.cweLookup()
}