use of org.eclipse.sw360.cvesearch.datasource.CveSearchData 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.cvesearch.datasource.CveSearchData in project sw360portal by sw360.
the class CveSearchJsonParserTest method singleFull_A.
@Test
public void singleFull_A() {
Object resultO = cveSearchJsonParserSingle.apply(toBufferedReader(SEARCH_RESULT_SINGLE_A));
CveSearchData result = (CveSearchData) resultO;
assert (result.getCvss() == 5.0);
assert ("CVE-2002-0438".equals(result.getId()));
Optional<Map.Entry<String, String>> vce = result.getVulnerable_configuration().entrySet().stream().findAny();
assert (vce.isPresent());
assert (vce.get().getKey().length() > 2);
assert (vce.get().getValue().length() > 2);
}
use of org.eclipse.sw360.cvesearch.datasource.CveSearchData in project sw360portal by sw360.
the class CveSearchJsonParserTest method setUp.
@Before
public void setUp() {
Type listTargetType = new TypeToken<List<CveSearchData>>() {
}.getType();
Type singleTargetType = new TypeToken<CveSearchData>() {
}.getType();
cveSearchJsonParserSingle = new CveSearchJsonParser(singleTargetType);
cveSearchJsonParserList = new CveSearchJsonParser(listTargetType);
}
use of org.eclipse.sw360.cvesearch.datasource.CveSearchData in project sw360portal by sw360.
the class CveSearchJsonParserTest method singleEmptyObj.
@Test
public void singleEmptyObj() {
Object resultO = cveSearchJsonParserSingle.apply(toBufferedReader(SEARCH_RESULT_EMPTYOBJ));
CveSearchData result = (CveSearchData) resultO;
}
use of org.eclipse.sw360.cvesearch.datasource.CveSearchData in project sw360portal by sw360.
the class CveSearchDataTranslatorTest method testWithApacheData.
@Test
public void testWithApacheData() throws IOException {
List<CveSearchData> cveSearchDatas = new CveSearchApiImpl(host).search("apache", ".*");
List<CveSearchDataTranslator.VulnerabilityWithRelation> vms = cveSearchDatas.stream().map(cveSearchData -> cveSearchDataTranslator.apply(cveSearchData)).collect(Collectors.toList());
assert (vms != null);
List<Vulnerability> vs = vms.stream().map(vm -> vm.vulnerability).collect(Collectors.toList());
assert (vs.size() > 700);
}
Aggregations