Cve { public static final String extractCveIdentifier(String _string) { if (_string == null) return null; final Matcher m = CVE_PATTERN.matcher(_string.toUpperCase()); if (m.matches()) return m.group(1); else return null; } Cve(); String getId(); void setId(String id); java.util.Calendar getPublished(); void setPublished(java.util.Calendar published); java.util.Calendar getModified(); void setModified(java.util.Calendar modified); Float getCvssScore(); void setCvssScore(Float cvss); String getCvssVersion(); void setCvssVersion(String cvssVersion); String getCvssVector(); void setCvssVector(String cvssVector); String getSummary(); void setSummary(String summary); @Override String toString(); static final String extractCveIdentifier(String _string); static final String CVE_REGEX; static final Pattern CVE_PATTERN; }
@Test public void testExtractCveIdentifier() { assertEquals("CVE-2014-0050", Cve.extractCveIdentifier("cVe-2014-0050")); assertEquals("CVE-2014-0050", Cve.extractCveIdentifier("cVe-2014-0050a")); assertEquals(null, Cve.extractCveIdentifier("cVe-2014-000a")); assertEquals("CVE-2014-005001010", Cve.extractCveIdentifier("cVe-2014-005001010-Foo")); assertEquals(null, Cve.extractCveIdentifier("Foo-cVe-2014-0050a")); }