Skip to content

Commit

Permalink
feat(ubuntu): Support Ubuntu 14.04 and 16.04 ESM (#1682)
Browse files Browse the repository at this point in the history
* feat(ubuntu): Support Ubuntu ESM

* Sort PackageFixStatuses to resolve the diff in integrationTest

* go mod update gost
  • Loading branch information
kotakanbe committed May 31, 2023
1 parent 6271ec5 commit 5a69804
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
github.com/vulsio/go-exploitdb v0.4.5
github.com/vulsio/go-kev v0.1.2
github.com/vulsio/go-msfdb v0.2.2
github.com/vulsio/gost v0.4.3
github.com/vulsio/gost v0.4.4
github.com/vulsio/goval-dictionary v0.9.2
go.etcd.io/bbolt v1.3.7
golang.org/x/exp v0.0.0-20230425010034-47ecfdc1ba53
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,8 @@ github.com/vulsio/go-kev v0.1.2 h1:ZWnRqXJy/PrfGs89s9W8ilgi/Qzfgb5x5R4knLdiSKo=
github.com/vulsio/go-kev v0.1.2/go.mod h1:xtrcsLfNO8xQI1jAjdIQell3/8ntCl8JBDd1fzEGPIk=
github.com/vulsio/go-msfdb v0.2.2 h1:rb82u++5QZyCjcTxqQLMHGe/Ngtp0SFCl4+VauY5DBM=
github.com/vulsio/go-msfdb v0.2.2/go.mod h1:lSpy43aBU6bdU09Kl+3531s2ihZbxdqw6hbTyqDzgIc=
github.com/vulsio/gost v0.4.3 h1:jr5HBRd7aPqChnFrW2zi0k9wJbng9Ss7P/IceEbP13A=
github.com/vulsio/gost v0.4.3/go.mod h1:HJJrb/9Q126yN5wDfwnkUVzRjOGotx1mllYDetLijDQ=
github.com/vulsio/gost v0.4.4 h1:nmYSaMjhW3V4gTtZ34O+/ZHSzXpLrhwO0EAHkCCmNgQ=
github.com/vulsio/gost v0.4.4/go.mod h1:HJJrb/9Q126yN5wDfwnkUVzRjOGotx1mllYDetLijDQ=
github.com/vulsio/goval-dictionary v0.9.2 h1:HTgCbrBsqDrI9lFb8CDpAdQrRaWr9BLG8IeQRHCAbmo=
github.com/vulsio/goval-dictionary v0.9.2/go.mod h1:SUhZkgjGkwdNyIJQRrXhQKbav3xaC8GEHqw3ojdVkrg=
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
Expand Down
1 change: 1 addition & 0 deletions gost/ubuntu.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ func (ubu Ubuntu) detect(cves map[string]gostmodels.UbuntuCVE, fixed bool, srcPk
}

if len(c.fixStatuses) > 0 {
c.fixStatuses.Sort()
contents = append(contents, c)
}
}
Expand Down
7 changes: 5 additions & 2 deletions models/vulninfos.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,13 @@ func (ps PackageFixStatuses) Store(pkg PackageFixStatus) PackageFixStatuses {
return ps
}

// Sort by Name
// Sort by Name asc, FixedIn desc
func (ps PackageFixStatuses) Sort() {
sort.Slice(ps, func(i, j int) bool {
return ps[i].Name < ps[j].Name
if ps[i].Name != ps[j].Name {
return ps[i].Name < ps[j].Name
}
return ps[j].FixedIn < ps[i].FixedIn
})
}

Expand Down
22 changes: 22 additions & 0 deletions models/vulninfos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,28 @@ func TestSortPackageStatues(t *testing.T) {
{Name: "b"},
},
},
{
in: PackageFixStatuses{
{
Name: "libzstd1",
FixedIn: "1.3.1+dfsg-1~ubuntu0.16.04.1+esm1",
},
{
Name: "libzstd1",
FixedIn: "1.3.1+dfsg-1~ubuntu0.16.04.1+esm2",
},
},
out: PackageFixStatuses{
{
Name: "libzstd1",
FixedIn: "1.3.1+dfsg-1~ubuntu0.16.04.1+esm2",
},
{
Name: "libzstd1",
FixedIn: "1.3.1+dfsg-1~ubuntu0.16.04.1+esm1",
},
},
},
}
for _, tt := range tests {
tt.in.Sort()
Expand Down

0 comments on commit 5a69804

Please sign in to comment.