use of com.blackducksoftware.integration.hub.detect.lifecycle.shutdown.ExitCodeRequest in project hub-detect by blackducksoftware.
the class BlackDuckSignatureScanner method reportResults.
private void reportResults(List<SignatureScanPath> signatureScanPaths, List<ScanCommandOutput> scanCommandOutputList) {
boolean anyFailed = false;
boolean anyExitCodeIs64 = false;
for (final SignatureScanPath target : signatureScanPaths) {
Optional<ScanCommandOutput> targetOutput = scanCommandOutputList.stream().filter(output -> output.getScanTarget().equals(target.targetPath)).findFirst();
StatusType scanStatus;
if (!targetOutput.isPresent()) {
scanStatus = StatusType.FAILURE;
logger.info(String.format("Scanning target %s was never scanned by the BlackDuck CLI.", target.targetPath));
} else {
ScanCommandOutput output = targetOutput.get();
if (output.getResult() == Result.FAILURE) {
scanStatus = StatusType.FAILURE;
if (output.getException().isPresent() && output.getErrorMessage().isPresent()) {
logger.error(String.format("Scanning target %s failed: %s", target.targetPath, output.getErrorMessage().get()));
logger.debug(output.getErrorMessage().get(), output.getException().get());
} else if (output.getErrorMessage().isPresent()) {
logger.error(String.format("Scanning target %s failed: %s", target.targetPath, output.getErrorMessage().get()));
} else {
logger.error(String.format("Scanning target %s failed for an unknown reason.", target.targetPath));
}
if (output.getScanExitCode().isPresent()) {
anyExitCodeIs64 = anyExitCodeIs64 || output.getScanExitCode().get() == 64;
}
} else {
scanStatus = StatusType.SUCCESS;
logger.info(String.format("%s was successfully scanned by the BlackDuck CLI.", target.targetPath));
}
}
anyFailed = anyFailed || scanStatus == StatusType.FAILURE;
eventSystem.publishEvent(Event.StatusSummary, new SignatureScanStatus(target.targetPath, scanStatus));
}
if (anyFailed) {
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_SCAN));
}
if (anyExitCodeIs64) {
logger.error("");
logger.error("Signature scanner returned 64. The most likely cause is you are using an unsupported version of Black Duck (<5.0.0).");
logger.error("You should update your Black Duck or downgrade your version of detect.");
logger.error("If you are using the detect scripts, you can use DETECT_LATEST_RELEASE_VERSION.");
logger.error("");
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_BLACKDUCK_VERSION_NOT_SUPPORTED));
}
}
use of com.blackducksoftware.integration.hub.detect.lifecycle.shutdown.ExitCodeRequest in project hub-detect by blackducksoftware.
the class Application method run.
@Override
public void run(final ApplicationArguments applicationArguments) throws Exception {
final long startTime = System.currentTimeMillis();
// Events, Status and Exit Codes are required even if boot fails.
EventSystem eventSystem = new EventSystem();
DetectStatusManager statusManager = new DetectStatusManager(eventSystem);
ExitCodeUtility exitCodeUtility = new ExitCodeUtility();
ExitCodeManager exitCodeManager = new ExitCodeManager(eventSystem, exitCodeUtility);
ReportManager reportManager = ReportManager.createDefault(eventSystem);
// Before boot even begins, we create a new Spring context for Detect to work within.
logger.info("Preparing detect.");
DetectRun detectRun = DetectRun.createDefault();
DetectContext detectContext = new DetectContext(detectRun);
BootResult bootResult = null;
Optional<RunResult> runResult = Optional.empty();
try {
logger.info("Detect boot begin.");
BootManager bootManager = new BootManager(new BootFactory());
bootResult = bootManager.boot(detectRun, applicationArguments.getSourceArgs(), environment, eventSystem, detectContext);
logger.info("Detect boot completed.");
} catch (final Exception e) {
logger.error("Detect boot failed.");
exitCodeManager.requestExitCode(e);
}
if (bootResult != null && bootResult.bootType == BootResult.BootType.CONTINUE) {
logger.info("Detect will attempt to run.");
RunManager runManager = new RunManager(detectContext);
try {
logger.info("Detect run begin: " + detectRun.getRunId());
runResult = Optional.ofNullable(runManager.run());
logger.info("Detect run completed.");
} catch (final Exception e) {
if (e.getMessage() != null) {
logger.error("Detect run failed: " + e.getMessage());
} else {
logger.error("Detect run failed: " + e.getClass().getSimpleName());
}
logger.debug("An exception was thrown during the detect run.", e);
exitCodeManager.requestExitCode(e);
}
try {
logger.info("Detect will attempt to shutdown.");
DiagnosticManager diagnosticManager = detectContext.getBean(DiagnosticManager.class);
DirectoryManager directoryManager = detectContext.getBean(DirectoryManager.class);
DetectConfiguration detectConfiguration = detectContext.getBean(DetectConfiguration.class);
ConnectivityManager connectivityManager = detectContext.getBean(ConnectivityManager.class);
ShutdownManager shutdownManager = new ShutdownManager(connectivityManager, statusManager, exitCodeManager, directoryManager, detectConfiguration, reportManager, diagnosticManager);
logger.info("Detect shutdown begin.");
shutdownManager.shutdown(runResult);
logger.info("Detect shutdown completed.");
} catch (final Exception e) {
logger.error("Detect shutdown failed.");
exitCodeManager.requestExitCode(e);
}
} else {
logger.debug("Detect will NOT attempt to run.");
}
logger.info("All detect actions completed.");
// Determine how detect should actually exit
boolean printOutput = true;
boolean shouldForceSuccess = false;
if (bootResult != null && bootResult.detectConfiguration != null) {
printOutput = !bootResult.detectConfiguration.getBooleanProperty(DetectProperty.DETECT_SUPPRESS_RESULTS_OUTPUT, PropertyAuthority.None);
shouldForceSuccess = bootResult.detectConfiguration.getBooleanProperty(DetectProperty.DETECT_FORCE_SUCCESS, PropertyAuthority.None);
}
// Generally, when requesting a failure status, an exit code is also requested, but if it is not, we default to an unknown error.
if (statusManager.hasAnyFailure()) {
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_UNKNOWN_ERROR, "A failure status was requested by one or more of Detect's tools."));
}
// Find the final (as requested) exit code
ExitCodeType finalExitCode = exitCodeManager.getWinningExitCode();
// Print detect's status
if (printOutput) {
reportManager.printDetectorIssues();
statusManager.logDetectResults(new Slf4jIntLogger(logger), finalExitCode);
}
// Print duration of run
final long endTime = System.currentTimeMillis();
logger.info(String.format("Detect duration: %s", DurationFormatUtils.formatPeriod(startTime, endTime, "HH'h' mm'm' ss's' SSS'ms'")));
// Exit with formal exit code
if (finalExitCode != ExitCodeType.SUCCESS && shouldForceSuccess) {
logger.warn(String.format("Forcing success: Exiting with exit code 0. Ignored exit code was %s.", finalExitCode.getExitCode()));
System.exit(0);
} else if (finalExitCode != ExitCodeType.SUCCESS) {
logger.error(String.format("Exiting with code %s - %s", finalExitCode.getExitCode(), finalExitCode.toString()));
}
System.exit(finalExitCode.getExitCode());
}
use of com.blackducksoftware.integration.hub.detect.lifecycle.shutdown.ExitCodeRequest in project hub-detect by blackducksoftware.
the class PolicyChecker method checkPolicy.
public void checkPolicy(final List<PolicySeverityType> policySeverities, final ProjectService projectService, final ProjectVersionView projectVersionView) throws IntegrationException {
final Optional<PolicyStatusDescription> optionalPolicyStatusDescription = getPolicyStatus(projectService, projectVersionView);
if (optionalPolicyStatusDescription.isPresent()) {
PolicyStatusDescription policyStatusDescription = optionalPolicyStatusDescription.get();
logger.info(policyStatusDescription.getPolicyStatusMessage());
if (arePolicySeveritiesViolated(policyStatusDescription, policySeverities)) {
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_POLICY_VIOLATION, policyStatusDescription.getPolicyStatusMessage()));
}
} else {
String availableLinks = StringUtils.join(projectVersionView.getAvailableLinks(), ", ");
logger.warn("It is not possible to check the policy status for this project/version. The policy-status link must be present. The available links are: " + availableLinks);
}
}
use of com.blackducksoftware.integration.hub.detect.lifecycle.shutdown.ExitCodeRequest in project hub-detect by blackducksoftware.
the class BootManager method boot.
public BootResult boot(DetectRun detectRun, final String[] sourceArgs, ConfigurableEnvironment environment, EventSystem eventSystem, DetectContext detectContext) throws DetectUserFriendlyException, IntegrationException {
Gson gson = bootFactory.createGson();
ObjectMapper objectMapper = bootFactory.createObjectMapper();
DocumentBuilder xml = bootFactory.createXmlDocumentBuilder();
Configuration configuration = bootFactory.createConfiguration();
DetectInfo detectInfo = DetectInfoUtility.createDefaultDetectInfo();
SpringPropertySource springPropertySource = new SpringPropertySource(environment);
DetectPropertySource propertySource = new DetectPropertySource(springPropertySource);
DetectPropertyMap propertyMap = new DetectPropertyMap();
DetectConfiguration detectConfiguration = new DetectConfiguration(propertySource, propertyMap);
DetectOptionManager detectOptionManager = new DetectOptionManager(detectConfiguration, detectInfo);
final List<DetectOption> options = detectOptionManager.getDetectOptions();
DetectArgumentState detectArgumentState = parseDetectArgumentState(sourceArgs);
if (detectArgumentState.isHelp() || detectArgumentState.isDeprecatedHelp() || detectArgumentState.isVerboseHelp()) {
printAppropriateHelp(options, detectArgumentState);
return BootResult.exit(detectConfiguration);
}
if (detectArgumentState.isHelpHtmlDocument()) {
printHelpHtmlDocument(options, detectInfo, configuration);
return BootResult.exit(detectConfiguration);
}
if (detectArgumentState.isHelpJsonDocument()) {
printHelpJsonDocument(options, detectInfo, configuration, gson);
return BootResult.exit(detectConfiguration);
}
printDetectInfo(detectInfo);
if (detectArgumentState.isInteractive()) {
startInteractiveMode(detectOptionManager, detectConfiguration, gson, objectMapper);
}
processDetectConfiguration(detectInfo, detectRun, detectConfiguration, options);
detectOptionManager.postConfigurationProcessedInit();
logger.info("Configuration processed completely.");
printConfiguration(detectConfiguration.getBooleanProperty(DetectProperty.DETECT_SUPPRESS_CONFIGURATION_OUTPUT, PropertyAuthority.None), options);
logger.info("Initializing detect.");
DetectConfigurationFactory factory = new DetectConfigurationFactory(detectConfiguration);
DirectoryManager directoryManager = new DirectoryManager(factory.createDirectoryOptions(), detectRun);
DiagnosticManager diagnosticManager = createDiagnostics(detectOptionManager.getDetectOptions(), detectRun, detectInfo, detectArgumentState, eventSystem, directoryManager);
checkForInvalidOptions(detectOptionManager);
if (detectOptionManager.checkForAnyFailureProperties()) {
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_CONFIGURATION));
return BootResult.exit(detectConfiguration);
}
ConnectivityManager connectivityManager;
boolean offline = detectConfiguration.getBooleanProperty(DetectProperty.BLACKDUCK_OFFLINE_MODE, PropertyAuthority.None);
if (offline) {
logger.info("Detect is in offline mode.");
connectivityManager = ConnectivityManager.offline();
} else {
logger.info("Detect is in online mode.");
// check my connectivity
ConnectivityChecker connectivityChecker = new ConnectivityChecker();
ConnectivityResult connectivityResult = connectivityChecker.determineConnectivity(detectConfiguration, detectOptionManager, detectInfo, gson, objectMapper, eventSystem);
if (connectivityResult.isSuccessfullyConnected()) {
logger.info("Detect is capable of communicating with server.");
connectivityManager = ConnectivityManager.online(connectivityResult.getBlackDuckServicesFactory(), connectivityResult.getPhoneHomeManager(), connectivityResult.getBlackDuckServerConfig());
} else {
logger.info("Detect is NOT capable of communicating with server.");
logger.info("Please double check the Detect documentation: https://synopsys.atlassian.net/wiki/spaces/INTDOCS/pages/622633/Hub+Detect");
if (detectConfiguration.getBooleanProperty(DetectProperty.DETECT_DISABLE_WITHOUT_BLACKDUCK, PropertyAuthority.None)) {
logger.info(connectivityResult.getFailureReason());
logger.info(String.format("%s is set to 'true' so Detect will simply exit.", DetectProperty.DETECT_DISABLE_WITHOUT_BLACKDUCK.getPropertyName()));
return BootResult.exit(detectConfiguration);
} else {
throw new DetectUserFriendlyException("Could not communicate with Black Duck: " + connectivityResult.getFailureReason(), ExitCodeType.FAILURE_HUB_CONNECTIVITY);
}
}
}
if (detectConfiguration.getBooleanProperty(DetectProperty.DETECT_TEST_CONNECTION, PropertyAuthority.None)) {
logger.info(String.format("%s is set to 'true' so Detect will not run.", DetectProperty.DETECT_TEST_CONNECTION.getPropertyName()));
return BootResult.exit(detectConfiguration);
}
// TODO: Only need this if in diagnostic or online (for phone home):
BomToolProfiler profiler = new BomToolProfiler(eventSystem);
// lock the configuration, boot has completed.
logger.debug("Configuration is now complete. No changes should occur to configuration.");
detectConfiguration.lock();
// Finished, populate the detect context
detectContext.registerBean(detectRun);
detectContext.registerBean(eventSystem);
detectContext.registerBean(profiler);
detectContext.registerBean(detectConfiguration);
detectContext.registerBean(detectInfo);
detectContext.registerBean(directoryManager);
detectContext.registerBean(diagnosticManager);
detectContext.registerBean(connectivityManager);
detectContext.registerBean(gson);
detectContext.registerBean(objectMapper);
detectContext.registerBean(xml);
detectContext.registerBean(configuration);
detectContext.registerConfiguration(RunBeanConfiguration.class);
detectContext.registerConfiguration(DetectorBeanConfiguration.class);
// can only refresh once, this locks and triggers refresh.
detectContext.lock();
BootResult result = new BootResult();
result.bootType = BootResult.BootType.CONTINUE;
result.detectConfiguration = detectConfiguration;
return result;
}
use of com.blackducksoftware.integration.hub.detect.lifecycle.shutdown.ExitCodeRequest in project hub-detect by blackducksoftware.
the class RunManager method run.
public RunResult run() throws DetectUserFriendlyException, InterruptedException, IntegrationException {
// TODO: Better way for run manager to get dependencies so he can be tested. (And better ways of creating his objects)
final DetectConfiguration detectConfiguration = detectContext.getBean(DetectConfiguration.class);
final DetectConfigurationFactory detectConfigurationFactory = detectContext.getBean(DetectConfigurationFactory.class);
final DirectoryManager directoryManager = detectContext.getBean(DirectoryManager.class);
final EventSystem eventSystem = detectContext.getBean(EventSystem.class);
final CodeLocationNameManager codeLocationNameManager = detectContext.getBean(CodeLocationNameManager.class);
final BdioCodeLocationCreator bdioCodeLocationCreator = detectContext.getBean(BdioCodeLocationCreator.class);
final ConnectionManager connectionManager = detectContext.getBean(ConnectionManager.class);
final DetectInfo detectInfo = detectContext.getBean(DetectInfo.class);
final ConnectivityManager connectivityManager = detectContext.getBean(ConnectivityManager.class);
if (connectivityManager.getPhoneHomeManager().isPresent()) {
connectivityManager.getPhoneHomeManager().get().startPhoneHome();
}
final RunResult runResult = new RunResult();
final RunOptions runOptions = detectConfigurationFactory.createRunOptions();
final DetectToolFilter detectToolFilter = runOptions.getDetectToolFilter();
DetectorEnvironment detectorEnvironment = new DetectorEnvironment(directoryManager.getSourceDirectory(), Collections.emptySet(), 0, null, false);
DetectorFactory detectorFactory = detectContext.getBean(DetectorFactory.class);
logger.info(ReportConstants.RUN_SEPARATOR);
if (detectToolFilter.shouldInclude(DetectTool.DOCKER)) {
logger.info("Will include the docker tool.");
ToolRunner toolRunner = new ToolRunner(eventSystem, detectorFactory.createDockerDetector(detectorEnvironment));
toolRunner.run(runResult);
logger.info("Docker actions finished.");
} else {
logger.info("Docker tool will not be run.");
}
logger.info(ReportConstants.RUN_SEPARATOR);
if (detectToolFilter.shouldInclude(DetectTool.BAZEL)) {
logger.info("Will include the bazel tool.");
ToolRunner toolRunner = new ToolRunner(eventSystem, detectorFactory.createBazelDetector(detectorEnvironment));
toolRunner.run(runResult);
logger.info("Bazel actions finished.");
} else {
logger.info("Bazel tool will not be run.");
}
logger.info(ReportConstants.RUN_SEPARATOR);
if (detectToolFilter.shouldInclude(DetectTool.DETECTOR)) {
logger.info("Will include the detector tool.");
final String projectBomTool = detectConfiguration.getProperty(DetectProperty.DETECT_PROJECT_DETECTOR, PropertyAuthority.None);
final SearchOptions searchOptions = detectConfigurationFactory.createSearchOptions(directoryManager.getSourceDirectory());
final DetectorTool detectorTool = new DetectorTool(detectContext);
final DetectorToolResult detectorToolResult = detectorTool.performDetectors(searchOptions, projectBomTool);
runResult.addToolNameVersionIfPresent(DetectTool.DETECTOR, detectorToolResult.bomToolProjectNameVersion);
runResult.addDetectCodeLocations(detectorToolResult.bomToolCodeLocations);
runResult.addApplicableDetectors(detectorToolResult.applicableDetectorTypes);
if (detectorToolResult.failedDetectorTypes.size() > 0) {
eventSystem.publishEvent(Event.ExitCode, new ExitCodeRequest(ExitCodeType.FAILURE_DETECTOR, "A detector failed."));
}
logger.info("Detector actions finished.");
} else {
logger.info("Detector tool will not be run.");
}
logger.info(ReportConstants.RUN_SEPARATOR);
logger.info("Completed code location tools.");
logger.info("Determining project info.");
final ProjectNameVersionOptions projectNameVersionOptions = detectConfigurationFactory.createProjectNameVersionOptions(directoryManager.getSourceDirectory().getName());
final ProjectNameVersionDecider projectNameVersionDecider = new ProjectNameVersionDecider(projectNameVersionOptions);
final NameVersion projectNameVersion = projectNameVersionDecider.decideProjectNameVersion(runOptions.getPreferredTools(), runResult.getDetectToolProjectInfo());
logger.info("Project name: " + projectNameVersion.getName());
logger.info("Project version: " + projectNameVersion.getVersion());
Optional<ProjectVersionWrapper> projectVersionWrapper = Optional.empty();
if (connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
logger.info("Getting or creating project.");
final DetectProjectServiceOptions options = detectConfigurationFactory.createDetectProjectServiceOptions();
final DetectProjectMappingService detectProjectMappingService = new DetectProjectMappingService(blackDuckServicesFactory.createBlackDuckService());
final DetectProjectService detectProjectService = new DetectProjectService(blackDuckServicesFactory, options, detectProjectMappingService);
projectVersionWrapper = Optional.of(detectProjectService.createOrUpdateHubProject(projectNameVersion, options.getApplicationId()));
if (projectVersionWrapper.isPresent() && runOptions.shouldUnmapCodeLocations()) {
logger.info("Unmapping code locations.");
final DetectCodeLocationUnmapService detectCodeLocationUnmapService = new DetectCodeLocationUnmapService(blackDuckServicesFactory.createBlackDuckService(), blackDuckServicesFactory.createCodeLocationService());
detectCodeLocationUnmapService.unmapCodeLocations(projectVersionWrapper.get().getProjectVersionView());
} else {
logger.debug("Will not unmap code locations: Project view was not present, or should not unmap code locations.");
}
} else {
logger.debug("Detect is not online, and will not create the project.");
}
logger.info("Completed project and version actions.");
logger.info("Processing Detect Code Locations.");
final CodeLocationWaitData codeLocationWaitData = new CodeLocationWaitData();
final BdioManager bdioManager = new BdioManager(detectInfo, new SimpleBdioFactory(), new IntegrationEscapeUtil(), codeLocationNameManager, detectConfiguration, bdioCodeLocationCreator, directoryManager, eventSystem);
final BdioResult bdioResult = bdioManager.createBdioFiles(runOptions.getAggregateName(), projectNameVersion, runResult.getDetectCodeLocations());
if (bdioResult.getUploadTargets().size() > 0) {
logger.info("Created " + bdioResult.getUploadTargets().size() + " BDIO files.");
bdioResult.getUploadTargets().forEach(it -> eventSystem.publishEvent(Event.OutputFileOfInterest, it.getUploadFile()));
if (connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
logger.info("Uploading BDIO files.");
final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
final DetectBdioUploadService detectBdioUploadService = new DetectBdioUploadService(detectConfiguration, blackDuckServicesFactory.createBdioUploadService(), eventSystem);
final CodeLocationCreationData<UploadBatchOutput> uploadBatchOutputCodeLocationCreationData = detectBdioUploadService.uploadBdioFiles(bdioResult.getUploadTargets());
codeLocationWaitData.setFromBdioCodeLocationCreationData(uploadBatchOutputCodeLocationCreationData);
}
} else {
logger.debug("Did not create any BDIO files.");
}
logger.info("Completed Detect Code Location processing.");
logger.info(ReportConstants.RUN_SEPARATOR);
if (detectToolFilter.shouldInclude(DetectTool.SIGNATURE_SCAN)) {
logger.info("Will include the signature scanner tool.");
final BlackDuckSignatureScannerOptions blackDuckSignatureScannerOptions = detectConfigurationFactory.createBlackDuckSignatureScannerOptions();
final BlackDuckSignatureScannerTool blackDuckSignatureScannerTool = new BlackDuckSignatureScannerTool(blackDuckSignatureScannerOptions, detectContext);
final SignatureScannerToolResult signatureScannerToolResult = blackDuckSignatureScannerTool.runScanTool(projectNameVersion, runResult.getDockerTar());
if (signatureScannerToolResult.getResult() == Result.SUCCESS && signatureScannerToolResult.getCreationData().isPresent()) {
codeLocationWaitData.setFromSignatureScannerCodeLocationCreationData(signatureScannerToolResult.getCreationData().get());
}
logger.info("Signature scanner actions finished.");
} else {
logger.info("Signature scan tool will not be run.");
}
logger.info(ReportConstants.RUN_SEPARATOR);
if (detectToolFilter.shouldInclude(DetectTool.BINARY_SCAN)) {
logger.info("Will include the binary scanner tool.");
if (connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
final BlackDuckBinaryScannerTool blackDuckBinaryScanner = new BlackDuckBinaryScannerTool(eventSystem, codeLocationNameManager, detectConfiguration, blackDuckServicesFactory);
BinaryScanToolResult result = blackDuckBinaryScanner.performBinaryScanActions(projectNameVersion);
if (result.isSuccessful()) {
codeLocationWaitData.setFromBinaryScan(result.getNotificationTaskRange(), result.getCodeLocationNames());
}
}
logger.info("Binary scanner actions finished.");
} else {
logger.info("Binary scan tool will not be run.");
}
logger.info(ReportConstants.RUN_SEPARATOR);
if (detectToolFilter.shouldInclude(DetectTool.POLARIS)) {
logger.info("Will include the Polaris tool.");
final PolarisTool polarisTool = new PolarisTool(eventSystem, directoryManager, new ExecutableRunner(), connectionManager);
polarisTool.runPolaris(new Slf4jIntLogger(logger), directoryManager.getSourceDirectory());
logger.info("Polaris actions finished.");
} else {
logger.info("Polaris CLI tool will not be run.");
}
logger.info(ReportConstants.RUN_SEPARATOR);
if (projectVersionWrapper.isPresent() && connectivityManager.isDetectOnline() && connectivityManager.getBlackDuckServicesFactory().isPresent()) {
final BlackDuckServicesFactory blackDuckServicesFactory = connectivityManager.getBlackDuckServicesFactory().get();
logger.info("Will perform Black Duck post actions.");
final BlackduckReportOptions blackduckReportOptions = detectConfigurationFactory.createReportOptions();
final PolicyCheckOptions policyCheckOptions = detectConfigurationFactory.createPolicyCheckOptions();
final long timeoutInSeconds = detectConfigurationFactory.getTimeoutInSeconds();
final BlackduckPostActions blackduckPostActions = new BlackduckPostActions(blackDuckServicesFactory, eventSystem);
blackduckPostActions.perform(blackduckReportOptions, policyCheckOptions, codeLocationWaitData, projectVersionWrapper.get(), timeoutInSeconds);
final boolean hasAtLeastOneBdio = !bdioResult.getUploadTargets().isEmpty();
final boolean shouldHaveScanned = detectToolFilter.shouldInclude(DetectTool.SIGNATURE_SCAN);
if (hasAtLeastOneBdio || shouldHaveScanned) {
final Optional<String> componentsLink = projectVersionWrapper.get().getProjectVersionView().getFirstLink(ProjectVersionView.COMPONENTS_LINK);
if (componentsLink.isPresent()) {
logger.info(String.format("To see your results, follow the URL: %s", componentsLink.get()));
}
}
logger.info("Black Duck actions have finished.");
} else {
logger.debug("Will not perform post actions: Detect is not online.");
}
logger.info("All tools have finished.");
logger.info(ReportConstants.RUN_SEPARATOR);
return runResult;
}
Aggregations