use of com.blackducksoftware.integration.hub.detect.detector.DetectorException in project hub-detect by blackducksoftware.
the class NpmExecutableFinder method findNpm.
public String findNpm(final DetectorEnvironment environment) throws DetectorException {
try {
if (!hasLookedForNpm) {
foundNpm = findNpm();
hasLookedForNpm = true;
}
return foundNpm;
} catch (final Exception e) {
throw new DetectorException(e);
}
}
use of com.blackducksoftware.integration.hub.detect.detector.DetectorException in project hub-detect by blackducksoftware.
the class GradleInspectorManager method getGradleInspector.
public String getGradleInspector() throws DetectorException {
if (!hasResolvedInspector) {
hasResolvedInspector = true;
try {
final File airGapPath = deriveGradleAirGapDir();
final File generatedGradleScriptFile = directoryManager.getSharedFile(GRADLE_DIR_NAME, GENERATED_GRADLE_SCRIPT_NAME);
GradleScriptCreator gradleScriptCreator = new GradleScriptCreator(detectConfiguration, configuration);
if (airGapPath == null) {
Optional<String> version = findVersion();
if (version.isPresent()) {
logger.info("Resolved the gradle inspector version: " + version.get());
generatedGradleScriptPath = gradleScriptCreator.generateOnlineScript(generatedGradleScriptFile, version.get());
} else {
throw new DetectorException("Unable to find the gradle inspector version from artifactory.");
}
} else {
generatedGradleScriptPath = gradleScriptCreator.generateAirGapScript(generatedGradleScriptFile, airGapPath.getCanonicalPath());
}
} catch (final Exception e) {
throw new DetectorException(e);
}
if (generatedGradleScriptPath == null) {
throw new DetectorException("Unable to initialize the gradle inspector.");
} else {
logger.trace("Derived generated gradle script path: " + generatedGradleScriptPath);
}
} else {
logger.debug("Already attempted to resolve the gradle inspector script, will not attempt again.");
}
if (StringUtils.isBlank(generatedGradleScriptPath)) {
throw new DetectorException("Unable to find or create the gradle inspector script.");
}
return generatedGradleScriptPath;
}
use of com.blackducksoftware.integration.hub.detect.detector.DetectorException in project hub-detect by blackducksoftware.
the class ExtractionHandler method processExtraction.
public void processExtraction(LoggedDetectExtraction extraction, DetectRunInfo detectRunInfo, DetectConfiguration detectConfiguration) throws DetectorException, ExecutableRunnerException {
if (extraction.bomToolDescription.equals("NUGET - Solution")) {
logger.info("OOOO Snap, I know how to handle this.");
NugetSolutionExtractionDebugger debugger = new NugetSolutionExtractionDebugger();
debugger.debug(extraction, detectRunInfo, detectConfiguration);
} else if (extraction.bomToolDescription.equals("GRADLE - Gradle Inspector")) {
logger.info("OOOO Snap, I know how to handle this.");
GradleExtractionDebugger debugger = new GradleExtractionDebugger();
debugger.debug(extraction, detectRunInfo, detectConfiguration);
} else {
throw new DetectorException("Don't know what to do with this extraction, sorry brah.");
}
}
use of com.blackducksoftware.integration.hub.detect.detector.DetectorException in project hub-detect by blackducksoftware.
the class DetectorFinder method findApplicableBomTools.
private List<DetectorEvaluation> findApplicableBomTools(final List<File> directoriesToSearch, final Set<Detector> appliedBefore, final int depth, final DetectorFinderOptions options) throws DetectorException, DetectUserFriendlyException {
final List<DetectorEvaluation> results = new ArrayList<>();
if (depth > options.getMaximumDepth()) {
return results;
}
if (null == directoriesToSearch || directoriesToSearch.size() == 0) {
return results;
}
for (final File directory : directoriesToSearch) {
if (depth > 0 && options.getDetectorSearchFilter().shouldExclude(directory)) {
// NEVER skip at depth 0.
logger.info("Skipping excluded directory: " + directory.getPath());
continue;
}
logger.info("Searching directory: " + directory.getPath());
final Set<DetectorType> applicableTypes = new HashSet<>();
final Set<Detector> applied = new HashSet<>();
final List<DetectorEvaluation> evaluations = processDirectory(directory, appliedBefore, depth, options);
results.addAll(evaluations);
final List<Detector> appliedBomTools = evaluations.stream().filter(it -> it.isApplicable()).map(it -> it.getDetector()).collect(Collectors.toList());
applied.addAll(appliedBomTools);
// TODO: Used to have a remaining detectors and would bail early here, not sure how to go about that?
final Set<Detector> everApplied = new HashSet<>();
everApplied.addAll(applied);
everApplied.addAll(appliedBefore);
final List<File> subdirectories = getSubDirectories(directory, options.getDetectorSearchFilter());
final List<DetectorEvaluation> recursiveResults = findApplicableBomTools(subdirectories, everApplied, depth + 1, options);
results.addAll(recursiveResults);
logger.debug(directory + ": " + applicableTypes.stream().map(it -> it.toString()).collect(Collectors.joining(", ")));
}
return results;
}
use of com.blackducksoftware.integration.hub.detect.detector.DetectorException in project hub-detect by blackducksoftware.
the class DockerInspectorManager method findOrDownloadJar.
private DockerInspectorInfo findOrDownloadJar() throws IntegrationException, DetectUserFriendlyException, IOException {
logger.info("Determining the location of the Docker inspector.");
String dockerVersion = detectConfiguration.getProperty(DetectProperty.DETECT_DOCKER_INSPECTOR_VERSION, PropertyAuthority.None);
Optional<String> location = artifactResolver.resolveArtifactLocation(ArtifactoryConstants.ARTIFACTORY_URL, ArtifactoryConstants.DOCKER_INSPECTOR_REPO, ArtifactoryConstants.DOCKER_INSPECTOR_PROPERTY, dockerVersion, ArtifactoryConstants.DOCKER_INSPECTOR_VERSION_OVERRIDE);
if (location.isPresent()) {
logger.info("Finding or downloading the docker inspector.");
File dockerDirectory = directoryManager.getPermanentDirectory(DOCKER_SHARED_DIRECTORY_NAME);
logger.debug(String.format("Downloading docker inspector from '%s' to '%s'.", location.get(), dockerDirectory.getAbsolutePath()));
File jarFile = artifactResolver.downloadOrFindArtifact(dockerDirectory, location.get());
logger.info("Found online docker inspector: " + jarFile.getAbsolutePath());
return new DockerInspectorInfo(jarFile);
} else {
throw new DetectorException("Unable to find Docker version from artifactory.");
}
}
Aggregations