use of org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus in project sw360portal by sw360.
the class ComponentPortlet method updateAllVulnerabilities.
private void updateAllVulnerabilities(ResourceRequest request, ResourceResponse response) throws PortletException, IOException {
CveSearchService.Iface cveClient = thriftClients.makeCvesearchClient();
try {
VulnerabilityUpdateStatus importStatus = cveClient.fullUpdate();
JSONObject responseData = PortletUtils.importStatusToJSON(importStatus);
PrintWriter writer = response.getWriter();
writer.write(responseData.toString());
} catch (TException e) {
log.error("Error occurred with full update of CVEs in backend.", e);
}
}
use of org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus 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.cvesearch.VulnerabilityUpdateStatus in project sw360portal by sw360.
the class VulnerabilityConnector method addOrUpdate.
public VulnerabilityUpdateStatus addOrUpdate(Vulnerability vulnerability, ReleaseVulnerabilityRelation partiallyFilledRelation, VulnerabilityUpdateStatus currentVulnerabilityUpdateStatus) {
UpdateType updateType = addOrUpdate(vulnerability, partiallyFilledRelation);
currentVulnerabilityUpdateStatus.getStatusToVulnerabilityIds().get(updateType).add(vulnerability.getExternalId());
return currentVulnerabilityUpdateStatus;
}
use of org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus in project sw360portal by sw360.
the class CveSearchHandler method updateForRelease.
private VulnerabilityUpdateStatus updateForRelease(Release release) {
Optional<List<CveSearchData>> cveSearchDatas = cveSearchWrapper.searchForRelease(release);
if (!cveSearchDatas.isPresent()) {
return new VulnerabilityUpdateStatus().setRequestStatus(RequestStatus.FAILURE);
}
CveSearchDataTranslator cveSearchDataTranslator = new CveSearchDataTranslator();
List<CveSearchDataTranslator.VulnerabilityWithRelation> translated = cveSearchDatas.get().stream().map(cveSearchDataTranslator).map(vulnerabilityWithRelation -> {
vulnerabilityWithRelation.relation.setReleaseId(release.getId());
return vulnerabilityWithRelation;
}).collect(Collectors.toList());
VulnerabilityUpdateStatus updateStatus = getEmptyVulnerabilityUpdateStatus();
for (CveSearchDataTranslator.VulnerabilityWithRelation vulnerabilityWithRelation : translated) {
updateStatus = vulnerabilityConnector.addOrUpdate(vulnerabilityWithRelation.vulnerability, vulnerabilityWithRelation.relation, updateStatus);
}
return updateStatus;
}
use of org.eclipse.sw360.datahandler.thrift.cvesearch.VulnerabilityUpdateStatus in project sw360portal by sw360.
the class VulnerabilityUtils method reduceVulnerabilityUpdateStatus.
public static VulnerabilityUpdateStatus reduceVulnerabilityUpdateStatus(VulnerabilityUpdateStatus... statuses) {
VulnerabilityUpdateStatus resultStatus = getEmptyVulnerabilityUpdateStatus();
RequestStatus requestStatus = Arrays.stream(statuses).map(VulnerabilityUpdateStatus::getRequestStatus).reduce(RequestStatus.SUCCESS, CommonUtils::reduceRequestStatus);
resultStatus.setRequestStatus(requestStatus);
for (UpdateType updateType : UpdateType.values()) {
for (VulnerabilityUpdateStatus status : statuses) {
if (status.isSetStatusToVulnerabilityIds()) {
resultStatus.statusToVulnerabilityIds.get(updateType).addAll(nullToEmptyList(status.statusToVulnerabilityIds.get(updateType)));
}
}
}
return resultStatus;
}
Aggregations