chore(deps): bump github.com/hashicorp/golang-lru from 0.5.4 to 2.0.1 (#3265)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: masahiro331 <m_fujimura@r.recruit.co.jp>
This commit is contained in:
dependabot[bot]
2022-12-25 12:39:26 +02:00
committed by GitHub
parent 5190f9566b
commit a66d3fe3f0
11 changed files with 36 additions and 36 deletions

10
go.mod
View File

@@ -43,7 +43,7 @@ require (
github.com/google/uuid v1.3.0
github.com/google/wire v0.5.0
github.com/hashicorp/go-getter v1.6.2
github.com/hashicorp/golang-lru v0.5.4
github.com/hashicorp/golang-lru/v2 v2.0.1
github.com/in-toto/in-toto-golang v0.5.0
github.com/knqyf263/go-apk-version v0.0.0-20200609155635-041fdbb8563f
github.com/knqyf263/go-deb-version v0.0.0-20190517075300-09fca494f03d
@@ -51,11 +51,11 @@ require (
github.com/kylelemons/godebug v1.1.0
github.com/mailru/easyjson v0.7.7
github.com/masahiro331/go-disk v0.0.0-20220919035250-c8da316f91ac
github.com/masahiro331/go-ebs-file v0.0.0-20221125181850-09c63351e38c
github.com/masahiro331/go-ext4-filesystem v0.0.0-20221016160854-4b40d7ee6193
github.com/masahiro331/go-ebs-file v0.0.0-20221225061409-5ef263bb2cc3
github.com/masahiro331/go-ext4-filesystem v0.0.0-20221225060520-c150f5eacfe1
github.com/masahiro331/go-mvn-version v0.0.0-20210429150710-d3157d602a08
github.com/masahiro331/go-vmdk-parser v0.0.0-20221124162251-5eeffd974e5a
github.com/masahiro331/go-xfs-filesystem v0.0.0-20221127135739-051c25f1becd
github.com/masahiro331/go-vmdk-parser v0.0.0-20221225061455-612096e4bbbd
github.com/masahiro331/go-xfs-filesystem v0.0.0-20221225060805-c02764233454
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/open-policy-agent/opa v0.44.1-0.20220927105354-00e835a7cc15
github.com/owenrumney/go-sarif/v2 v2.1.2

20
go.sum
View File

@@ -978,8 +978,8 @@ github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru/v2 v2.0.1 h1:5pv5N1lT1fjLg2VQ5KWc7kmucp2x/kvFOnxuVTqZ6x4=
github.com/hashicorp/golang-lru/v2 v2.0.1/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hcl/v2 v2.14.1 h1:x0BpjfZ+CYdbiz+8yZTQ+gdLO7IXvOut7Da+XJayx34=
@@ -1125,16 +1125,16 @@ github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kN
github.com/marstr/guid v1.1.0/go.mod h1:74gB1z2wpxxInTG6yaqA7KrtM0NZ+RbrcqDvYHefzho=
github.com/masahiro331/go-disk v0.0.0-20220919035250-c8da316f91ac h1:QyRucnGOLHJag1eB9CtuZwZk+/LpvTSYr5mnFLLFlgA=
github.com/masahiro331/go-disk v0.0.0-20220919035250-c8da316f91ac/go.mod h1:J7Vb0sf0JzOhT0uHTeCqO6dqP/ELVcQvQ6yQ/56ZRGw=
github.com/masahiro331/go-ebs-file v0.0.0-20221125181850-09c63351e38c h1:sBVxQbdRxqMoczqQYPxUwe3V3msmAUj9KPuPZRpD13k=
github.com/masahiro331/go-ebs-file v0.0.0-20221125181850-09c63351e38c/go.mod h1:5NOkqebMwu8UiOTSjwqam1Ykdr7fci52TVE2xDQnIiM=
github.com/masahiro331/go-ext4-filesystem v0.0.0-20221016160854-4b40d7ee6193 h1:1005OfmUUdBL4540DpkovaDrV+lkiEda7Nb/t792LEg=
github.com/masahiro331/go-ext4-filesystem v0.0.0-20221016160854-4b40d7ee6193/go.mod h1:X08d9nmB+eg7Gj2XWAOkiG8lbMFbgGXPsDKEvkFwyF8=
github.com/masahiro331/go-ebs-file v0.0.0-20221225061409-5ef263bb2cc3 h1:CCX8exCYIPHrMKba1KDhM37PxC3/amBUZXH8yoJOAMQ=
github.com/masahiro331/go-ebs-file v0.0.0-20221225061409-5ef263bb2cc3/go.mod h1:5NOkqebMwu8UiOTSjwqam1Ykdr7fci52TVE2xDQnIiM=
github.com/masahiro331/go-ext4-filesystem v0.0.0-20221225060520-c150f5eacfe1 h1:GBZZSY8xEoAf76ZOlxqKi/OMufpZnTxpTf7ectT1eNM=
github.com/masahiro331/go-ext4-filesystem v0.0.0-20221225060520-c150f5eacfe1/go.mod h1:X08d9nmB+eg7Gj2XWAOkiG8lbMFbgGXPsDKEvkFwyF8=
github.com/masahiro331/go-mvn-version v0.0.0-20210429150710-d3157d602a08 h1:AevUBW4cc99rAF8q8vmddIP8qd/0J5s/UyltGbp66dg=
github.com/masahiro331/go-mvn-version v0.0.0-20210429150710-d3157d602a08/go.mod h1:JOkBRrE1HvgTyjk6diFtNGgr8XJMtIfiBzkL5krqzVk=
github.com/masahiro331/go-vmdk-parser v0.0.0-20221124162251-5eeffd974e5a h1:R2wjAgJt2IwTqKfSDc4mJ0SIz66lIslqmAjW/Dmi5fE=
github.com/masahiro331/go-vmdk-parser v0.0.0-20221124162251-5eeffd974e5a/go.mod h1:5f7mCJGW9cJb8SDn3z8qodGxpMCOo8d/2nls/tiwRrw=
github.com/masahiro331/go-xfs-filesystem v0.0.0-20221127135739-051c25f1becd h1:jOFGJ9IFmR9jbm06nZzSR9xdd5clVbRcK55yGNhqMYM=
github.com/masahiro331/go-xfs-filesystem v0.0.0-20221127135739-051c25f1becd/go.mod h1:QKBZqdn6teT0LK3QhAf3K6xakItd1LonOShOEC44idQ=
github.com/masahiro331/go-vmdk-parser v0.0.0-20221225061455-612096e4bbbd h1:Y30EzvuoVp97b0unb/GOFXzBUKRXZXUN2e0wYmvC+ic=
github.com/masahiro331/go-vmdk-parser v0.0.0-20221225061455-612096e4bbbd/go.mod h1:5f7mCJGW9cJb8SDn3z8qodGxpMCOo8d/2nls/tiwRrw=
github.com/masahiro331/go-xfs-filesystem v0.0.0-20221225060805-c02764233454 h1:XHFL/6QXvGlsBZ6xZvLPSsQW5QIzrOnNUKgkjRo7KWo=
github.com/masahiro331/go-xfs-filesystem v0.0.0-20221225060805-c02764233454/go.mod h1:QKBZqdn6teT0LK3QhAf3K6xakItd1LonOShOEC44idQ=
github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=

View File

@@ -4,7 +4,7 @@ import (
"context"
"io"
lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/v2"
ebsfile "github.com/masahiro331/go-ebs-file"
"golang.org/x/xerrors"
@@ -77,7 +77,7 @@ func (a *EBS) Inspect(ctx context.Context) (types.ArtifactReference, error) {
}
func (a *EBS) openEBS(ctx context.Context) (*io.SectionReader, error) {
c, err := lru.New(storageEBSCacheSize)
c, err := lru.New[string, []byte](storageEBSCacheSize)
if err != nil {
return nil, xerrors.Errorf("lru cache error: %w", err)
}

View File

@@ -8,7 +8,7 @@ import (
"io"
"os"
lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/opencontainers/go-digest"
"golang.org/x/xerrors"
@@ -38,7 +38,7 @@ func newFile(filePath string, storage Storage) (*ImageFile, error) {
return nil, xerrors.Errorf("file open error: %w", err)
}
c, err := lru.New(storageFILECacheSize)
c, err := lru.New[string, []byte](storageFILECacheSize)
if err != nil {
return nil, xerrors.Errorf("failed to create new lru cache: %w", err)
}

View File

@@ -17,12 +17,13 @@ var (
// Disk defines virtual machine disk images like VMDK, VDI and VHD.
type Disk interface {
NewReader(rs io.ReadSeeker, cache vm.Cache) (*io.SectionReader, error)
NewReader(io.ReadSeeker, vm.Cache[string, []byte]) (*io.SectionReader, error)
}
func New(rs io.ReadSeeker, cache vm.Cache) (*io.SectionReader, error) {
for _, disk := range vmDisks {
vreader, err := disk.NewReader(rs, cache)
func New(rs io.ReadSeeker, cache vm.Cache[string, []byte]) (*io.SectionReader, error) {
for _, vmdisk := range vmDisks {
var vreader, err = vmdisk.NewReader(rs, cache)
if err != nil {
if errors.Is(err, vm.ErrInvalidSignature) {
continue

View File

@@ -15,7 +15,7 @@ import (
func TestNew(t *testing.T) {
type args struct {
rs io.ReadSeeker
cache vm.Cache
cache vm.Cache[string, []byte]
}
tests := []struct {
name string

View File

@@ -12,7 +12,7 @@ import (
type VMDK struct{}
func (V VMDK) NewReader(rs io.ReadSeeker, cache vm.Cache) (*io.SectionReader, error) {
func (V VMDK) NewReader(rs io.ReadSeeker, cache vm.Cache[string, []byte]) (*io.SectionReader, error) {
if _, err := rs.Seek(0, io.SeekStart); err != nil {
return nil, xerrors.Errorf("seek error: %w", err)
}

View File

@@ -12,7 +12,7 @@ import (
type EXT4 struct{}
func (e EXT4) New(sr io.SectionReader, cache vm.Cache) (fs.FS, error) {
func (e EXT4) New(sr io.SectionReader, cache vm.Cache[string, any]) (fs.FS, error) {
_, err := sr.Seek(0, io.SeekStart)
if err != nil {
return nil, xerrors.Errorf("failed to seek offset error: %w", err)

View File

@@ -5,7 +5,7 @@ import (
"io"
"io/fs"
lru "github.com/hashicorp/golang-lru"
lru "github.com/hashicorp/golang-lru/v2"
"golang.org/x/xerrors"
"github.com/aquasecurity/trivy/pkg/fanal/vm"
@@ -14,23 +14,22 @@ import (
const cacheSize = 2048
var (
filesystems = []Filesystem{
ErrInvalidHeader = xerrors.New("invalid Header error")
filesystems = []Filesystem{
EXT4{},
XFS{},
}
ErrInvalidHeader = xerrors.New("invalid Header error")
)
type Filesystem interface {
New(sr io.SectionReader, cache vm.Cache) (fs.FS, error)
New(io.SectionReader, vm.Cache[string, any]) (fs.FS, error)
}
func New(sr io.SectionReader) (fs.FS, func(), error) {
var clean func()
// Initialize LRU cache for filesystem walking
lruCache, err := lru.New(cacheSize)
lruCache, err := lru.New[string, any](cacheSize)
if err != nil {
return nil, clean, xerrors.Errorf("failed to create a LRU cache: %w", err)
}

View File

@@ -12,7 +12,7 @@ import (
type XFS struct{}
func (x XFS) New(sr io.SectionReader, cache vm.Cache) (fs.FS, error) {
func (x XFS) New(sr io.SectionReader, cache vm.Cache[string, any]) (fs.FS, error) {
_, err := sr.Seek(0, io.SeekStart)
if err != nil {
return nil, xerrors.Errorf("failed to seek offset error: %w", err)

View File

@@ -9,10 +9,10 @@ var (
ErrUnsupportedType = xerrors.New("unsupported type error")
)
type Cache interface {
type Cache[K comparable, V any] interface {
// Add stores data in the cache
Add(key, value interface{}) bool
Add(key K, value V) (evicted bool)
// Get returns key's value from the cache
Get(key interface{}) (value interface{}, ok bool)
Get(key K) (value V, ok bool)
}