mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-23 07:29:00 -08:00
cache: Switch to Raw encoding.
This commit also switches zstd to use SpeedDefault. Signed-off-by: Simarpreet Singh <simar@linux.com>
This commit is contained in:
@@ -101,7 +101,7 @@ func NewDockerExtractor(option types.DockerOption) (Extractor, error) {
|
||||
return NewDockerExtractorWithCache(option, bolt.Options{
|
||||
RootBucketName: "fanal",
|
||||
Path: utils.CacheDir() + "/cache.db", // TODO: Make this configurable via a public method
|
||||
Codec: encoding.Gob,
|
||||
Codec: encoding.Raw,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ func (d Extractor) SaveLocalImage(ctx context.Context, imageName string) (io.Rea
|
||||
return nil, xerrors.Errorf("failed to read saved image: %w", err)
|
||||
}
|
||||
|
||||
e, err := zstd.NewWriter(nil, zstd.WithEncoderLevel(zstd.SpeedDefault))
|
||||
e, err := zstd.NewWriter(nil, zstd.WithEncoderLevel(zstd.SpeedFastest))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -420,7 +420,7 @@ func getFilteredTarballBuffer(tr *tar.Reader, requiredFilenames []string) (bytes
|
||||
func (d Extractor) storeLayerInCache(cacheBuf bytes.Buffer, dig digest.Digest) {
|
||||
// compress tar to zstd before storing to cache
|
||||
var dst bytes.Buffer
|
||||
w, _ := zstd.NewWriter(&dst)
|
||||
w, _ := zstd.NewWriter(&dst, zstd.WithEncoderLevel(zstd.SpeedFastest))
|
||||
_, _ = io.Copy(w, &cacheBuf)
|
||||
_ = w.Close()
|
||||
|
||||
|
||||
BIN
extractor/docker/testdata/testdir.tar.zstd
vendored
BIN
extractor/docker/testdata/testdir.tar.zstd
vendored
Binary file not shown.
2
go.mod
2
go.mod
@@ -19,7 +19,7 @@ require (
|
||||
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348
|
||||
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/simar7/gokv v0.3.2
|
||||
github.com/simar7/gokv v0.3.3-0.20191216080237-ab4446a6841b
|
||||
github.com/stretchr/testify v1.4.0
|
||||
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
|
||||
|
||||
9
go.sum
9
go.sum
@@ -60,6 +60,7 @@ github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw
|
||||
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4=
|
||||
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
|
||||
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
|
||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
|
||||
@@ -173,12 +174,8 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z
|
||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
|
||||
github.com/shurcooL/httpfs v0.0.0-20181222201310-74dc9339e414/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
|
||||
github.com/simar7/gokv v0.1.0 h1:5DoScIR7r6w6DCJPXFlSGKU2SOmpLeSfZkINVyVaPmI=
|
||||
github.com/simar7/gokv v0.1.0/go.mod h1:vixfnOzH16g5QN5Uij1q4zSVbNp3iJu2D6xgIPM4ZSE=
|
||||
github.com/simar7/gokv v0.3.2 h1:UAcjZs5nsoAKyGxHMOJgGZs7Q9Yeub40Gb54YRW1Fo8=
|
||||
github.com/simar7/gokv v0.3.2/go.mod h1:jXjPspRkuCDCRTRBgfGsfXvW8ofOGh3Y+tjZvoFr7XU=
|
||||
github.com/simar7/gokv v0.3.3-0.20191213063627-21f89164966d h1:lsqk9OujJz7FwE7pP7ZMjH2pWaGO4QPSPEJ7JSsuOO8=
|
||||
github.com/simar7/gokv v0.3.3-0.20191213063627-21f89164966d/go.mod h1:jXjPspRkuCDCRTRBgfGsfXvW8ofOGh3Y+tjZvoFr7XU=
|
||||
github.com/simar7/gokv v0.3.3-0.20191216080237-ab4446a6841b h1:2qPkc0Hnrd6IhlxioXb0RG/NBmIPx2b5y9Z1IKriuxQ=
|
||||
github.com/simar7/gokv v0.3.3-0.20191216080237-ab4446a6841b/go.mod h1:jXjPspRkuCDCRTRBgfGsfXvW8ofOGh3Y+tjZvoFr7XU=
|
||||
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
|
||||
|
||||
Reference in New Issue
Block a user