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();
}
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;
}
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);
}
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);
}
Aggregations