use of org.eclipse.sw360.cvesearch.datasource.CveSearchData in project sw360portal by sw360.
the class CveSearchJsonParserTest method testDateParser2_2.
@Test
public void testDateParser2_2() {
long dateAsLong = 1299534616563L;
String json = "{\"Modified\": { \"$date\": " + dateAsLong + "}}";
Object resultO = cveSearchJsonParserSingle.apply(toBufferedReader(json));
CveSearchData result = (CveSearchData) resultO;
assert (result.getModified() != null);
assert (result.getModified().length() > 0);
assert (result.getModified().startsWith("2011-03-07T"));
}
use of org.eclipse.sw360.cvesearch.datasource.CveSearchData in project sw360portal by sw360.
the class CveSearchJsonParserTest method testDateParser2_1.
@Test
public void testDateParser2_1() {
String date = "2011-03-07T21:50:16.563-05:00";
String json = "{\"Modified\": \"" + date + "\"}";
Object resultO = cveSearchJsonParserSingle.apply(toBufferedReader(json));
CveSearchData result = (CveSearchData) resultO;
assert (result.getModified() != null);
assert (result.getModified().length() > 0);
assert (date.equals(result.getModified()));
}
use of org.eclipse.sw360.cvesearch.datasource.CveSearchData in project sw360portal by sw360.
the class CveSearchJsonParserTest method singleFull_B.
@Test
public void singleFull_B() {
Object resultO = cveSearchJsonParserSingle.apply(toBufferedReader(SEARCH_RESULT_SINGLE_B));
CveSearchData result = (CveSearchData) resultO;
assert (result.getCvss() == 5.0);
assert ("CVE-2002-0438".equals(result.getId()));
assert (result.getVulnerable_configuration().size() == 6);
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);
assert (!vce.get().getKey().equals(vce.get().getValue()));
}
use of org.eclipse.sw360.cvesearch.datasource.CveSearchData in project sw360portal by sw360.
the class CveSearchDataTranslatorTest method testIdTranslation.
@Test
public void testIdTranslation() {
Vulnerability v = cveSearchDataTranslator.apply(cveSearchData).vulnerability;
Set<CVEReference> cveReferences = v.getCveReferences();
assert (cveReferences.size() == 1);
CVEReference cveReference = cveReferences.stream().findAny().get();
assert (CVEYEAR.equals(cveReference.getYear()));
assert ((CVENUMBER + ID).equals(cveReference.getNumber()));
}
use of org.eclipse.sw360.cvesearch.datasource.CveSearchData in project sw360portal by sw360.
the class CveSearchDataToVulnerabilityTranslator method apply.
@Override
public Vulnerability apply(CveSearchData cveSearchData) {
Vulnerability vulnerability = new Vulnerability().setTitle(cveSearchData.getId()).setCveReferences(getCVEReferencesForCveSearchdata(cveSearchData)).setDescription(cveSearchData.getSummary()).setPublishDate(cveSearchData.getPublished()).setLastExternalUpdate(cveSearchData.getModified()).setReferences(cveSearchData.getReferences()).setExternalId(cveSearchData.getId()).setImpact(cveSearchData.getImpact()).setAccess(cveSearchData.getAccess()).setVulnerableConfiguration(cveSearchData.getVulnerable_configuration()).setCwe(cveSearchData.getCwe()).setCveFurtherMetaDataPerSource(cveSearchData.getMap_cve_all());
if (cveSearchData.getCvss() != null) {
vulnerability.setIsSetCvss(true);
vulnerability.setCvss(cveSearchData.getCvss());
vulnerability.setCvssTime(cveSearchData.getCvss_time());
}
return vulnerability;
}
Aggregations