Search in sources :

Example 1 with Finding

use of com.checkmarx.sdk.dto.ast.report.Finding in project cx-flow by checkmarx-ltd.

the class GitHubCommentsASTSteps method createFakeASTScanResults.

private ScanResults createFakeASTScanResults(int highCount, int mediumCount, int lowCount) {
    ScanResults result = new ScanResults();
    ASTResults astResults = new ASTResults();
    List<Finding> findings = new LinkedList<>();
    astResults.setScanId("" + SCAN_ID);
    boolean addNodes = false;
    if (highCount + mediumCount + lowCount > 0) {
        addNodes = true;
    }
    List<StatusCounter> findingCounts = new LinkedList<>();
    addFinding(highCount, findingCounts, findings, Severity.HIGH.name(), addNodes, "SQL_INJECTION");
    addFinding(mediumCount, findingCounts, findings, Severity.MEDIUM.name(), addNodes, "Hardcoded_password_in_Connection_String");
    addFinding(lowCount, findingCounts, findings, Severity.LOW.name(), addNodes, "Open_Redirect");
    astResults.setFindings(findings);
    result.setAstResults(astResults);
    AstSummaryResults summary = new AstSummaryResults();
    summary.setStatusCounters(findingCounts);
    summary.setHighVulnerabilityCount(highCount);
    summary.setMediumVulnerabilityCount(mediumCount);
    summary.setLowVulnerabilityCount(lowCount);
    astResults.setWebReportLink(AST_WEB_REPORT_LINK);
    astResults.setSummary(summary);
    Map<String, Object> details = new HashMap<>();
    details.put(Constants.SUMMARY_KEY, new HashMap<>());
    result.setAdditionalDetails(details);
    return result;
}
Also used : ScanResults(com.checkmarx.sdk.dto.ScanResults) StatusCounter(com.checkmarx.sdk.dto.ast.report.StatusCounter) AstSummaryResults(com.checkmarx.sdk.dto.ast.report.AstSummaryResults) Finding(com.checkmarx.sdk.dto.ast.report.Finding)

Example 2 with Finding

use of com.checkmarx.sdk.dto.ast.report.Finding in project cx-flow by checkmarx-ltd.

the class Github2AdoSteps method createAstFindings.

private void createAstFindings(ScanResults result) {
    result.setAstResults(new ASTResults());
    result.getAstResults().setScanId("111");
    result.getAstResults().setWebReportLink(WEB_REPORT_LINK);
    LinkedList<Finding> findings = new LinkedList();
    findings.add(createAstFinding(1));
    findings.add(createAstFinding(2));
    result.getAstResults().setFindings(findings);
    result.setScanSummary(new CxScanSummary());
    result.getAstResults().setSummary(new AstSummaryResults());
}
Also used : AstSummaryResults(com.checkmarx.sdk.dto.ast.report.AstSummaryResults) Finding(com.checkmarx.sdk.dto.ast.report.Finding) ASTResults(com.checkmarx.sdk.dto.ast.ASTResults) CxScanSummary(com.checkmarx.sdk.dto.cx.CxScanSummary)

Example 3 with Finding

use of com.checkmarx.sdk.dto.ast.report.Finding in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class AstTest method validateSummary.

private void validateSummary(ASTResults ASTResults) {
    AstSummaryResults summary = ASTResults.getSummary();
    Assert.assertNotNull("Summary is null.", summary);
    Assert.assertTrue("No medium-severity vulnerabilities.", summary.getMediumVulnerabilityCount() > 0);
    Assert.assertNotNull("Status counter list is null.", summary.getStatusCounters());
    Assert.assertFalse("No status counters.", summary.getStatusCounters().isEmpty());
    Assert.assertTrue("Expected total counter to be a positive value.", summary.getTotalCounter() > 0);
    int actualFindingCount = ASTResults.getFindings().size();
    Assert.assertEquals("Total finding count from summary doesn't correspond to the actual count.", actualFindingCount, summary.getTotalCounter());
    long actualFindingCountExceptInfo = ASTResults.getFindings().stream().filter(finding -> !StringUtils.equalsIgnoreCase(finding.getSeverity(), "info")).count();
    int countFromSummaryExceptInfo = summary.getHighVulnerabilityCount() + summary.getMediumVulnerabilityCount() + summary.getLowVulnerabilityCount();
    Assert.assertEquals("Finding count from summary (excluding 'info') doesn't correspond to the actual count.", actualFindingCountExceptInfo, countFromSummaryExceptInfo);
}
Also used : AstScanner(com.checkmarx.sdk.service.scanner.AstScanner) java.util(java.util) CxProperties(com.checkmarx.sdk.config.CxProperties) SourceLocationType(com.checkmarx.sdk.dto.SourceLocationType) URL(java.net.URL) RunWith(org.junit.runner.RunWith) Autowired(org.springframework.beans.factory.annotation.Autowired) ScanParams(com.checkmarx.sdk.dto.ast.ScanParams) StringUtils(org.apache.commons.lang3.StringUtils) Finding(com.checkmarx.sdk.dto.ast.report.Finding) RemoteRepositoryInfo(com.checkmarx.sdk.dto.RemoteRepositoryInfo) SpringRunner(org.springframework.test.context.junit4.SpringRunner) MalformedURLException(java.net.MalformedURLException) AstSummaryResults(com.checkmarx.sdk.dto.ast.report.AstSummaryResults) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Import(org.springframework.context.annotation.Import) GithubProperties(com.checkmarx.sdk.GithubProperties) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) CommonClientTest(com.checkmarx.sdk.service.CommonClientTest) Slf4j(lombok.extern.slf4j.Slf4j) SpringConfiguration(com.checkmarx.sdk.config.SpringConfiguration) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) AstScaResults(com.checkmarx.sdk.dto.AstScaResults) ASTResults(com.checkmarx.sdk.dto.ast.ASTResults) AstConfig(com.checkmarx.sdk.config.AstConfig) FilterConfiguration(com.checkmarx.sdk.dto.filtering.FilterConfiguration) Assert(org.junit.Assert) AstProperties(com.checkmarx.sdk.config.AstProperties) RestClientConfig(com.checkmarx.sdk.config.RestClientConfig) AstSummaryResults(com.checkmarx.sdk.dto.ast.report.AstSummaryResults)

Example 4 with Finding

use of com.checkmarx.sdk.dto.ast.report.Finding in project cx-flow by checkmarx-ltd.

the class GitHubCommentsASTSteps method addFinding.

private void addFinding(Integer countFindingsPerSeverity, List<StatusCounter> findingCounts, List<Finding> findings, String severity, boolean addNodes, String queryName) {
    for (int i = 0; i < countFindingsPerSeverity; i++) {
        Finding fnd = new Finding();
        fnd.setSeverity(severity);
        fnd.setQueryName(queryName + "-" + i);
        if (addNodes) {
            addNodes(fnd);
        }
        findings.add(fnd);
    }
    StatusCounter statusCounter = new StatusCounter();
    statusCounter.setStatus(severity);
    statusCounter.setCounter(countFindingsPerSeverity);
    findingCounts.add(statusCounter);
}
Also used : Finding(com.checkmarx.sdk.dto.ast.report.Finding) StatusCounter(com.checkmarx.sdk.dto.ast.report.StatusCounter)

Example 5 with Finding

use of com.checkmarx.sdk.dto.ast.report.Finding in project cx-flow by checkmarx-ltd.

the class Github2AdoSteps method createAstFinding.

private Finding createAstFinding(int index) {
    Finding f1 = new Finding();
    f1.setDescription(DESCRIPTION_AST + index);
    f1.setState(TO_VERIFY);
    f1.setQueryName("Query Name " + index);
    f1.setSeverity("HIGH");
    f1.setCweID(index);
    f1.setSimilarityID(index);
    f1.setUniqueID(index);
    f1.setNodes(Arrays.asList(new FindingNode()));
    f1.getNodes().get(0).setFileName(index + "file.java");
    return f1;
}
Also used : FindingNode(com.checkmarx.sdk.dto.ast.report.FindingNode) Finding(com.checkmarx.sdk.dto.ast.report.Finding)

Aggregations

Finding (com.checkmarx.sdk.dto.ast.report.Finding)6 AstSummaryResults (com.checkmarx.sdk.dto.ast.report.AstSummaryResults)3 ASTResults (com.checkmarx.sdk.dto.ast.ASTResults)2 StatusCounter (com.checkmarx.sdk.dto.ast.report.StatusCounter)2 GithubProperties (com.checkmarx.sdk.GithubProperties)1 AstConfig (com.checkmarx.sdk.config.AstConfig)1 AstProperties (com.checkmarx.sdk.config.AstProperties)1 CxProperties (com.checkmarx.sdk.config.CxProperties)1 RestClientConfig (com.checkmarx.sdk.config.RestClientConfig)1 SpringConfiguration (com.checkmarx.sdk.config.SpringConfiguration)1 AstScaResults (com.checkmarx.sdk.dto.AstScaResults)1 RemoteRepositoryInfo (com.checkmarx.sdk.dto.RemoteRepositoryInfo)1 ScanResults (com.checkmarx.sdk.dto.ScanResults)1 SourceLocationType (com.checkmarx.sdk.dto.SourceLocationType)1 ScanParams (com.checkmarx.sdk.dto.ast.ScanParams)1 FindingNode (com.checkmarx.sdk.dto.ast.report.FindingNode)1 CxScanSummary (com.checkmarx.sdk.dto.cx.CxScanSummary)1 FilterConfiguration (com.checkmarx.sdk.dto.filtering.FilterConfiguration)1 ScannerRuntimeException (com.checkmarx.sdk.exception.ScannerRuntimeException)1 CommonClientTest (com.checkmarx.sdk.service.CommonClientTest)1