use of com.checkmarx.sdk.utils.sca.fingerprints.CxSCAScanFingerprints in project checkmarx-spring-boot-java-sdk by checkmarx-ltd.
the class ScaClientHelper method submitManifestsAndFingerprintsFromLocalDir.
private HttpResponse submitManifestsAndFingerprintsFromLocalDir(String projectId, ScanConfigBase configBase) throws IOException {
log.info("Using manifest only and fingerprint flow");
String sourceDir = config.getSourceDir();
PathFilter userFilter = new PathFilter("", "", log);
if (ArrayUtils.isNotEmpty(userFilter.getIncludes()) && !ArrayUtils.contains(userFilter.getIncludes(), "**")) {
userFilter.addToIncludes("**");
}
Set<String> scannedFileSet = new HashSet<>(Arrays.asList(CxSCAFileSystemUtils.scanAndGetIncludedFiles(sourceDir, userFilter)));
PathFilter manifestIncludeFilter = new PathFilter(null, getManifestsIncludePattern(), log);
if (manifestIncludeFilter.getIncludes().length == 0) {
throw new ScannerRuntimeException(String.format("Using manifest only mode requires include filter. Resolving config does not have include patterns defined: %s", getManifestsIncludePattern()));
}
List<String> filesToZip = Arrays.stream(CxSCAFileSystemUtils.scanAndGetIncludedFiles(sourceDir, manifestIncludeFilter)).filter(scannedFileSet::contains).collect(Collectors.toList());
List<String> filesToFingerprint = Arrays.stream(CxSCAFileSystemUtils.scanAndGetIncludedFiles(sourceDir, new PathFilter(null, getFingerprintsIncludePattern(), log))).filter(scannedFileSet::contains).collect(Collectors.toList());
CxSCAScanFingerprints fingerprints = fingerprintCollector.collectFingerprints(sourceDir, filesToFingerprint);
File zipFile = zipDirectoryAndFingerprints(sourceDir, filesToZip, fingerprints);
optionallyWriteFingerprintsToFile(fingerprints);
if (config.isClonedRepo()) {
CxRepoFileHelper cxRepoFileHelper = new CxRepoFileHelper();
cxRepoFileHelper.deleteCloneLocalDir(new File(sourceDir));
config.setZipFile(zipFile);
}
return initiateScanForUpload(projectId, FileUtils.readFileToByteArray(zipFile), configBase);
}
Aggregations