| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1cfe52e commit e91a7b1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,7 @@ | |||
| 22 | 22 | import java.io.FileReader; | |
| 23 | 23 | import java.text.SimpleDateFormat; | |
| 24 | 24 | import java.util.Date; | |
| 25 | + import org.apache.commons.lang3.StringUtils; | ||
| 25 | 26 | import org.json.JSONObject; | |
| 26 | 27 | import org.owasp.benchmark.score.BenchmarkScore; | |
| 27 | 28 | ||
@@ -37,6 +38,10 @@ public TestResults parse(File f) throws Exception { | |||
| 37 | 38 | TestResults tr = new TestResults("Contrast", true, TestResults.ToolType.IAST); | |
| 38 | 39 | ||
| 39 | 40 | BufferedReader reader = new BufferedReader(new FileReader(f)); | |
| 41 | + String FIRSTLINEINDICATOR = | ||
| 42 | + BenchmarkScore.TESTCASENAME | ||
| 43 | + + StringUtils.repeat("0", BenchmarkScore.TESTIDLENGTH - 1) | ||
| 44 | + + "1"; | ||
| 40 | 45 | String firstLine = null; | |
| 41 | 46 | String lastLine = ""; | |
| 42 | 47 | String line = ""; | |
@@ -50,10 +55,8 @@ public TestResults parse(File f) throws Exception { | |||
| 50 | 55 | String version = | |
| 51 | 56 | line.substring(line.indexOf("Version:") + "Version:".length()); | |
| 52 | 57 | tr.setToolVersion(version.trim()); | |
| 53 | - // TODO: expand length of "00001" to match length of TESTCASE_NAME rather | ||
| 54 | - // than exactly 5 | ||
| 55 | 58 | } else if (line.contains("DEBUG - >>> [URL") | |
| 56 | - && line.contains(BenchmarkScore.TESTCASENAME + "00001")) { | ||
| 59 | + && line.contains(FIRSTLINEINDICATOR)) { | ||
| 57 | 60 | firstLine = line; | |
| 58 | 61 | } else if (line.contains("DEBUG - >>> [URL")) { | |
| 59 | 62 | lastLine = line; | |
@@ -92,9 +95,10 @@ private void parseContrastFinding(TestResults tr, String json) throws Exception | |||
| 92 | 95 | } | |
| 93 | 96 | } | |
| 94 | 97 | } catch (Exception e) { | |
| 95 | - // There are a few crypto-bad-mac findings not associated with a request, so ignore | ||
| 96 | - // errors associated with those. | ||
| 97 | - if (!json.contains("\"ruleId\":\"crypto-bad-mac\"")) { | ||
| 98 | + // There are a few crypto-bad-mac & crypto-weak-randomness findings not associated with | ||
| 99 | + // a request, so ignore errors associated with those. | ||
| 100 | + if (!json.contains("\"ruleId\":\"crypto-bad-mac\"") | ||
| 101 | + && !json.contains("\"ruleId\":\"crypto-weak-randomness\"")) { | ||
| 98 | 102 | System.err.println("Contrast Results Parse error for: " + json); | |
| 99 | 103 | e.printStackTrace(); | |
| 100 | 104 | } | |
@@ -169,3 +173,4 @@ private String calculateTime(String firstLine, String lastLine) { | |||
| 169 | 173 | return null; | |
| 170 | 174 | } | |
| 171 | 175 | } | |
| 176 | + | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments