From 09cbfe325b93f19aa05a946ab90d76296d2bd2f4 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Thu, 27 Apr 2017 18:57:19 -0400 Subject: [PATCH] ext/vulnsrc/oracle: ensure flag is largest elsa If the Oracle Linux directory is ever in the wrong order, this should ensure that the updaterFlag is always set the latest ELSA value. --- ext/vulnsrc/oracle/oracle.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ext/vulnsrc/oracle/oracle.go b/ext/vulnsrc/oracle/oracle.go index 30363416..bc112865 100644 --- a/ext/vulnsrc/oracle/oracle.go +++ b/ext/vulnsrc/oracle/oracle.go @@ -174,7 +174,7 @@ func (u *updater) Update(datastore database.Datastore) (resp vulnsrc.UpdateRespo // Set the flag if we found anything. if len(elsaList) > 0 { resp.FlagName = updaterFlag - resp.FlagValue = strconv.Itoa(elsaList[len(elsaList)-1]) + resp.FlagValue = strconv.Itoa(largest(elsaList)) } else { log.Debug("no Oracle Linux update.") } @@ -182,6 +182,15 @@ func (u *updater) Update(datastore database.Datastore) (resp vulnsrc.UpdateRespo return resp, nil } +func largest(list []int) (largest int) { + for _, element := range list { + if element > largest { + largest = element + } + } + return +} + func (u *updater) Clean() {} func parseELSA(ovalReader io.Reader) (vulnerabilities []database.Vulnerability, err error) {