Skip to content

Commit 90e70ff

Browse files
authored
Merge pull request OWASP-Benchmark#154 from darkspirit510/shiftleft-jsonl
Fix ShiftLeftScan reader to parse JSONL format and add version
2 parents f541c69 + 29c9ebb commit 90e70ff

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public static boolean isShiftLeftScanReport(final String content) {
3535
}
3636

3737
public TestSuiteResults parse(final String content) throws Exception {
38-
int startOfSecondJson = content.indexOf("\n{\n");
38+
String[] lines = content.split("\n");
3939

40-
JSONObject javaSourceAnalyzer = new JSONObject(content.substring(0, startOfSecondJson));
41-
JSONObject classFileAnalyzer = new JSONObject(content.substring(startOfSecondJson));
40+
JSONObject javaSourceAnalyzer = new JSONObject(lines[0]);
41+
JSONObject classFileAnalyzer = new JSONObject(lines[1]);
4242

4343
// false indicates this is an open source/free tool.
4444
TestSuiteResults tr =
@@ -47,9 +47,19 @@ public TestSuiteResults parse(final String content) throws Exception {
4747
parseAndAddResults(tr, javaSourceAnalyzer);
4848
parseAndAddResults(tr, classFileAnalyzer);
4949

50+
tr.setToolVersion(readVersion(javaSourceAnalyzer));
51+
5052
return tr;
5153
}
5254

55+
private String readVersion(JSONObject javaSourceAnalyzer) {
56+
return javaSourceAnalyzer
57+
.getJSONObject("tool")
58+
.getJSONObject("driver")
59+
.getString("version")
60+
.replace("-scan", "");
61+
}
62+
5363
private void parseAndAddResults(TestSuiteResults tr, JSONObject analyzerResults) {
5464
JSONArray arr = analyzerResults.getJSONArray("results");
5565

0 commit comments

Comments
 (0)