Search in sources :

Example 6 with FilterValidator

use of com.checkmarx.sdk.service.FilterValidator 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 7 with FilterValidator

use of com.checkmarx.sdk.service.FilterValidator in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.

the class CxGoFilterValidatorTest method verifyScriptResult.

private static void verifyScriptResult(Script script, String severity, String status, String state, String category, String cweId, boolean expectedResult) {
    FilterInput finding = createFilterInput(severity, category, status, state, cweId);
    EngineFilterConfiguration filterConfiguration = createFilterConfiguration(script);
    FilterValidator validator = new FilterValidator();
    boolean actualResult = validator.passesFilter(finding, filterConfiguration);
    assertEquals(expectedResult, actualResult, "Unexpected script filtering result.");
}
Also used : FilterValidator(com.checkmarx.sdk.service.FilterValidator)

Aggregations

FilterValidator (com.checkmarx.sdk.service.FilterValidator)7 CxProperties (com.checkmarx.sdk.config.CxProperties)3 QueryType (com.checkmarx.sdk.dto.cx.xml.QueryType)3 ResultType (com.checkmarx.sdk.dto.cx.xml.ResultType)3 EngineFilterConfiguration (com.checkmarx.sdk.dto.filtering.EngineFilterConfiguration)3 FilterInput (com.checkmarx.sdk.dto.filtering.FilterInput)3 FilterInputFactory (com.checkmarx.sdk.service.FilterInputFactory)3 CheckmarxRuntimeException (com.checkmarx.sdk.exception.CheckmarxRuntimeException)2 GroovyRuntimeException (groovy.lang.GroovyRuntimeException)2 Script (groovy.lang.Script)2 Filter (com.checkmarx.sdk.dto.sast.Filter)1