Search in sources :

Example 1 with ComponentVersionVulnerabilities

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());
}
Also used : ComponentVersionVulnerabilities(com.synopsys.integration.blackduck.service.model.ComponentVersionVulnerabilities) SimpleBdioFactory(com.synopsys.integration.bdio.SimpleBdioFactory) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) ComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ComponentVersionView) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory) ComponentsView(com.synopsys.integration.blackduck.api.generated.response.ComponentsView) VulnerabilityView(com.synopsys.integration.blackduck.api.generated.view.VulnerabilityView) Test(org.junit.jupiter.api.Test)

Example 2 with ComponentVersionVulnerabilities

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;
}
Also used : ComponentVersionVulnerabilities(com.synopsys.integration.blackduck.service.model.ComponentVersionVulnerabilities) ArrayList(java.util.ArrayList) ProjectVersionComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView) ComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ComponentVersionView) HttpUrl(com.synopsys.integration.rest.HttpUrl) ProjectVersionComponentVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView)

Example 3 with ComponentVersionVulnerabilities

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);
}
Also used : ComponentVersionVulnerabilities(com.synopsys.integration.blackduck.service.model.ComponentVersionVulnerabilities) BlackDuckRequestBuilder(com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder) VulnerabilityView(com.synopsys.integration.blackduck.api.generated.view.VulnerabilityView)

Aggregations

ComponentVersionVulnerabilities (com.synopsys.integration.blackduck.service.model.ComponentVersionVulnerabilities)3 ComponentVersionView (com.synopsys.integration.blackduck.api.generated.view.ComponentVersionView)2 VulnerabilityView (com.synopsys.integration.blackduck.api.generated.view.VulnerabilityView)2 SimpleBdioFactory (com.synopsys.integration.bdio.SimpleBdioFactory)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 ComponentsView (com.synopsys.integration.blackduck.api.generated.response.ComponentsView)1 ProjectVersionComponentVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionComponentVersionView)1 BlackDuckRequestBuilder (com.synopsys.integration.blackduck.http.BlackDuckRequestBuilder)1 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)1 HttpUrl (com.synopsys.integration.rest.HttpUrl)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1