use of com.synopsys.integration.blackduck.service.model.ComponentVersionVulnerabilities in project blackduck-common by blackducksoftware.
the class VulnerabilityDataServiceTestIT method testGetCommonsFileUploadVulns.
@Test
public void testGetCommonsFileUploadVulns() throws Exception {
BlackDuckServicesFactory blackDuckServicesFactory = intHttpClientTestHelper.createBlackDuckServicesFactory();
ComponentService componentService = blackDuckServicesFactory.createComponentService();
SimpleBdioFactory simpleBdioFactory = new SimpleBdioFactory();
ExternalIdFactory externalIdFactory = simpleBdioFactory.getExternalIdFactory();
ExternalId commonsFileUploadExternalId = externalIdFactory.createMavenExternalId("commons-fileupload", "commons-fileupload", "1.2.2");
Optional<ComponentsView> searchResult = componentService.getFirstOrEmptyResult(commonsFileUploadExternalId);
Optional<ComponentVersionView> componentVersionView = componentService.getComponentVersionView(searchResult.get());
ComponentVersionVulnerabilities componentVersionVulnerabilities = componentService.getComponentVersionVulnerabilities(componentVersionView.get());
List<VulnerabilityView> vulnerabilities = componentVersionVulnerabilities.getVulnerabilities();
System.out.println(vulnerabilities);
assertNotNull(vulnerabilities);
assertFalse(vulnerabilities.isEmpty());
ExternalId integrationCommonExternalId = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "integration-common", "15.0.0");
searchResult = componentService.getFirstOrEmptyResult(integrationCommonExternalId);
componentVersionView = componentService.getComponentVersionView(searchResult.get());
componentVersionVulnerabilities = componentService.getComponentVersionVulnerabilities(componentVersionView.get());
vulnerabilities = componentVersionVulnerabilities.getVulnerabilities();
System.out.println(vulnerabilities);
assertNotNull(vulnerabilities);
assertTrue(vulnerabilities.isEmpty());
}
use of com.synopsys.integration.blackduck.service.model.ComponentVersionVulnerabilities in project blackduck-common by blackducksoftware.
the class ProjectBomService method getComponentVersionVulnerabilities.
public List<ComponentVersionVulnerabilities> getComponentVersionVulnerabilities(ProjectVersionView projectVersionView) throws IntegrationException {
List<ProjectVersionComponentVersionView> ProjectVersionComponentViews = getComponentsForProjectVersion(projectVersionView);
List<ComponentVersionView> componentVersionViews = new ArrayList<>();
for (ProjectVersionComponentVersionView projectVersionComponentVersionView : ProjectVersionComponentViews) {
if (StringUtils.isNotBlank(projectVersionComponentVersionView.getComponentVersion())) {
HttpUrl projectVersionComponentUrl = new HttpUrl(projectVersionComponentVersionView.getComponentVersion());
ComponentVersionView componentVersionView = blackDuckApiClient.getResponse(projectVersionComponentUrl, ComponentVersionView.class);
componentVersionViews.add(componentVersionView);
}
}
List<ComponentVersionVulnerabilities> componentVersionVulnerabilitiesList = new ArrayList<>();
for (ComponentVersionView componentVersionView : componentVersionViews) {
ComponentVersionVulnerabilities componentVersionVulnerabilities = componentService.getComponentVersionVulnerabilities(componentVersionView);
componentVersionVulnerabilitiesList.add(componentVersionVulnerabilities);
}
return componentVersionVulnerabilitiesList;
}
use of com.synopsys.integration.blackduck.service.model.ComponentVersionVulnerabilities in project blackduck-common by blackducksoftware.
the class ComponentService method getComponentVersionVulnerabilities.
public ComponentVersionVulnerabilities getComponentVersionVulnerabilities(ComponentVersionView componentVersion) throws IntegrationException {
BlackDuckRequestBuilder blackDuckRequestBuilder = new BlackDuckRequestBuilder().commonGet().acceptMimeType(BlackDuckMediaTypes.VULNERABILITY_REQUEST_SERVICE_V1);
BlackDuckMultipleRequest<VulnerabilityView> requestMultiple = blackDuckRequestBuilder.buildBlackDuckRequest(componentVersion.metaVulnerabilitiesLink());
List<VulnerabilityView> vulnerabilityList = blackDuckApiClient.getAllResponses(requestMultiple);
return new ComponentVersionVulnerabilities(componentVersion, vulnerabilityList);
}
Aggregations