use of com.blackducksoftware.integration.hub.detect.util.executable.Executable in project hub-detect by blackducksoftware.
the class ExeNugetInspector method execute.
@Override
public ExecutableOutput execute(File workingDirectory, List<String> arguments) throws ExecutableRunnerException {
final Executable hubNugetInspectorExecutable = new Executable(workingDirectory, inspectorExe, arguments);
final ExecutableOutput executableOutput = executableRunner.execute(hubNugetInspectorExecutable);
return executableOutput;
}
use of com.blackducksoftware.integration.hub.detect.util.executable.Executable in project hub-detect by blackducksoftware.
the class PipenvExtractor method extract.
public Extraction extract(final File directory, final String pythonExe, final String pipenvExe, final File setupFile) {
Extraction extraction;
try {
final String projectName = getProjectName(directory, pythonExe, setupFile);
final String projectVersionName = getProjectVersionName(directory, pythonExe, setupFile);
final PipParseResult result;
final Executable pipenvRunPipFreeze = new Executable(directory, pipenvExe, Arrays.asList("run", "pip", "freeze"));
final ExecutableOutput pipFreezeOutput = executableRunner.execute(pipenvRunPipFreeze);
final Executable pipenvGraph = new Executable(directory, pipenvExe, Arrays.asList("graph", "--bare"));
final ExecutableOutput graphOutput = executableRunner.execute(pipenvGraph);
result = pipenvTreeParser.parse(projectName, projectVersionName, pipFreezeOutput.getStandardOutputAsList(), graphOutput.getStandardOutputAsList(), directory.toString());
if (result != null) {
extraction = new Extraction.Builder().success(result.getCodeLocation()).projectName(result.getProjectName()).projectVersion(result.getProjectVersion()).build();
} else {
extraction = new Extraction.Builder().failure("Pipenv graph could not successfully be parsed").build();
}
} catch (final Exception e) {
extraction = new Extraction.Builder().exception(e).build();
}
return extraction;
}
use of com.blackducksoftware.integration.hub.detect.util.executable.Executable in project hub-detect by blackducksoftware.
the class PipenvExtractor method getProjectName.
private String getProjectName(final File directory, final String pythonExe, final File setupFile) throws ExecutableRunnerException {
String projectName = detectConfiguration.getProperty(DetectProperty.DETECT_PIP_PROJECT_NAME, PropertyAuthority.None);
if (StringUtils.isBlank(projectName) && setupFile != null && setupFile.exists()) {
final Executable findProjectNameExecutable = new Executable(directory, pythonExe, Arrays.asList(setupFile.getAbsolutePath(), "--name"));
final List<String> output = executableRunner.execute(findProjectNameExecutable).getStandardOutputAsList();
projectName = output.get(output.size() - 1).replace('_', '-').trim();
}
return projectName;
}
use of com.blackducksoftware.integration.hub.detect.util.executable.Executable in project hub-detect by blackducksoftware.
the class PipenvExtractor method getProjectVersionName.
private String getProjectVersionName(final File directory, final String pythonExe, final File setupFile) throws ExecutableRunnerException {
String projectVersionName = detectConfiguration.getProperty(DetectProperty.DETECT_PIP_PROJECT_VERSION_NAME, PropertyAuthority.None);
if (StringUtils.isBlank(projectVersionName) && setupFile != null && setupFile.exists()) {
final Executable findProjectNameExecutable = new Executable(directory, pythonExe, Arrays.asList(setupFile.getAbsolutePath(), "--version"));
final List<String> output = executableRunner.execute(findProjectNameExecutable).getStandardOutputAsList();
projectVersionName = output.get(output.size() - 1).trim();
}
return projectVersionName;
}
use of com.blackducksoftware.integration.hub.detect.util.executable.Executable in project hub-detect by blackducksoftware.
the class NpmCliExtractor method extract.
public Extraction extract(final File directory, final String npmExe, final ExtractionId extractionId) {
final boolean includeDevDeps = detectConfiguration.getBooleanProperty(DetectProperty.DETECT_NPM_INCLUDE_DEV_DEPENDENCIES, PropertyAuthority.None);
final List<String> exeArgs = new ArrayList<>();
exeArgs.add("ls");
exeArgs.add("-json");
if (!includeDevDeps) {
exeArgs.add("-prod");
}
final String additionalArguments = detectConfiguration.getProperty(DetectProperty.DETECT_NPM_ARGUMENTS, PropertyAuthority.None);
if (StringUtils.isNotBlank(additionalArguments)) {
exeArgs.addAll(Arrays.asList(additionalArguments.split(" ")));
}
final Executable npmLsExe = new Executable(directory, npmExe, exeArgs);
ExecutableOutput executableOutput;
try {
executableOutput = executableRunner.execute(npmLsExe);
} catch (final Exception e) {
return new Extraction.Builder().exception(e).build();
}
final String standardOutput = executableOutput.getStandardOutput();
final String errorOutput = executableOutput.getErrorOutput();
if (StringUtils.isNotBlank(errorOutput)) {
logger.error("Error when running npm ls -json command");
logger.error(errorOutput);
return new Extraction.Builder().failure("Npm wrote to stderr while running npm ls.").build();
} else if (StringUtils.isNotBlank(standardOutput)) {
logger.debug("Parsing npm ls file.");
logger.debug(standardOutput);
try {
final NpmParseResult result = npmCliParser.generateCodeLocation(directory.getCanonicalPath(), standardOutput);
return new Extraction.Builder().success(result.codeLocation).projectName(result.projectName).projectVersion(result.projectVersion).build();
} catch (final IOException e) {
return new Extraction.Builder().exception(e).build();
}
} else {
logger.error("Nothing returned from npm ls -json command");
return new Extraction.Builder().failure("Npm returned error after running npm ls.").build();
}
}
Aggregations