use of com.checkmarx.sdk.service.FilterInputFactory in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class FilterValidatorTest method verifyScriptResult.
private static void verifyScriptResult(Script script, String severity, String status, String state, String name, String cweId, boolean expectedResult) {
ResultType finding = createFinding(status, state);
QueryType findingGroup = createFindingGroup(severity, name, cweId);
EngineFilterConfiguration filterConfiguration = createFilterConfiguration(script);
FilterValidator validator = new FilterValidator();
FilterInputFactory filterInputFactory = new FilterInputFactory(new CxProperties());
FilterInput filterInput = filterInputFactory.createFilterInputForCxSast(findingGroup, finding);
boolean actualResult = validator.passesFilter(filterInput, filterConfiguration);
assertEquals(expectedResult, actualResult, "Unexpected script filtering result.");
}
use of com.checkmarx.sdk.service.FilterInputFactory in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class FilterValidatorTest method validateExpectedError.
private void validateExpectedError(String scriptWithUnknownObject) {
Script script = parse(scriptWithUnknownObject);
QueryType findingGroup = createFindingGroup(SEVERITY_LOW, NAME1, CWE1);
ResultType finding = createFinding(STATUS_NEW, STATE_URGENT_ID);
EngineFilterConfiguration filterConfiguration = createFilterConfiguration(script);
FilterValidator validator = new FilterValidator();
try {
FilterInputFactory filterInputFactory = new FilterInputFactory(new CxProperties());
FilterInput filterInput = filterInputFactory.createFilterInputForCxSast(findingGroup, finding);
validator.passesFilter(filterInput, filterConfiguration);
} catch (Exception e) {
assertTrue(e instanceof CheckmarxRuntimeException, String.format("Expected %s to be thrown.", CheckmarxRuntimeException.class));
assertTrue(e.getCause() instanceof GroovyRuntimeException, String.format("Expected exception cause to be %s", GroovyRuntimeException.class));
}
}
use of com.checkmarx.sdk.service.FilterInputFactory in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class FilterValidatorTest method verifySimpleFilterResult.
private static void verifySimpleFilterResult(List<Filter> filters, String severity, String status, String state, String name, String cweId, boolean expectedResult) {
ResultType finding = createFinding(status, state);
QueryType findingGroup = createFindingGroup(severity, name, cweId);
FilterValidator filterValidator = new FilterValidator();
EngineFilterConfiguration filterConfiguration = EngineFilterConfiguration.builder().simpleFilters(filters).build();
FilterInputFactory filterInputFactory = new FilterInputFactory(new CxProperties());
FilterInput filterInput = filterInputFactory.createFilterInputForCxSast(findingGroup, finding);
boolean passes = filterValidator.passesFilter(filterInput, filterConfiguration);
assertEquals(expectedResult, passes, "Unexpected simple filtering result.");
}
Aggregations