| 
18 | 18 | package org.owasp.benchmarkutils.score.parsers.sarif;  | 
19 | 19 | 
 
  | 
20 | 20 | import org.owasp.benchmarkutils.score.CweNumber;  | 
 | 21 | +import org.owasp.benchmarkutils.score.ResultFile;  | 
 | 22 | +import org.owasp.benchmarkutils.score.TestSuiteResults;  | 
21 | 23 | 
 
  | 
22 | 24 | public class PTAIReader extends SarifReader {  | 
23 | 25 | 
 
  | 
24 | 26 |     static final int PTAI_CWE_EXTERNAL_FILEPATH_CONTROL = 73;  | 
25 | 27 |     static final int PTAI_CWE_BLIND_XPATH_INJECTION = 91;  | 
26 | 28 | 
 
  | 
 | 29 | +    static final String EXPECTED_TOOL_NAME = "Positive Technologies Application Inspector";  | 
 | 30 | +    static final String SHORTENED_TOOL_NAME = "PT Application Inspector";  | 
 | 31 | + | 
27 | 32 |     public PTAIReader() {  | 
28 |  | -        super("Positive Technologies Application Inspector", true, CweSourceType.FIELD);  | 
 | 33 | +        super(EXPECTED_TOOL_NAME, true, CweSourceType.FIELD);  | 
 | 34 | +    }  | 
 | 35 | + | 
 | 36 | +    @Override  | 
 | 37 | +    public String toolName(ResultFile resultFile) {  | 
 | 38 | +        return SHORTENED_TOOL_NAME;  | 
 | 39 | +    }  | 
 | 40 | + | 
 | 41 | +    /**  | 
 | 42 | +     * SARIF report tool version field is too long as it contains build number. Shorten it to X.Y.Z  | 
 | 43 | +     */  | 
 | 44 | +    @Override  | 
 | 45 | +    public void setVersion(ResultFile resultFile, TestSuiteResults testSuiteResults) {  | 
 | 46 | +        super.setVersion(resultFile, testSuiteResults);  | 
 | 47 | +        String version = testSuiteResults.getToolVersion();  | 
 | 48 | +        String[] versionItems = version.split("\\.");  | 
 | 49 | +        if (versionItems.length < 4) return;  | 
 | 50 | +        testSuiteResults.setToolVersion(  | 
 | 51 | +                String.format("%s.%s.%s", versionItems[0], versionItems[1], versionItems[2]));  | 
29 | 52 |     }  | 
30 | 53 | 
 
  | 
31 | 54 |     @Override  | 
 | 
0 commit comments