Search in sources :

Example 16 with Filter

use of com.checkmarx.sdk.dto.sast.Filter in project cx-flow by checkmarx-ltd.

the class JiraAnalyticsCommandLineCommonSteps method getBasicScanRequest.

ScanRequest getBasicScanRequest() {
    List<Filter> simpleFilters = Collections.singletonList(this.filter);
    FilterConfiguration filterConfiguration = FilterConfiguration.fromSimpleFilters(simpleFilters);
    return ScanRequest.builder().application("TestApp").product(ScanRequest.Product.CX).project("TestProject").team("CxServer").namespace("Test").repoName("TestRepo").repoUrl("http://localhost/repo.git").repoUrlWithAuth("http://localhost/repo.git").repoType(ScanRequest.Repository.GITHUB).bugTracker(bugTracker).branch("master").refs(Constants.CX_BRANCH_PREFIX.concat("master")).email(null).incremental(false).scanPreset("Checkmarx Default").filter(filterConfiguration).build();
}
Also used : Filter(com.checkmarx.sdk.dto.sast.Filter) FilterConfiguration(com.checkmarx.sdk.dto.filtering.FilterConfiguration)

Example 17 with Filter

use of com.checkmarx.sdk.dto.sast.Filter in project cx-flow by checkmarx-ltd.

the class JiraTestUtils method getIssuesPerSeverity.

@Override
public Map<Filter.Severity, Integer> getIssuesPerSeverity(String projectKey) {
    Map<Filter.Severity, Integer> result = new HashMap<>();
    SearchResult searchResults = searchForAllIssues(projectKey);
    for (Issue issue : searchResults.getIssues()) {
        String severity = getIssueSeverity(issue.getDescription());
        if (severity == null) {
            continue;
        }
        Filter.Severity filterSeverity = null;
        // iterate over enums using for loop
        for (Filter.Severity s : Filter.Severity.values()) {
            log.debug("Comparing Filter Severity: '" + s.name() + "' to  '" + severity + "'\n");
            if (s.name().trim().equalsIgnoreCase(severity.trim())) {
                filterSeverity = s;
            }
        }
        // Filter.Severity filterSeverity = Filter.Severity.valueOf(severity.toUpperCase());
        if (filterSeverity != null && result.containsKey(filterSeverity)) {
            result.put(filterSeverity, result.get(filterSeverity) + 1);
        } else {
            result.put(filterSeverity, 1);
        }
    }
    return result;
}
Also used : Issue(com.atlassian.jira.rest.client.api.domain.Issue) Filter(com.checkmarx.sdk.dto.sast.Filter) SearchResult(com.atlassian.jira.rest.client.api.domain.SearchResult)

Example 18 with Filter

use of com.checkmarx.sdk.dto.sast.Filter in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class CxGoFilterValidatorTest method verifyScoreFilter.

private void verifyScoreFilter(Double valueToCheck, String valueFromFilter, boolean shouldPass) {
    Filter score = Filter.builder().type(Filter.Type.SCORE).value(valueFromFilter).build();
    EngineFilterConfiguration scaFilterConfig = EngineFilterConfiguration.builder().simpleFilters(Collections.singletonList(score)).build();
    FilterInput input = FilterInput.builder().id("424").score(valueToCheck).build();
    String message = String.format("Unexpected score filter result (valueToCheck: %f, valueFromFilter: %s)", valueToCheck, valueFromFilter);
    boolean actuallyPassed = new FilterValidator().passesFilter(input, scaFilterConfig);
    Assert.assertEquals(message, shouldPass, actuallyPassed);
}
Also used : Filter(com.checkmarx.sdk.dto.sast.Filter) FilterValidator(com.checkmarx.sdk.service.FilterValidator)

Example 19 with Filter

use of com.checkmarx.sdk.dto.sast.Filter in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class CxGoFilterValidatorTest method passesFilter_allSimpleFilters.

@Test
public void passesFilter_allSimpleFilters() {
    Filter severity = Filter.builder().type(Filter.Type.SEVERITY).value(SEVERITY_HIGH).build();
    Filter cwe = Filter.builder().type(Filter.Type.CWE).value(CWE1).build();
    Filter type = Filter.builder().type(Filter.Type.TYPE).value(CATEGORY1).build();
    Filter status = Filter.builder().type(Filter.Type.STATUS).value(STATUS_NEW).build();
    Filter state = Filter.builder().type(Filter.Type.STATE).value(STATE_URGENT_NAME).build();
    List<Filter> filters = Arrays.asList(severity, cwe, type, status, state);
    verifySimpleFilterResult(filters, SEVERITY_HIGH, STATUS_NEW, STATE_URGENT_NAME, CATEGORY1, CWE1, true);
    verifySimpleFilterResult(filters, SEVERITY_MEDIUM, STATUS_NEW, STATE_URGENT_NAME, CATEGORY1, CWE1, false);
    verifySimpleFilterResult(filters, SEVERITY_HIGH, STATUS_RECURRENT, STATE_URGENT_NAME, CATEGORY1, CWE1, false);
    verifySimpleFilterResult(filters, SEVERITY_HIGH, STATUS_NEW, STATE_VERIFY_NAME, CATEGORY1, CWE1, false);
    verifySimpleFilterResult(filters, SEVERITY_HIGH, STATUS_NEW, STATE_URGENT_NAME, CATEGORY2, CWE1, false);
    verifySimpleFilterResult(filters, SEVERITY_HIGH, STATUS_NEW, STATE_URGENT_NAME, CATEGORY1, CWE2, false);
}
Also used : Filter(com.checkmarx.sdk.dto.sast.Filter) Test(org.junit.Test)

Aggregations

Filter (com.checkmarx.sdk.dto.sast.Filter)19 FilterConfiguration (com.checkmarx.sdk.dto.filtering.FilterConfiguration)6 ScanResults (com.checkmarx.sdk.dto.ScanResults)5 Test (org.junit.Test)4 EngineFilterConfiguration (com.checkmarx.sdk.dto.filtering.EngineFilterConfiguration)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 CxScanParams (com.checkmarx.sdk.dto.cx.CxScanParams)2 CheckmarxException (com.checkmarx.sdk.exception.CheckmarxException)2 Given (io.cucumber.java.en.Given)2 Then (io.cucumber.java.en.Then)2 ArrayList (java.util.ArrayList)2 Function (java.util.function.Function)2 Collectors (java.util.stream.Collectors)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Ignore (org.junit.Ignore)2 Issue (com.atlassian.jira.rest.client.api.domain.Issue)1 SearchResult (com.atlassian.jira.rest.client.api.domain.SearchResult)1 CxFlowApplication (com.checkmarx.flow.CxFlowApplication)1 FlowProperties (com.checkmarx.flow.config.FlowProperties)1 RepoProperties (com.checkmarx.flow.config.RepoProperties)1