use of com.synopsys.integration.detectable.ExecutableTarget in project synopsys-detect by blackducksoftware.
the class LocatorNugetInspectorResolver method install.
private NugetInspector install() throws IntegrationException {
// dotnet
ExecutableTarget dotnetExecutable = executableResolver.resolveDotNet();
boolean useDotnet = true;
if (shouldForceExeInspector(detectInfo)) {
logger.debug("Will use the classic inspector.");
useDotnet = false;
} else if (dotnetExecutable == null) {
if (isNotWindows(detectInfo)) {
throw new DetectableException("When not on Windows, the nuget inspector requires the dotnet executable to run.");
} else {
useDotnet = false;
}
}
if (useDotnet) {
File dotnetFolder;
if (dotNetRuntimeManager.isRuntimeAvailable(5)) {
dotnetFolder = nugetInspectorLocator.locateDotnet5Inspector();
return findDotnetCoreInspector(dotnetFolder, dotnetExecutable, "NugetDotnet5Inspector.dll");
} else if (dotNetRuntimeManager.isRuntimeAvailable(3, 1)) {
dotnetFolder = nugetInspectorLocator.locateDotnet3Inspector();
return findDotnetCoreInspector(dotnetFolder, dotnetExecutable, "NugetDotnet3Inspector.dll");
} else {
dotnetFolder = nugetInspectorLocator.locateDotnetInspector();
return findDotnetCoreInspector(dotnetFolder, dotnetExecutable, "BlackduckNugetInspector.dll");
}
} else {
File classicFolder = nugetInspectorLocator.locateExeInspector();
return findExeInspector(classicFolder);
}
}
use of com.synopsys.integration.detectable.ExecutableTarget 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.ExecutableTarget in project synopsys-detect by blackducksoftware.
the class LernaPackageDiscoverer method discoverLernaPackages.
public List<LernaPackage> discoverLernaPackages(File workingDirectory, ExecutableTarget lernaExecutable) throws ExecutableRunnerException {
ExecutableOutput lernaLsExecutableOutput = executableRunner.execute(ExecutableUtils.createFromTarget(workingDirectory, lernaExecutable, "ls", "--all", "--json"));
String lernaLsOutput = lernaLsExecutableOutput.getStandardOutput();
Type lernaPackageListType = new TypeToken<ArrayList<LernaPackage>>() {
}.getType();
List<LernaPackage> lernaPackages = gson.fromJson(lernaLsOutput, lernaPackageListType);
return lernaPackages.stream().filter(Objects::nonNull).filter(lernaPackage -> excludedIncludedFilter.shouldInclude(lernaPackage.getName())).collect(Collectors.toList());
}
use of com.synopsys.integration.detectable.ExecutableTarget in project synopsys-detect by blackducksoftware.
the class NugetInspectorExtractor method executeTarget.
private NugetTargetResult executeTarget(ExecutableTarget inspector, File targetFile, File outputDirectory, NugetInspectorOptions nugetInspectorOptions) throws ExecutableRunnerException, IOException, DetectableException {
if (!outputDirectory.exists() && !outputDirectory.mkdirs()) {
throw new DetectableException(String.format("Executing the nuget inspector failed, could not create output directory: %s", outputDirectory));
}
List<String> arguments = NugetInspectorArguments.fromInspectorOptions(nugetInspectorOptions, targetFile, outputDirectory);
Executable executable = ExecutableUtils.createFromTarget(outputDirectory, inspector, arguments);
ExecutableOutput executableOutput = executableRunner.execute(executable);
if (executableOutput.getReturnCode() != 0) {
throw new DetectableException(String.format("Executing the nuget inspector failed: %s", executableOutput.getReturnCode()));
}
List<File> dependencyNodeFiles = fileFinder.findFiles(outputDirectory, INSPECTOR_OUTPUT_PATTERN);
List<NugetParseResult> parseResults = new ArrayList<>();
if (dependencyNodeFiles != null) {
for (File dependencyNodeFile : dependencyNodeFiles) {
String text = FileUtils.readFileToString(dependencyNodeFile, StandardCharsets.UTF_8);
NugetParseResult result = nugetInspectorParser.createCodeLocation(text);
parseResults.add(result);
}
}
NugetTargetResult targetResult = new NugetTargetResult();
targetResult.codeLocations = parseResults.stream().flatMap(it -> it.getCodeLocations().stream()).collect(Collectors.toList());
targetResult.nameVersion = parseResults.stream().filter(it -> StringUtils.isNotBlank(it.getProjectName())).map(it -> new NameVersion(it.getProjectName(), it.getProjectVersion())).findFirst().orElse(null);
return targetResult;
}
use of com.synopsys.integration.detectable.ExecutableTarget in project synopsys-detect by blackducksoftware.
the class ProjectInspectorExtractor method extract.
public Extraction extract(ProjectInspectorOptions projectInspectorOptions, List<String> extra, File targetDirectory, File outputDirectory, ExecutableTarget inspector) throws ExecutableFailedException {
File outputFile = new File(outputDirectory, "inspection.json");
List<String> arguments = new LinkedList<>();
arguments.add("inspect");
arguments.add("--dir");
arguments.add(targetDirectory.toString());
arguments.add("--output-file");
arguments.add(outputFile.toString());
arguments.addAll(extra);
Optional.ofNullable(projectInspectorOptions.getAdditionalArguments()).map(arg -> arg.split(" ")).ifPresent(additionalArguments -> arguments.addAll(Arrays.asList(additionalArguments)));
executableRunner.executeSuccessfully(ExecutableUtils.createFromTarget(targetDirectory, inspector, arguments));
try {
String outputContents = FileUtils.readFileToString(outputFile, StandardCharsets.UTF_8);
List<CodeLocation> codeLocations = projectInspectorParser.parse(outputContents);
return new Extraction.Builder().success(codeLocations).build();
} catch (IOException e) {
return new Extraction.Builder().exception(e).build();
}
}
Aggregations