fix(go-vulndb): skip error, if broken several modules (#184)

This commit is contained in:
DmitriyLewen 2022-11-23 15:10:35 +06:00 committed by GitHub
parent 32b738cf73
commit 3c40c660fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,13 +2,14 @@ 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"
)
@ -17,6 +18,7 @@ const (
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)
}