use of com.synopsys.integration.detectable.detectable.executable.ExecutableFailedException in project synopsys-detect by blackducksoftware.
the class GoModCliExtractor method extract.
public Extraction extract(File directory, ExecutableTarget goExe) throws ExecutableFailedException, JsonSyntaxException, DetectableException {
List<GoListModule> goListModules = listModules(directory, goExe);
List<GoListAllData> goListAllModules = listAllModules(directory, goExe);
List<GoGraphRelationship> goGraphRelationships = listGraphRelationships(directory, goExe);
Set<String> excludedModules = listExcludedModules(directory, goExe);
GoRelationshipManager goRelationshipManager = new GoRelationshipManager(goGraphRelationships, excludedModules);
GoModDependencyManager goModDependencyManager = new GoModDependencyManager(goListAllModules, externalIdFactory);
List<CodeLocation> codeLocations = goListModules.stream().map(goListModule -> goModGraphGenerator.generateGraph(goListModule, goRelationshipManager, goModDependencyManager)).collect(Collectors.toList());
// No project info - hoping git can help with that.
return new Extraction.Builder().success(codeLocations).build();
}
use of com.synopsys.integration.detectable.detectable.executable.ExecutableFailedException in project synopsys-detect by blackducksoftware.
the class DetectableTool method extract.
public DetectableToolResult extract() {
// TODO: Move docker/bazel out of detectable and drop this notion of a detctable tool. Will simplify this logic and make this unneccessary.
DetectableResult extractable;
try {
extractable = detectable.extractable();
} catch (DetectableException e) {
extractable = new ExceptionDetectableResult(e);
}
if (!extractable.getPassed()) {
logger.error(String.format("Was not extractable: %s", extractable.toDescription()));
statusEventPublisher.publishIssue(new DetectIssue(DetectIssueType.DETECTABLE_TOOL, "Detectable Tool Issue", Arrays.asList(extractable.toDescription())));
statusEventPublisher.publishStatusSummary(new Status(name, StatusType.FAILURE));
exitCodePublisher.publishExitCode(ExitCodeType.FAILURE_GENERAL_ERROR, extractable.toDescription());
return DetectableToolResult.failed(extractable);
}
logger.debug("Extractable passed.");
ExtractionEnvironment extractionEnvironment = extractionEnvironmentProvider.createExtractionEnvironment(name);
Extraction extraction;
try {
extraction = detectable.extract(extractionEnvironment);
} catch (ExecutableFailedException | ExecutableRunnerException | JsonSyntaxException | IOException | CycleDetectedException | DetectableException | MissingExternalIdException | ParserConfigurationException | SAXException e) {
extraction = new Extraction.Builder().exception(e).build();
}
if (!extraction.isSuccess()) {
logger.error("Extraction was not success.");
List<String> errorMessages = collectErrorMessages(extraction);
statusEventPublisher.publishIssue(new DetectIssue(DetectIssueType.DETECTABLE_TOOL, "Detectable Tool Issue", errorMessages));
statusEventPublisher.publishStatusSummary(new Status(name, StatusType.FAILURE));
exitCodePublisher.publishExitCode(new ExitCodeRequest(ExitCodeType.FAILURE_GENERAL_ERROR, extraction.getDescription()));
return DetectableToolResult.failed();
} else {
logger.debug("Extraction success.");
statusEventPublisher.publishStatusSummary(new Status(name, StatusType.SUCCESS));
}
Map<CodeLocation, DetectCodeLocation> detectCodeLocationMap = codeLocationConverter.toDetectCodeLocation(sourcePath, extraction, sourcePath, name);
List<DetectCodeLocation> detectCodeLocations = new ArrayList<>(detectCodeLocationMap.values());
DockerTargetData dockerTargetData = DockerTargetData.fromExtraction(extraction);
DetectToolProjectInfo projectInfo = null;
if (StringUtils.isNotBlank(extraction.getProjectName()) || StringUtils.isNotBlank(extraction.getProjectVersion())) {
NameVersion nameVersion = new NameVersion(extraction.getProjectName(), extraction.getProjectVersion());
projectInfo = new DetectToolProjectInfo(detectTool, nameVersion);
}
logger.debug("Tool finished.");
return DetectableToolResult.success(detectCodeLocations, projectInfo, dockerTargetData);
}
use of com.synopsys.integration.detectable.detectable.executable.ExecutableFailedException in project synopsys-detect by blackducksoftware.
the class BitbakeExtractor method generateCodeLocationForTargetPackage.
private Optional<CodeLocation> generateCodeLocationForTargetPackage(String targetPackage, File sourceDirectory, ExecutableTarget bashExecutable, File buildEnvironmentFile, File buildDirectory, ShowRecipesResults showRecipesResults, BitbakeEnvironment bitbakeEnvironment) {
try {
BitbakeGraph bitbakeGraph = generateBitbakeGraph(sourceDirectory, bashExecutable, buildEnvironmentFile, buildDirectory, targetPackage, showRecipesResults.getLayerNames());
Map<String, String> imageRecipes = null;
if (dependencyTypeFilter.shouldExclude(BitbakeDependencyType.BUILD)) {
imageRecipes = readImageRecipes(buildDirectory, targetPackage, bitbakeEnvironment);
}
DependencyGraph dependencyGraph = bitbakeDependencyGraphTransformer.transform(bitbakeGraph, showRecipesResults.getRecipesWithLayers(), imageRecipes);
return Optional.of(new CodeLocation(dependencyGraph));
} catch (ExecutableFailedException | IntegrationException | IOException e) {
logger.error("Failed to extract a Code Location while running Bitbake against package '{}': {}", targetPackage, e.getMessage());
logger.debug(e.getMessage(), e);
return Optional.empty();
}
}
use of com.synopsys.integration.detectable.detectable.executable.ExecutableFailedException in project synopsys-detect by blackducksoftware.
the class BitbakeExtractor method determineBuildDirectory.
private File determineBuildDirectory(File sourceDirectory, ExecutableTarget bashExecutable, File buildEnvironmentFile) {
File fallbackBuildDir = new File(sourceDirectory, DEFAULT_BUILD_DIR_NAME);
File derivedBuildDirectory;
try {
List<String> pwdOutput = bitbakeCommandRunner.runPwdCommand(sourceDirectory, bashExecutable, buildEnvironmentFile);
derivedBuildDirectory = pwdOutputParser.deriveBuildDirectory(pwdOutput);
} catch (ExecutableFailedException | IOException e) {
logger.warn("Unable to determine build directory location due to error: {}; ; using {} for build dir", e.getMessage(), fallbackBuildDir.getAbsolutePath());
return fallbackBuildDir;
}
if (derivedBuildDirectory.isDirectory()) {
logger.debug("Derived build dir: {}", derivedBuildDirectory.getAbsolutePath());
return derivedBuildDirectory;
} else {
logger.warn("Derived build dir {} is not a directory; using {} for build dir", derivedBuildDirectory.getAbsolutePath(), fallbackBuildDir.getAbsolutePath());
return fallbackBuildDir;
}
}
use of com.synopsys.integration.detectable.detectable.executable.ExecutableFailedException in project synopsys-detect by blackducksoftware.
the class SbtDotExtractor method extract.
public Extraction extract(File directory, ExecutableTarget sbt, String sbtCommandAdditionalArguments) {
try {
List<String> sbtArgs = sbtCommandArgumentGenerator.generateSbtCmdArgs(sbtCommandAdditionalArguments, "dependencyDot");
Executable dotExecutable = ExecutableUtils.createFromTarget(directory, sbt, sbtArgs);
ExecutableOutput dotOutput = executableRunner.executeSuccessfully(dotExecutable);
List<File> dotGraphs = sbtDotOutputParser.parseGeneratedGraphFiles(dotOutput.getStandardOutputAsList());
Extraction.Builder extraction = new Extraction.Builder();
for (File dotGraph : dotGraphs) {
GraphParser graphParser = new GraphParser(FileUtils.openInputStream(dotGraph));
Set<String> rootIDs = sbtRootNodeFinder.determineRootIDs(graphParser);
// typically found in project-folder/target/<>.dot so .parent.parent == project folder
File projectFolder = dotGraph.getParentFile().getParentFile();
if (rootIDs.size() == 1) {
String projectId = rootIDs.stream().findFirst().get();
DependencyGraph graph = sbtGraphParserTransformer.transformDotToGraph(graphParser, projectId);
Dependency projectDependency = graphNodeParser.nodeToDependency(projectId);
extraction.codeLocations(new CodeLocation(graph, projectDependency.getExternalId(), projectFolder));
if (projectFolder.equals(directory)) {
extraction.projectName(projectDependency.getName());
extraction.projectVersion(projectDependency.getVersion());
}
} else {
logger.warn("Unable to determine which node was the project in an SBT graph: " + dotGraph.toString());
logger.warn("This may mean you have extraneous dependencies and should consider removing them. The dependencies are: " + String.join(",", rootIDs));
DependencyGraph graph = sbtGraphParserTransformer.transformDotToGraph(graphParser, rootIDs);
extraction.codeLocations(new CodeLocation(graph, projectFolder));
}
}
return extraction.success().build();
} catch (IOException | DetectableException | ExecutableFailedException e) {
return new Extraction.Builder().exception(e).build();
}
}
Aggregations