Search in sources :

Example 1 with Vulnerability

use of org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability in project sw360portal by sw360.

the class Sw360VulnerabilityService method getVulnerabilityWithReleaseRelationsByExternalId.

public Vulnerability getVulnerabilityWithReleaseRelationsByExternalId(String externalId, User sw360User) {
    try {
        VulnerabilityService.Iface sw360VulnerabilityClient = getThriftVulnerabilityClient();
        final VulnerabilityWithReleaseRelations vulWithRel = sw360VulnerabilityClient.getVulnerabilityWithReleaseRelationsByExternalId(externalId, sw360User);
        return vulWithRel.getVulnerability();
    } catch (TException e) {
        throw new RuntimeException(e);
    }
}
Also used : VulnerabilityWithReleaseRelations(org.eclipse.sw360.datahandler.thrift.vulnerabilities.VulnerabilityWithReleaseRelations) TException(org.apache.thrift.TException) VulnerabilityService(org.eclipse.sw360.datahandler.thrift.vulnerabilities.VulnerabilityService)

Example 2 with Vulnerability

use of org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability in project sw360portal by sw360.

the class VulnerabilityDTOResourceProcessor method process.

@Override
public Resource process(Resource<VulnerabilityDTO> resource) {
    VulnerabilityDTO vulnerability = resource.getContent();
    Link selfLink = linkTo(VulnerabilityController.class).slash("api" + VulnerabilityController.VULNERABILITIES_URL + "/" + vulnerability.getExternalId()).withSelfRel();
    resource.add(selfLink);
    return resource;
}
Also used : VulnerabilityDTO(org.eclipse.sw360.datahandler.thrift.vulnerabilities.VulnerabilityDTO) Link(org.springframework.hateoas.Link)

Example 3 with Vulnerability

use of org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability in project sw360portal by sw360.

the class ProjectPortlet method updateVulnerabilityRating.

private void updateVulnerabilityRating(ResourceRequest request, ResourceResponse response) throws IOException {
    String projectId = request.getParameter(PortalConstants.PROJECT_ID);
    User user = UserCacheHolder.getUserFromRequest(request);
    VulnerabilityService.Iface vulClient = thriftClients.makeVulnerabilityClient();
    RequestStatus requestStatus = RequestStatus.FAILURE;
    try {
        Optional<ProjectVulnerabilityRating> projectVulnerabilityRatings = wrapThriftOptionalReplacement(vulClient.getProjectVulnerabilityRatingByProjectId(projectId, user));
        ProjectVulnerabilityRating link = ProjectPortletUtils.updateProjectVulnerabilityRatingFromRequest(projectVulnerabilityRatings, request);
        requestStatus = vulClient.updateProjectVulnerabilityRating(link, user);
    } catch (TException e) {
        log.error("Error updating vulnerability ratings for project in backend.", e);
    }
    JSONObject responseData = JSONFactoryUtil.createJSONObject();
    responseData.put(PortalConstants.REQUEST_STATUS, requestStatus.toString());
    PrintWriter writer = response.getWriter();
    writer.write(responseData.toString());
}
Also used : WrappedTException(org.eclipse.sw360.datahandler.common.WrappedException.WrappedTException) TException(org.apache.thrift.TException) User(org.eclipse.sw360.datahandler.thrift.users.User) JSONFactoryUtil.createJSONObject(com.liferay.portal.kernel.json.JSONFactoryUtil.createJSONObject) JSONObject(com.liferay.portal.kernel.json.JSONObject) PrintWriter(java.io.PrintWriter)

Example 4 with Vulnerability

use of org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability in project sw360portal by sw360.

the class CveSearchHandler method update.

@Override
public RequestStatus update() throws TException {
    log.info("Starting CveSearch update...");
    VulnerabilityUpdateStatus vulnerabilityUpdateStatus = fullUpdate();
    log.info("CveSearch update finished with status:" + vulnerabilityUpdateStatus.getRequestStatus());
    log.info("The following vulnerability/ies could not be imported:" + vulnerabilityUpdateStatus.getStatusToVulnerabilityIds().get(UpdateType.FAILED) + "\n" + "The following vulnerability/ies were updated:" + vulnerabilityUpdateStatus.getStatusToVulnerabilityIds().get(UpdateType.UPDATED) + "\n" + "The following vulnerability/ies were added:" + vulnerabilityUpdateStatus.getStatusToVulnerabilityIds().get(UpdateType.NEW));
    return vulnerabilityUpdateStatus.getRequestStatus();
}
Also used : VulnerabilityUpdateStatus(org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus)

Example 5 with Vulnerability

use of org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability in project sw360portal by sw360.

the class VulnerabilityConnectorTest method testIsMoreRecentFirstNull.

@Test
public void testIsMoreRecentFirstNull() throws Exception {
    Vulnerability v1 = new Vulnerability();
    Vulnerability v2 = new Vulnerability().setLastExternalUpdate("2016");
    assertThat(vulnerabilityConnector.isMoreRecent(v1, v2), is(true));
}
Also used : Vulnerability(org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability) Test(org.junit.Test)

Aggregations

Vulnerability (org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability)28 Test (org.junit.Test)15 UpdateType (org.eclipse.sw360.datahandler.thrift.cvesearch.UpdateType)10 User (org.eclipse.sw360.datahandler.thrift.users.User)8 TException (org.apache.thrift.TException)6 VulnerabilityService (org.eclipse.sw360.datahandler.thrift.vulnerabilities.VulnerabilityService)5 ReleaseVulnerabilityRelation (org.eclipse.sw360.datahandler.thrift.vulnerabilities.ReleaseVulnerabilityRelation)4 JSONObject (com.liferay.portal.kernel.json.JSONObject)3 PrintWriter (java.io.PrintWriter)3 VulnerabilityUpdateStatus (org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus)3 Before (org.junit.Before)3 IOException (java.io.IOException)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 Collectors (java.util.stream.Collectors)2 CommonUtils (org.eclipse.sw360.datahandler.common.CommonUtils)2 PortletUtils.getVerificationState (org.eclipse.sw360.portal.common.PortletUtils.getVerificationState)2 ResponseEntity (org.springframework.http.ResponseEntity)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1