From 8e98ee878ac324888855c35597fb6bea2ba84369 Mon Sep 17 00:00:00 2001 From: Eric Sim Date: Tue, 11 Dec 2018 17:11:56 -0800 Subject: [PATCH] Add 2xx checks for mirror.list and repomd.xml --- ext/vulnsrc/amzn/amzn.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ext/vulnsrc/amzn/amzn.go b/ext/vulnsrc/amzn/amzn.go index 678737f3..b458d9c3 100644 --- a/ext/vulnsrc/amzn/amzn.go +++ b/ext/vulnsrc/amzn/amzn.go @@ -173,6 +173,11 @@ func (u *updater) getUpdateInfoURI() (updateInfoURI string, err error) { } defer mirrorListResponse.Body.Close() + if !httputil.Status2xx(mirrorListResponse) { + log.WithField("StatusCode", mirrorListResponse.StatusCode).Error("could not download mirror list") + return updateInfoURI, commonerr.ErrCouldNotDownload + } + // Parse the URI of the first mirror. scanner := bufio.NewScanner(mirrorListResponse.Body) success := scanner.Scan() @@ -190,6 +195,11 @@ func (u *updater) getUpdateInfoURI() (updateInfoURI string, err error) { } defer repoMdResponse.Body.Close() + if !httputil.Status2xx(repoMdResponse) { + log.WithField("StatusCode", repoMdResponse.StatusCode).Error("could not download repomd.xml") + return updateInfoURI, commonerr.ErrCouldNotDownload + } + // Decode repomd.xml. var repoMd RepoMd err = xml.NewDecoder(repoMdResponse.Body).Decode(&repoMd)