use of com.synopsys.integration.executable.ExecutableOutput in project synopsys-detect by blackducksoftware.
the class DockerExtractor method loadDockerImage.
private void loadDockerImage(File directory, Map<String, String> environmentVariables, ExecutableTarget dockerExe, File imageToImport) throws IOException, ExecutableRunnerException, IntegrationException {
List<String> dockerImportArguments = Arrays.asList("load", "-i", imageToImport.getCanonicalPath());
Executable dockerImportImageExecutable = ExecutableUtils.createFromTarget(directory, environmentVariables, dockerExe, dockerImportArguments);
ExecutableOutput exeOut = executableRunner.execute(dockerImportImageExecutable);
if (exeOut.getReturnCode() != 0) {
throw new IntegrationException(String.format("Command %s %s returned %d: %s", dockerExe.toCommand(), dockerImportArguments, exeOut.getReturnCode(), exeOut.getErrorOutput()));
}
}
use of com.synopsys.integration.executable.ExecutableOutput 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.executable.ExecutableOutput 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.executable.ExecutableOutput in project synopsys-detect by blackducksoftware.
the class BitbakeDetectableTest method setup.
@Override
protected void setup() throws IOException {
addFile("oe-init-build-env");
addExecutableOutput(// Command generates task-depends.dot
createStandardOutput(""), createBitbakeCommand("bitbake -g core-image-minimal"));
addFile(Paths.get("task-depends.dot"), "digraph depends {", "\"acl.do_build\" [label = \"acl do_build\\n:2.2.52-r0\\n/home/bit/poky/meta/recipes-support/attr/acl_2.2.52.bb\"]", "\"acl.do_build\" -> \"acl.do_package_qa\"", "\"acl.do_package\" -> \"attr.do_packagedata\"", "\"attr.do_build\" [label = \"attr do_build\\n:2.4.47-r0\\n/home/bit/poky/meta/recipes-support/attr/attr_2.4.47.bb\"]", "\"attr.do_build\" -> \"base-files.do_package_write_rpm\"", "\"attr.do_build\" -> \"base-passwd.do_package_write_rpm\"", "\"base-files.do_build\" [label = \"base-files do_build\\n:3.0.14-r89\\n/home/bit/poky/meta/recipes-core/base-files/base-files_3.0.14.bb\"]", "\"base-passwd.do_build\" [label = \"base-passwd do_build\\n:3.5.29-r0\\n/home/bit/poky/meta/recipes-core/base-passwd/base-passwd_3.5.29.bb\"]", "}");
ExecutableOutput bitbakeShowRecipesOutput = createStandardOutput("=== Available recipes: ===", "acl:", " meta 2.2.52", "attr:", " meta 2.4.47", "base-files:", " meta 3.0.14", "base-passwd:", " meta 3.5.29");
addExecutableOutput(bitbakeShowRecipesOutput, createBitbakeCommand("bitbake-layers show-recipes"));
addExecutableOutput(createStandardOutput(getSourceDirectory().toFile().getAbsolutePath()), createBitbakeCommand("pwd"));
Path licensesDirectory = Paths.get("licenses/");
Path licenseManifest = Paths.get(licensesDirectory.toString(), "core-image-minimal-some-arch/license.manifest");
addFile(licenseManifest, "PACKAGE NAME: libattr", "PACKAGE VERSION: 2.4.47", "RECIPE NAME: attr", "LICENSE: LGPLv2.1+", "", "PACKAGE NAME: base-files", "PACKAGE VERSION: 3.0.14", "RECIPE NAME: base-files", "LICENSE: GPLv2", "", "PACKAGE NAME: base-passwd", "PACKAGE VERSION: 3.5.29", "RECIPE NAME: base-passwd", "LICENSE: GPLv2");
addExecutableOutput(createStandardOutput("MACHINE_ARCH=\"not-using\"", "LICENSE_DIRECTORY=\"" + licenseManifest.toAbsolutePath() + "\""), createBitbakeCommand("bitbake --environment"));
}
use of com.synopsys.integration.executable.ExecutableOutput in project synopsys-detect by blackducksoftware.
the class PearCliDetectableTest method setup.
@Override
protected void setup() throws IOException {
addFile(Paths.get("package.xml"), "<?xml version=\"1.0\"?>", "<!DOCTYPE package SYSTEM \"http://pear.php.net/dtd/package-1.0\">", "<package xmlns=\"http://pear.php.net/dtd/package-2.0\">", " <name>couchbase</name>", " <version>", " <release>3.0.1</release>", " <api>3.0.0</api>", " </version>", " <dependencies>", " <required>", " <php>", " <min>7.1.0</min>", " </php>", " <pearinstaller>", " <min>1.10.1</min>", " </pearinstaller>", " </required>", " </dependencies>", "</package>");
ExecutableOutput listOutput = createStandardOutput("==================", "PHP 7.1.0", "PearInstaller 1.10.1");
addExecutableOutput(listOutput, new HashMap<>(), "pear", "list");
ExecutableOutput packageDependenciesOutput = createStandardOutput("==================", "Y Package PHP", "Y Package PearInstaller");
addExecutableOutput(packageDependenciesOutput, new HashMap<>(), "pear", "package-dependencies", "package.xml");
}
Aggregations