use of com.synopsys.integration.detect.workflow.result.AirGapDetectResult in project synopsys-detect by blackducksoftware.
the class DetectStatusLoggerTest method createResults.
private List<DetectResult> createResults() {
ArrayList<DetectResult> detectResults = new ArrayList<>();
DetectResult result = new BlackDuckBomDetectResult("https://example.com/api/projects/project_1");
detectResults.add(result);
result = new BlackDuckBomDetectResult("https://example.com/api/projects/project_2");
detectResults.add(result);
result = new AirGapDetectResult("./air_gap/directory");
detectResults.add(result);
result = new ReportDetectResult("report_1", "./report/1/report_file");
detectResults.add(result);
return detectResults;
}
use of com.synopsys.integration.detect.workflow.result.AirGapDetectResult in project synopsys-detect by blackducksoftware.
the class AirGapCreator method createAirGapZip.
public File createAirGapZip(AirGapType airGapType, File outputPath, String gradleInspectorVersion) throws DetectUserFriendlyException {
try {
logger.info("");
logger.info(ReportConstants.RUN_SEPARATOR);
logger.info(ReportConstants.RUN_SEPARATOR);
logger.info("Detect is in Air Gap Creation mode.");
logger.info("Detect will create an air gap of itself and then exit.");
logger.info("The created air gap zip will not be cleaned up.");
logger.info("Specify desired air gap zip type after the -z argument. Available options are FULL or NO_DOCKER. Default is FULL.");
logger.info(ReportConstants.RUN_SEPARATOR);
logger.info(ReportConstants.RUN_SEPARATOR);
logger.info("");
File detectJar = airGapPathFinder.findDetectJar();
if (detectJar == null) {
throw new DetectUserFriendlyException("To create an air gap zip, Detect must be run from a jar and be able to find that jar. Detect was unable to find it's own jar.", ExitCodeType.FAILURE_CONFIGURATION);
}
logger.info("The detect jar location: " + detectJar.getCanonicalPath());
logger.info("Creating zip at location: " + outputPath);
String basename = FilenameUtils.removeExtension(detectJar.getName());
String airGapName = basename + "-air-gap";
if (airGapType == AirGapType.NO_DOCKER) {
airGapName = airGapName + "-no-docker";
}
File target = new File(outputPath, airGapName + ".zip");
File installFolder = new File(outputPath, basename);
logger.info("Will build the zip in the following folder: " + installFolder.getCanonicalPath());
logger.info("Installing dependencies.");
installAllAirGapDependencies(airGapType, installFolder, gradleInspectorVersion);
logger.info("Copying detect jar.");
FileUtils.copyFile(detectJar, new File(installFolder, detectJar.getName()));
logger.info("Zipping into: " + target.getCanonicalPath());
ZipUtil.pack(installFolder, target);
logger.info("Cleaning up working directory: " + installFolder.getCanonicalPath());
FileUtils.deleteDirectory(installFolder);
logger.info(ReportConstants.RUN_SEPARATOR);
String result = target.getCanonicalPath();
logger.info("Successfully created air gap zip: " + result);
logger.info(ReportConstants.RUN_SEPARATOR);
eventSystem.publishEvent(Event.ResultProduced, new AirGapDetectResult(result));
return target;
} catch (IOException e) {
throw new DetectUserFriendlyException("Failed to create detect air gap zip.", e, ExitCodeType.FAILURE_UNKNOWN_ERROR);
}
}
Aggregations