use of com.checkmarx.sdk.dto.sast.Filter in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class FilterValidatorTest 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(NAME1).build();
Filter status = Filter.builder().type(Filter.Type.STATUS).value(STATUS_NEW).build();
// Using state name to init the filter, and a corresponding state ID while creating a finding.
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_ID, NAME1, CWE1, true);
verifySimpleFilterResult(filters, SEVERITY_MEDIUM, STATUS_NEW, STATE_URGENT_ID, NAME1, CWE1, false);
verifySimpleFilterResult(filters, SEVERITY_HIGH, STATUS_RECURRENT, STATE_URGENT_ID, NAME1, CWE1, false);
verifySimpleFilterResult(filters, SEVERITY_HIGH, STATUS_NEW, STATE_VERIFY_ID, NAME1, CWE1, false);
verifySimpleFilterResult(filters, SEVERITY_HIGH, STATUS_NEW, STATE_URGENT_ID, NAME2, CWE1, false);
verifySimpleFilterResult(filters, SEVERITY_HIGH, STATUS_NEW, STATE_URGENT_ID, NAME1, CWE2, false);
}
use of com.checkmarx.sdk.dto.sast.Filter in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxGoServiceIT method completeScanFlow.
@Test
// works only on Windows
@Ignore
public void completeScanFlow() throws CheckmarxException {
login();
if (StringUtils.isNotEmpty(properties.getClientSecret())) {
String teamId = service.getTeamId(properties.getTeam());
Integer projectId = service.getProjectId(teamId, GO_PROJECT_NAME);
CxScanParams params = new CxScanParams();
params.setProjectName(GO_PROJECT_NAME);
params.setTeamId(teamId);
params.setProjectId(projectId);
params.setGitUrl("https://github.com/Custodela/Riches.git");
params.setBranch("refs/heads/master");
params.setSourceType(CxScanParams.Type.GIT);
// run the scan and wait for it to finish
Integer x = service.createScan(params, "CxFlow Scan");
service.waitForScanCompletion(x);
FilterConfiguration filterConfiguration = FilterConfiguration.fromSimpleFilters(Collections.singletonList(new Filter(Filter.Type.SEVERITY, "High")));
// generate the results
ScanResults results = service.getReportContentByScanId(x, filterConfiguration);
assertNotNull(results);
}
}
use of com.checkmarx.sdk.dto.sast.Filter in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxServiceIT method getReportContent.
@Test
public void getReportContent() {
try {
List<Filter> filters = new ArrayList<>();
filters.add(new Filter(Filter.Type.SEVERITY, "High"));
FilterConfiguration filterConfiguration = FilterConfiguration.fromSimpleFilters(filters);
ScanResults results = service.getLatestScanResults(properties.getTeam(), "Riches", filterConfiguration);
assertNotNull(results);
} catch (CheckmarxException e) {
fail("Unexpected CheckmarxException");
}
}
use of com.checkmarx.sdk.dto.sast.Filter in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class CxServiceIT method completeScanFlow.
@Test
@Ignore("Stable environment required")
public void completeScanFlow() throws CheckmarxException {
final String PROJECT_NAME = "my-project-name";
final String GIT_REPO_URL = "https://github.com/my-organization/my-repo.git";
final String BRANCH_NAME = "refs/heads/develop";
String teamId = service.getTeamId(properties.getTeam());
Integer projectId = service.getProjectId(teamId, PROJECT_NAME);
CxScanParams params = new CxScanParams();
params.setProjectName(PROJECT_NAME);
params.setTeamId(teamId);
params.setProjectId(projectId);
params.setGitUrl(GIT_REPO_URL);
params.setBranch(BRANCH_NAME);
params.setSourceType(CxScanParams.Type.GIT);
// run the scan and wait for it to finish
Integer x = service.createScan(params, "CxSDK Scan");
service.waitForScanCompletion(x);
List<Filter> highSeverityOnly = Collections.singletonList(new Filter(Filter.Type.SEVERITY, "High"));
FilterConfiguration filterConfiguration = FilterConfiguration.fromSimpleFilters(highSeverityOnly);
// generate the results
ScanResults results = service.getReportContentByScanId(x, filterConfiguration);
assertNotNull(results);
}
use of com.checkmarx.sdk.dto.sast.Filter in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class FilterValidator method groupFilterValuesByFilterType.
private static Map<Filter.Type, List<String>> groupFilterValuesByFilterType(List<Filter> filters) {
// First prepare an empty list for each Filter.Type enum member.
Map<Filter.Type, List<String>> valuesByType = Arrays.stream(Filter.Type.values()).collect(Collectors.toMap(Function.identity(), filterType -> new ArrayList<>()));
// Populate the lists using the provided filters.
for (Filter filter : filters) {
List<String> targetList = valuesByType.get(filter.getType());
String safeValue = StringUtils.defaultString(filter.getValue());
targetList.add(safeValue.toUpperCase(Locale.ROOT));
}
return valuesByType;
}
Aggregations