Skip to content

Commit e41f180

Browse files
XapiMaknqyf263
authored andcommitted
Use go-deb-version for version validation (fanal#17)
1 parent b7debf7 commit e41f180

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

analyzer/pkg/apk/apk.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import (
77

88
"github.com/pkg/errors"
99

10-
"github.com/coreos/clair/ext/versionfmt"
11-
clairDpkg "github.com/coreos/clair/ext/versionfmt/dpkg"
12-
1310
"github.com/knqyf263/fanal/analyzer"
1411
"github.com/knqyf263/fanal/extractor"
12+
13+
debVersion "github.com/knqyf263/go-deb-version"
1514
)
1615

1716
func init() {
@@ -59,7 +58,7 @@ func (a alpinePkgAnalyzer) parseApkInfo(scanner *bufio.Scanner) (pkgs []analyzer
5958
pkg.Name = line[2:]
6059
case "V:":
6160
version = string(line[2:])
62-
if err = versionfmt.Valid(clairDpkg.ParserName, version); err != nil {
61+
if !debVersion.Valid(version) {
6362
log.Printf("Invalid Version Found : OS %s, Package %s, Version %s", "alpine", pkg.Name, version)
6463
continue
6564
}

analyzer/pkg/dpkg/dpkg.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@ import (
1010
mapset "github.com/deckarep/golang-set"
1111
"golang.org/x/xerrors"
1212

13-
"github.com/coreos/clair/ext/versionfmt"
14-
"github.com/coreos/clair/ext/versionfmt/dpkg"
15-
clairDpkg "github.com/coreos/clair/ext/versionfmt/dpkg"
1613
"github.com/knqyf263/fanal/analyzer"
1714
"github.com/knqyf263/fanal/extractor"
15+
16+
debVersion "github.com/knqyf263/go-deb-version"
1817
)
1918

2019
var (
@@ -115,7 +114,7 @@ func (a debianPkgAnalyzer) parseDpkgPkg(scanner *bufio.Scanner) (pkg *analyzer.P
115114

116115
if name == "" || version == "" {
117116
return nil
118-
} else if err := versionfmt.Valid(clairDpkg.ParserName, version); err != nil {
117+
} else if !debVersion.Valid(version) {
119118
log.Printf("Invalid Version Found : OS %s, Package %s, Version %s", "debian", name, version)
120119
return nil
121120
}
@@ -135,7 +134,7 @@ func (a debianPkgAnalyzer) parseDpkgPkg(scanner *bufio.Scanner) (pkg *analyzer.P
135134
sourceVersion = version
136135
}
137136

138-
if err := versionfmt.Valid(dpkg.ParserName, sourceVersion); err != nil {
137+
if !debVersion.Valid(sourceVersion) {
139138
log.Printf("Invalid Version Found : OS %s, Package %s, Version %s", "debian", sourceName, sourceVersion)
140139
return pkg
141140
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ require (
44
cloud.google.com/go v0.37.4 // indirect
55
github.com/GoogleCloudPlatform/docker-credential-gcr v1.5.0
66
github.com/aws/aws-sdk-go v1.19.11
7-
github.com/coreos/clair v0.0.0-20180919182544-44ae4bc9590a
87
github.com/deckarep/golang-set v1.7.1
98
github.com/docker/distribution v0.0.0-20180920194744-16128bbac47f
109
github.com/docker/docker v0.0.0-20180924202107-a9c061deec0f
1110
github.com/docker/go-connections v0.4.0 // indirect
1211
github.com/genuinetools/reg v0.16.0
12+
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d
1313
github.com/knqyf263/go-dep-parser v0.0.0-20190515172517-b8305876c9c2
1414
github.com/knqyf263/go-rpmdb v0.0.0-20190501070121-10a1c42a10dc
1515
github.com/knqyf263/nested v0.0.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V
9393
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
9494
github.com/knqyf263/berkeleydb v0.0.0-20190501065933-fafe01fb9662 h1:UGS0RbPHwXJkq8tcba8OD0nvVUWLf2h7uUJznuHPPB0=
9595
github.com/knqyf263/berkeleydb v0.0.0-20190501065933-fafe01fb9662/go.mod h1:bu1CcN4tUtoRcI/B/RFHhxMNKFHVq/c3SV+UTyduoXg=
96+
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d h1:X4cedH4Kn3JPupAwwWuo4AzYp16P0OyLO9d7OnMZc/c=
97+
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d/go.mod h1:o8sgWoz3JADecfc/cTYD92/Et1yMqMy0utV1z+VaZao=
9698
github.com/knqyf263/go-dep-parser v0.0.0-20190515172517-b8305876c9c2 h1:bQGj8WH6X4czC2FlkgUKKFq2xPnJovzf61T4Yl9sVZs=
9799
github.com/knqyf263/go-dep-parser v0.0.0-20190515172517-b8305876c9c2/go.mod h1:gSiqSkOFPstUZu/qZ4wnNJS69PtQQnPl397vxKHJ5mQ=
98100
github.com/knqyf263/go-rpmdb v0.0.0-20190501070121-10a1c42a10dc h1:pumO9pqmRAjvic6oove22RGh9wDZQnj96XQjJSbSEPs=

0 commit comments

Comments
 (0)