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);
}
}
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;
}
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());
}
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();
}
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));
}
Aggregations