From 3c40c660fd14da07dadbf72c60c9851ca2858605 Mon Sep 17 00:00:00 2001 From: DmitriyLewen <91113035+DmitriyLewen@users.noreply.github.com> Date: Wed, 23 Nov 2022 15:10:35 +0600 Subject: [PATCH] fix(go-vulndb): skip error, if broken several modules (#184) --- go-vulndb/govulndb.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/go-vulndb/govulndb.go b/go-vulndb/govulndb.go index e396ca0..f75113a 100644 --- a/go-vulndb/govulndb.go +++ b/go-vulndb/govulndb.go @@ -2,21 +2,23 @@ package govulndb import ( "encoding/json" + "fmt" + "golang.org/x/xerrors" "log" "net/url" "os" "path" "path/filepath" - - "golang.org/x/xerrors" + "strings" "github.com/aquasecurity/vuln-list-update/utils" ) const ( - vulndbURL = "https://storage.googleapis.com/go-vulndb" - vulndbDir = "go" - retry = 3 + vulndbURL = "https://storage.googleapis.com/go-vulndb" + vulndbDir = "go" + retry = 3 + notFoundError = "HTTP error. status code: 404" ) type options struct { @@ -123,6 +125,10 @@ func (c VulnDB) parseModuleEntries(baseURL *url.URL, moduleName string) ([]Entry res, err := utils.FetchURL(pkgURL.String(), "", c.retry) if err != nil { + if strings.Contains(err.Error(), notFoundError) { + log.Println(fmt.Sprintf("module %s not found", moduleName)) + return nil, nil + } return nil, xerrors.Errorf("unable to query %s advisory: %w", moduleName, err) }