use of com.synopsys.integration.detectable.detectable.result.DetectableResult in project synopsys-detect by blackducksoftware.
the class XcodeWorkspaceDetectable method extractable.
@Override
public DetectableResult extractable() {
Requirements requirements = new Requirements(fileFinder, environment);
File swiftPMDirectory = workspaceDirectory.toPath().resolve("xcshareddata/swiftpm").toFile();
requirements.anyFile(new SearchPattern(swiftPMDirectory, "Package.resolved", packageResolvedFile -> foundPackageResolvedFile = packageResolvedFile), new SearchPattern(workspaceDirectory, "contents.xcworkspacedata", workspaceDataFile -> foundWorkspaceDataFile = workspaceDataFile));
return requirements.result();
}
use of com.synopsys.integration.detectable.detectable.result.DetectableResult 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.result.DetectableResult in project synopsys-detect by blackducksoftware.
the class DetectableTool method initializeAndCheckForApplicable.
public boolean initializeAndCheckForApplicable(File sourcePath) {
// TODO: Move docker/bazel out of detectable and drop this notion of a detctable tool. Will simplify this logic and make this unneccessary.
logger.trace("Starting a detectable tool.");
this.sourcePath = sourcePath;
DetectableEnvironment detectableEnvironment = new DetectableEnvironment(sourcePath);
detectable = detectableCreatable.createDetectable(detectableEnvironment);
DetectableResult applicable = detectable.applicable();
if (!applicable.getPassed()) {
logger.debug("Was not applicable.");
return false;
}
logger.debug("Applicable passed.");
return true;
}
use of com.synopsys.integration.detectable.detectable.result.DetectableResult in project synopsys-detect by blackducksoftware.
the class PubDepsDetectableTest method testThrowExceptionWhenLockFilePresentButNotYaml.
@Test
public void testThrowExceptionWhenLockFilePresentButNotYaml() throws DetectableException {
FileFinder fileFinder = Mockito.mock(FileFinder.class);
Mockito.when(fileFinder.findFile(null, "pubspec.yaml")).thenReturn(null);
Mockito.when(fileFinder.findFile(null, "pubspec.lock")).thenReturn(new File(""));
DartPubDepDetectable dartPubDepDetectable = new DartPubDepDetectable(new DetectableEnvironment(null), fileFinder, null, null, null, null);
DetectableResult applicable = dartPubDepDetectable.applicable();
Assertions.assertTrue(applicable.getPassed());
DetectableResult extractable = dartPubDepDetectable.extractable();
Assertions.assertTrue(extractable instanceof FileNotFoundDetectableResult);
}
use of com.synopsys.integration.detectable.detectable.result.DetectableResult in project synopsys-detect by blackducksoftware.
the class DetectorToolTest method testExtractionException.
@Test
public void testExtractionException() throws DetectableException, ExecutableFailedException {
Extraction extraction = createExceptionExtraction();
DetectableResult extractionResult = new PassedDetectableResult();
String projectBomTool = DetectorType.GO_MOD.name();
DetectorToolResult result = executeToolTest(extraction, extractionResult, projectBomTool);
assertFalse(result.getApplicableDetectorTypes().isEmpty());
assertTrue(result.getBomToolCodeLocations().isEmpty());
assertFalse(result.getBomToolProjectNameVersion().isPresent());
assertTrue(result.getCodeLocationMap().isEmpty());
assertTrue(result.getFailedDetectorTypes().isEmpty());
assertTrue(result.getRootDetectorEvaluationTree().isPresent());
}
Aggregations