improve ruby comparison version check. (#552)

* Implemented ruby comparison version check.

* Added semver package to validate and check version

* Added more tests

* Replaced go-version with semver

* Removing go-version from dependency

* Added check for ruby gem version format

* Updated semver model and patch rewrite process

* Refactoring
This commit is contained in:
rahul2393
2020-07-19 20:33:56 +05:30
committed by GitHub
parent 43085a80bc
commit 6eebed33b2
13 changed files with 196 additions and 30 deletions

View File

@@ -8,11 +8,12 @@ import (
"github.com/google/wire"
"github.com/Masterminds/semver/v3"
"github.com/aquasecurity/trivy/pkg/log"
"github.com/knqyf263/go-version"
"golang.org/x/xerrors"
"github.com/aquasecurity/trivy/pkg/scanner/utils"
"github.com/aquasecurity/trivy/pkg/types"
)
@@ -54,7 +55,7 @@ func detect(driver Driver, libs []ftypes.LibraryInfo) ([]types.DetectedVulnerabi
log.Logger.Infof("Detecting %s vulnerabilities...", driver.Type())
var vulnerabilities []types.DetectedVulnerability
for _, lib := range libs {
v, err := version.NewVersion(lib.Library.Version)
v, err := semver.NewVersion(utils.FormatPatchVersion(lib.Library.Version))
if err != nil {
log.Logger.Debugf("invalid version, library: %s, version: %s, error: %s\n",
lib.Library.Name, lib.Library.Version, err)