Skip to content

Commit 25d45e1

Browse files
authored
fix(alpine): replace go-deb-version with go-apk-version (#520)
* fix(alpine): add a failing test with go-deb-version * fix(alpine): replace go-deb-version with go-apk-version * chore(mod): update dependencies * chore(mod): update go-apk-version
1 parent 298ba99 commit 25d45e1

File tree

4 files changed

+53
-1
lines changed

4 files changed

+53
-1
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
github.com/google/go-containerregistry v0.0.0-20200331213917-3d03ed9b1ca2
1616
github.com/google/go-github/v28 v28.1.1
1717
github.com/google/wire v0.3.0
18+
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f
1819
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d
1920
github.com/knqyf263/go-rpm-version v0.0.0-20170716094938-74609b86c936
2021
github.com/knqyf263/go-version v1.1.1

go.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
272272
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
273273
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
274274
github.com/knqyf263/berkeleydb v0.0.0-20190501065933-fafe01fb9662/go.mod h1:bu1CcN4tUtoRcI/B/RFHhxMNKFHVq/c3SV+UTyduoXg=
275+
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f h1:GvCU5GXhHq+7LeOzx/haG7HSIZokl3/0GkoUFzsRJjg=
276+
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f/go.mod h1:q59u9px8b7UTj0nIjEjvmTWekazka6xIt6Uogz5Dm+8=
275277
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d h1:X4cedH4Kn3JPupAwwWuo4AzYp16P0OyLO9d7OnMZc/c=
276278
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d/go.mod h1:o8sgWoz3JADecfc/cTYD92/Et1yMqMy0utV1z+VaZao=
277279
github.com/knqyf263/go-rpm-version v0.0.0-20170716094938-74609b86c936 h1:HDjRqotkViMNcGMGicb7cgxklx8OwnjtCBmyWEqrRvM=
@@ -427,6 +429,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
427429
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
428430
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
429431
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
432+
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
430433
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
431434
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
432435
github.com/testcontainers/testcontainers-go v0.3.1 h1:KZkEKNfnlsipJblzGCz6fmzd+0DzJ3djulYrislG3Zw=

pkg/detector/ospkg/alpine/alpine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"strings"
55
"time"
66

7-
version "github.com/knqyf263/go-deb-version"
7+
version "github.com/knqyf263/go-apk-version"
88
"golang.org/x/xerrors"
99

1010
ftypes "github.com/aquasecurity/fanal/types"

pkg/detector/ospkg/alpine/alpine_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,54 @@ func TestScanner_Detect(t *testing.T) {
153153
},
154154
},
155155
},
156+
{
157+
name: "contain pre",
158+
args: args{
159+
osVer: "3.12",
160+
pkgs: []ftypes.Package{
161+
{
162+
Name: "test",
163+
Version: "0.1.0_alpha",
164+
Layer: ftypes.Layer{
165+
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
166+
},
167+
},
168+
},
169+
},
170+
mocks: mocks{
171+
get: []get{
172+
{
173+
input: getInput{
174+
osVer: "3.12",
175+
pkgName: "test",
176+
},
177+
output: getOutput{
178+
advisories: []dbTypes.Advisory{
179+
{
180+
VulnerabilityID: "CVE-2030-0001",
181+
FixedVersion: "0.1.0_alpha_pre2",
182+
},
183+
{
184+
VulnerabilityID: "CVE-2030-0002",
185+
FixedVersion: "0.1.0_alpha2",
186+
},
187+
},
188+
},
189+
},
190+
},
191+
},
192+
want: []types.DetectedVulnerability{
193+
{
194+
VulnerabilityID: "CVE-2030-0002",
195+
PkgName: "test",
196+
InstalledVersion: "0.1.0_alpha",
197+
FixedVersion: "0.1.0_alpha2",
198+
Layer: ftypes.Layer{
199+
DiffID: "sha256:932da51564135c98a49a34a193d6cd363d8fa4184d957fde16c9d8527b3f3b02",
200+
},
201+
},
202+
},
203+
},
156204
{
157205
name: "Get returns an error",
158206
args: args{

0 commit comments

Comments
 (0)