diff --git a/updater/fetchers/apps/apps_test.go b/updater/fetchers/apps/apps_test.go index 572f01e..c84fe89 100644 --- a/updater/fetchers/apps/apps_test.go +++ b/updater/fetchers/apps/apps_test.go @@ -32,21 +32,16 @@ func TestRubyAffectedVersion(t *testing.T) { func TestOpensslVulVersion(t *testing.T) { lines := []string{ - "", - "", - "", - "", + "
  • from 1.0.1 before 1.0.1u
  • ", + "
  • from 1.0.2 before 1.0.2i
  • \n
  • from 1.0.4 before 1.0.5d
  • ", } affected := [][]common.AppModuleVersion{ []common.AppModuleVersion{ - {"lt", "3.2.2"}, {"gteq", "3.2.0"}, {"orlt", "3.1.6"}, {"gteq", "3.1.0"}, - {"orlt", "3.0.14"}, {"gteq", "3.0.0"}, {"orlt", "1.1.1y"}, {"gteq", "1.1.1"}}, + {"gteq", "1.0.1"}, {"lt", "1.0.1u"}, + }, []common.AppModuleVersion{ - {"lt", "0.9.8h"}, {"gteq", "0.9.8f"}}, - []common.AppModuleVersion{ - {"lt", "fips-1.1.2"}, {"gteq", "fips-1.1.1"}}, - []common.AppModuleVersion{ - {"lt", "0.9.8j"}, {"gteq", "0.9.8"}}, + {"gteq", "1.0.2"}, {"lt", "1.0.2i"}, {"gteq", "1.0.4"}, {"orlt", "1.0.5d"}, + }, } for i, line := range lines { diff --git a/updater/fetchers/apps/openssl.go b/updater/fetchers/apps/openssl.go index 102e987..26cb978 100644 --- a/updater/fetchers/apps/openssl.go +++ b/updater/fetchers/apps/openssl.go @@ -20,8 +20,9 @@ const ( var cveNameRegexp = regexp.MustCompile(`="(.*)">CVE-([0-9\-]+)`) var fixedVerRegexp = regexp.MustCompile(`Fixed in OpenSSL\s*\n*([0-9a-z\.\-\s]+)`) var affectedVerRegexp = regexp.MustCompile(`\(Affected\s+([0-9a-z\.\-,\s]+)\s*\)`) -var verRegexp = regexp.MustCompile(`Fixed in OpenSSL\s*\n*([0-9a-z\.\-\s]+).*?\(Affected\s+([0-9a-z\.\-,\s]+)\s*\)`) // ungreedy -var severityRegexp = regexp.MustCompile(`[[a-zA-Z]+ severity]`) +var verRegexp = regexp.MustCompile(`
  • from\s*\n*([0-9a-z\.\-\s]+) before\s*\n*([0-9a-z\.\-\s]+)<\/li>`) // ungreedy +var severityRegexp = regexp.MustCompile(`
    Severity<\/dt>[\S+\n\r\s]+
    ([a-zA-Z]+)<\/dd>`) +var descriptionRegexp = regexp.MustCompile(`

    ([a-zA-Z[\S+\n\r\s]+)<\/p>`) // FetchUpdate gets vulnerability updates from the openssl. func opensslUpdate() error { @@ -70,21 +71,14 @@ func opensslUpdate() error { match = severityRegexp.FindAllStringSubmatch(line, -1) if len(match) > 0 { - s := match[0] - severityStr := strings.Split(s[0], " ")[0] - severityStr = strings.Replace(severityStr, "[", "", 1) - severity = severityStr + severity = match[0][1] } else { continue } - a0 := strings.Index(line, "

    ") - a1 := strings.Index(line, "