| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,8 @@ | |||
| 21 | 21 | package org.owasp.benchmark.score.parsers; | |
| 22 | 22 | ||
| 23 | 23 | import java.io.File; | |
| 24 | + import java.text.ParseException; | ||
| 25 | + import java.text.SimpleDateFormat; | ||
| 24 | 26 | import org.json.JSONArray; | |
| 25 | 27 | import org.json.JSONObject; | |
| 26 | 28 | import org.owasp.benchmark.score.BenchmarkScore; | |
@@ -40,6 +42,8 @@ public static boolean isHorusecReport(final JSONObject json) { | |||
| 40 | 42 | } | |
| 41 | 43 | } | |
| 42 | 44 | ||
| 45 | + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); | ||
| 46 | + | ||
| 43 | 47 | public TestSuiteResults parse(JSONObject json) throws Exception { | |
| 44 | 48 | TestSuiteResults tr = | |
| 45 | 49 | new TestSuiteResults("Horusec", false, TestSuiteResults.ToolType.SAST); | |
@@ -53,6 +57,9 @@ public TestSuiteResults parse(JSONObject json) throws Exception { | |||
| 53 | 57 | } | |
| 54 | 58 | } | |
| 55 | 59 | ||
| 60 | + tr.setToolVersion(readVersion(json)); | ||
| 61 | + tr.setTime(calculateTime(json.getString("createdAt"), json.getString("finishedAt"))); | ||
| 62 | + | ||
| 56 | 63 | return tr; | |
| 57 | 64 | } | |
| 58 | 65 | ||
@@ -162,4 +169,30 @@ private int testNumber(String filename) { | |||
| 162 | 169 | private String filename(JSONObject vuln) { | |
| 163 | 170 | return new File(vuln.getString("file")).getName(); | |
| 164 | 171 | } | |
| 172 | + | ||
| 173 | + private String calculateTime(String createdAt, String finishedAt) { | ||
| 174 | + try { | ||
| 175 | + long passedMilliseconds = unixMilliseconds(finishedAt) - unixMilliseconds(createdAt); | ||
| 176 | + return TestSuiteResults.formatTime(passedMilliseconds); | ||
| 177 | + } catch (Exception e) { | ||
| 178 | + e.printStackTrace(); | ||
| 179 | + return "Unknown"; | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + private long unixMilliseconds(String createdAt) throws ParseException { | ||
| 184 | + return sdf.parse(trimAfterDot(createdAt)).getTime(); | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + private String trimAfterDot(String date) { | ||
| 188 | + return date.substring(0, date.indexOf('.')); | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + private String readVersion(JSONObject json) { | ||
| 192 | + if (json.has("version")) { | ||
| 193 | + return json.getString("version"); | ||
| 194 | + } else { | ||
| 195 | + return "0.0.0"; | ||
| 196 | + } | ||
| 197 | + } | ||
| 165 | 198 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -68,6 +68,8 @@ public static TestSuiteResults parse(JSONObject json) throws Exception { | |||
| 68 | 68 | } | |
| 69 | 69 | } | |
| 70 | 70 | ||
| 71 | + tr.setToolVersion(readVersion(json)); | ||
| 72 | + | ||
| 71 | 73 | return tr; | |
| 72 | 74 | } | |
| 73 | 75 | ||
@@ -96,4 +98,8 @@ private static String filename(JSONObject finding) { | |||
| 96 | 98 | private static int testNumber(String filename) { | |
| 97 | 99 | return Integer.parseInt(filename.substring(BenchmarkScore.TESTCASENAME.length() + 1)); | |
| 98 | 100 | } | |
| 101 | + | ||
| 102 | + private static String readVersion(JSONObject json) { | ||
| 103 | + return json.getJSONObject("infos").getString("version").substring("Wapiti ".length()); | ||
| 104 | + } | ||
| 99 | 105 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments