Skip to content

Commit

Permalink
Refactor. logic for vaild test case result check
Browse files Browse the repository at this point in the history
  • Loading branch information
0xgoto committed Jul 10, 2024
1 parent 923d9c6 commit 5986a0c
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

import org.json.JSONArray;
import org.json.JSONObject;
import org.owasp.benchmarkutils.score.*;
import org.owasp.benchmarkutils.score.CweNumber;
import org.owasp.benchmarkutils.score.ResultFile;
import org.owasp.benchmarkutils.score.TestCaseResult;
import org.owasp.benchmarkutils.score.TestSuiteResults;

public class GitLabSastReader extends Reader {
@Override
Expand Down Expand Up @@ -53,10 +56,9 @@ public TestSuiteResults parse(ResultFile resultFile) throws Exception {
private TestCaseResult parseGitLabSastFindings(JSONObject vulnerability) {

try {
String className = vulnerability.getJSONObject("location").getString("file");
className = (className.substring(className.lastIndexOf('/') + 1)).split("\\.")[0];
int testNumber = testNumber(vulnerability.getJSONObject("location").getString("file"));

if (className.startsWith(BenchmarkScore.TESTCASENAME)) {
if (testNumber > -1) {
TestCaseResult tcr = new TestCaseResult();

JSONArray identifiers = vulnerability.getJSONArray("identifiers");
Expand All @@ -73,7 +75,7 @@ private TestCaseResult parseGitLabSastFindings(JSONObject vulnerability) {
tcr.setCategory(category);
tcr.setEvidence(evidence);
tcr.setConfidence(0);
tcr.setNumber(testNumber(className));
tcr.setNumber(testNumber);

return tcr;
}
Expand Down

0 comments on commit 5986a0c

Please sign in to comment.