use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class DockerExtractor method findCodeLocations.
private Extraction.Builder findCodeLocations(File directoryToSearch, File directory) {
File bdioFile = fileFinder.findFile(directoryToSearch, DEPENDENCIES_PATTERN);
if (bdioFile != null) {
SimpleBdioDocument simpleBdioDocument = null;
try (InputStream dockerOutputInputStream = new FileInputStream(bdioFile);
BdioReader bdioReader = new BdioReader(gson, dockerOutputInputStream)) {
simpleBdioDocument = bdioReader.readSimpleBdioDocument();
} catch (Exception e) {
return new Extraction.Builder().exception(e);
}
if (simpleBdioDocument != null) {
DependencyGraph dependencyGraph = bdioTransformer.transformToDependencyGraph(simpleBdioDocument.getProject(), simpleBdioDocument.getComponents());
String projectName = simpleBdioDocument.getProject().name;
String projectVersionName = simpleBdioDocument.getProject().version;
// TODO ejk - update this when project external id is not req'd anymore
Forge dockerForge = new Forge(BdioId.BDIO_ID_SEPARATOR, simpleBdioDocument.getProject().bdioExternalIdentifier.forge);
String externalIdPath = simpleBdioDocument.getProject().bdioExternalIdentifier.externalId;
ExternalId projectExternalId = externalIdFactory.createPathExternalId(dockerForge, externalIdPath);
CodeLocation detectCodeLocation = new CodeLocation(dependencyGraph, projectExternalId);
return new Extraction.Builder().success(detectCodeLocation).projectName(projectName).projectVersion(projectVersionName);
}
}
return new Extraction.Builder().failure("No files found matching pattern [" + DEPENDENCIES_PATTERN + "]. Expected docker-inspector to produce file in " + directory.toString());
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PipenvExtractor method extract.
public Extraction extract(File directory, ExecutableTarget pythonExe, ExecutableTarget pipenvExe, File setupFile, String providedProjectName, String providedProjectVersionName, boolean includeOnlyProjectTree) {
Extraction extraction;
try {
String projectName = resolveProjectName(directory, pythonExe, setupFile, providedProjectName);
String projectVersionName = resolveProjectVersionName(directory, pythonExe, setupFile, providedProjectVersionName);
ExecutableOutput pipFreezeOutput = executableRunner.execute(ExecutableUtils.createFromTarget(directory, pipenvExe, Arrays.asList("run", "pip", "freeze")));
ExecutableOutput graphOutput = executableRunner.execute(ExecutableUtils.createFromTarget(directory, pipenvExe, Arrays.asList("graph", "--bare", "--json-tree")));
PipFreeze pipFreeze = pipenvFreezeParser.parse(pipFreezeOutput.getStandardOutputAsList());
PipenvGraph pipenvGraph = pipEnvJsonGraphParser.parse(graphOutput.getStandardOutput());
CodeLocation codeLocation = pipenvTransformer.transform(projectName, projectVersionName, pipFreeze, pipenvGraph, includeOnlyProjectTree);
return new Extraction.Builder().projectName(projectName).projectVersion(projectVersionName).success(codeLocation).build();
} catch (Exception e) {
extraction = new Extraction.Builder().exception(e).build();
}
return extraction;
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class SwiftExtractor method extract.
public Extraction extract(File environmentDirectory, ExecutableTarget swiftExecutable) {
try {
toolVersionLogger.log(environmentDirectory, swiftExecutable);
SwiftPackage rootSwiftPackage = getRootSwiftPackage(environmentDirectory, swiftExecutable);
CodeLocation codeLocation = swiftPackageTransformer.transform(rootSwiftPackage);
return new Extraction.Builder().success(codeLocation).projectName(rootSwiftPackage.getName()).projectVersion(rootSwiftPackage.getVersion()).build();
} catch (IntegrationException | ExecutableRunnerException e) {
return new Extraction.Builder().exception(e).build();
}
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class XcodeSwiftExtractor method extract.
public Extraction extract(File foundPackageResolvedFile, File foundXcodeProjectFile) throws FileNotFoundException {
FileReader fileReader = new FileReader(foundPackageResolvedFile);
PackageResolved packageResolved = gson.fromJson(fileReader, PackageResolved.class);
if (packageResolved == null) {
// There are no dependencies to extract.
DependencyGraph dependencyGraph = new MutableMapDependencyGraph();
CodeLocation emptyCodeLocation = new CodeLocation(dependencyGraph, foundXcodeProjectFile);
return new Extraction.Builder().success(emptyCodeLocation).build();
}
packageResolvedFormatChecker.handleVersionCompatibility(packageResolved, (fileFormatVersion, knownVersions) -> logger.warn(String.format("The format version of Package.resolved (%s) is unknown to Detect, but will attempt to parse anyway. Known format versions are (%s).", fileFormatVersion, StringUtils.join(knownVersions, ", "))));
DependencyGraph dependencyGraph = packageResolvedTransformer.transform(packageResolved);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
return new Extraction.Builder().success(codeLocation).build();
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class BazelExtractor method generateCodelocation.
@NotNull
private CodeLocation generateCodelocation(Pipelines pipelines, Set<WorkspaceRule> workspaceRules) throws DetectableException, ExecutableFailedException {
List<Dependency> aggregatedDependencies = new ArrayList<>();
// Make sure the order of processing deterministic
List<WorkspaceRule> sortedWorkspaceRules = workspaceRules.stream().sorted(Comparator.naturalOrder()).collect(Collectors.toList());
for (WorkspaceRule workspaceRule : sortedWorkspaceRules) {
logger.info("Running processing pipeline for rule {}", workspaceRule);
List<Dependency> ruleDependencies = pipelines.get(workspaceRule).run();
logger.info("Number of dependencies discovered for rule {}: {}}", workspaceRule, ruleDependencies.size());
logger.debug("Dependencies discovered for rule {}: {}}", workspaceRule, ruleDependencies);
aggregatedDependencies.addAll(ruleDependencies);
}
DependencyGraph dependencyGraph = new BasicDependencyGraph();
dependencyGraph.addChildrenToRoot(aggregatedDependencies);
return new CodeLocation(dependencyGraph);
}
Aggregations