use of com.checkmarx.sdk.dto.sast.Filter in project cx-flow by checkmarx-ltd.
the class ScaFilterFactory method initScaFilter.
public void initScaFilter(ScanRequest request) {
log.info("Initializing SCA filters.");
List<Filter> severityFilters = getSeverityFilters(scaProperties.getFilterSeverity());
Filter scoreFilter = getScoreFilter(scaProperties.getFilterScore());
List<Filter> allFilters = combine(severityFilters, scoreFilter);
writeToLog(allFilters);
setScaFilters(allFilters, request);
}
use of com.checkmarx.sdk.dto.sast.Filter in project cx-flow by checkmarx-ltd.
the class OsaScannerService method cxOsaParseResults.
public void cxOsaParseResults(ScanRequest request, File file, File libs) throws ExitThrowable {
try {
List<Filter> simpleFilters = Optional.ofNullable(request).map(ScanRequest::getFilter).map(FilterConfiguration::getSastFilters).map(EngineFilterConfiguration::getSimpleFilters).orElse(null);
ScanResults results = cxService.getOsaReportContent(file, libs, simpleFilters);
resultsService.processResults(request, results, scanDetails);
if (flowProperties.isBreakBuild() && results != null && results.getXIssues() != null && !results.getXIssues().isEmpty()) {
log.error(ERROR_BREAK_MSG);
exit(ExitCode.BUILD_INTERRUPTED);
}
} catch (MachinaException | CheckmarxException e) {
log.error("Error occurred while processing results file(s)", e);
exit(3);
}
}
use of com.checkmarx.sdk.dto.sast.Filter in project cx-flow by checkmarx-ltd.
the class ResultsService method getOSAScan.
ScanResults getOSAScan(ScanRequest request, Integer projectId, String osaScanId, FilterConfiguration filter, ScanResults results) throws CheckmarxException {
if (Boolean.TRUE.equals(cxScannerService.getProperties().getEnableOsa()) && !ScanUtils.empty(osaScanId)) {
log.info("Waiting for OSA Scan results for scan id {}", osaScanId);
List<Filter> filters = Optional.ofNullable(filter.getScaFilters()).map(EngineFilterConfiguration::getSimpleFilters).orElse(null);
results = osaService.waitForOsaScan(osaScanId, projectId, results, filters);
new ScanResultsReport(osaScanId, request, results).log();
}
return results;
}
use of com.checkmarx.sdk.dto.sast.Filter in project cx-flow by checkmarx-ltd.
the class ScaThresholdsSteps method getFakeSCAResults.
private SCAResults getFakeSCAResults(String findingsName) {
SCAResults scaResults = new SCAResults();
scaResults.setScanId("1");
Summary summary = new Summary();
Map<Filter.Severity, Integer> summaryMap = new EnumMap<>(Filter.Severity.class);
List<Finding> findings = new LinkedList<>();
Map<String, String> specMap = findingsDefs.stream().filter(findingsDef -> findingsDef.get("name").equals(findingsName)).findAny().get();
EnumSet.allOf(Severity.class).forEach(severity -> {
String spec = specMap.get(severity.name().toLowerCase());
log.info("{}-spec: {}", severity, spec);
/* create findings */
Integer count = Arrays.stream(spec.split("-than-")).mapToInt(v -> "more".equals(v) ? 3 : "less".equals(v) ? -3 : Integer.parseInt(v)).reduce(0, Integer::sum);
log.info("going to generate {} issues with {} severity", count, severity);
summaryMap.put(Filter.Severity.valueOf(severity.name()), count);
populateFindings(findings, severity, count);
});
summary.setFindingCounts(summaryMap);
scaResults.setFindings(findings);
scaResults.setSummary(summary);
return scaResults;
}
use of com.checkmarx.sdk.dto.sast.Filter in project cx-flow by checkmarx-ltd.
the class CxConfigSteps method getFilter.
private List<String> getFilter(List<Filter> filters, Filter.Type type) {
List<String> filterByType = new ArrayList<>();
if (filters == null || filters.isEmpty()) {
return filterByType;
}
for (Filter filter : filters) {
if (filter.getType().equals(type)) {
String value = filter.getValue();
filterByType.add(value.toUpperCase(Locale.ROOT));
}
}
return filterByType;
}
Aggregations