Skip to content

Commit

Permalink
bugfix: handle zero version event (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonaim authored Jul 11, 2022
1 parent 0f6aeb9 commit 0230f73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/vulnsrc/govulndb/govulndb.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ func (vs VulnSrc) commit(tx *bolt.Tx, item Entry) error {
if vulnerable != "" {
vulnerableVersions = append(vulnerableVersions, vulnerable)
}
if event.Introduced == "0" {
event.Introduced = "0.0.0-0"
}
vulnerable = fmt.Sprintf(">=%s", event.Introduced)
case event.Fixed != "":
// patched versions
Expand Down
5 changes: 3 additions & 2 deletions pkg/vulnsrc/govulndb/govulndb_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package govulndb_test

import (
"github.com/aquasecurity/trivy-db/pkg/vulnsrctest"
"testing"

"github.com/aquasecurity/trivy-db/pkg/vulnsrctest"

"github.com/aquasecurity/trivy-db/pkg/types"
"github.com/aquasecurity/trivy-db/pkg/vulnsrc/govulndb"
"github.com/aquasecurity/trivy-db/pkg/vulnsrc/vulnerability"
Expand Down Expand Up @@ -50,7 +51,7 @@ func TestVulnSrc_Update(t *testing.T) {
Key: []string{"advisory-detail", "CVE-2020-26160", "go::The Go Vulnerability Database", "github.com/dgrijalva/jwt-go/v4"},
Value: types.Advisory{
PatchedVersions: []string{"4.0.0-preview1"},
VulnerableVersions: []string{">=0, <4.0.0-preview1"},
VulnerableVersions: []string{">=0.0.0-0, <4.0.0-preview1"},
},
},
{
Expand Down

0 comments on commit 0230f73

Please sign in to comment.