Search in sources :

Example 1 with CVEReference

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

the class CveSearchDataToVulnerabilityTranslator method getCVEReferencesForCVE.

protected Set<CVEReference> getCVEReferencesForCVE(String cve) {
    Set<CVEReference> cveReferences = new HashSet<>();
    String[] cveParts = cve.split("-");
    if (cveParts.length < 3) {
        return null;
    }
    cveReferences.add(new CVEReference().setYear(cveParts[1]).setNumber(cveParts[2]));
    return cveReferences;
}
Also used : CVEReference(org.eclipse.sw360.datahandler.thrift.vulnerabilities.CVEReference) HashSet(java.util.HashSet)

Example 2 with CVEReference

use of org.eclipse.sw360.datahandler.thrift.vulnerabilities.CVEReference 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()));
}
Also used : CVEReference(org.eclipse.sw360.datahandler.thrift.vulnerabilities.CVEReference) Vulnerability(org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability) Test(org.junit.Test)

Example 3 with CVEReference

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

the class CveSearchDataTranslatorTest method getCVEReferenceForCveSearchdataTest.

@Test
public void getCVEReferenceForCveSearchdataTest() {
    Set<CVEReference> cveReferences = cveSearchDataToVulnerabilityTranslator.getCVEReferencesForCVE(CVE);
    assert (1 == cveReferences.size());
    CVEReference cveReference = cveReferences.stream().findAny().get();
    assert (CVEYEAR.equals(cveReference.getYear()));
    assert (CVENUMBER.equals(cveReference.getNumber()));
}
Also used : CVEReference(org.eclipse.sw360.datahandler.thrift.vulnerabilities.CVEReference) Test(org.junit.Test)

Aggregations

CVEReference (org.eclipse.sw360.datahandler.thrift.vulnerabilities.CVEReference)3 Test (org.junit.Test)2 HashSet (java.util.HashSet)1 Vulnerability (org.eclipse.sw360.datahandler.thrift.vulnerabilities.Vulnerability)1