Skip to content

Commit f91616e

Browse files
author
Kazuyoshi Kato
committed
Copy FuzzConvertManifest from cncf/cncf-fuzzing
This test is one of the noisiest and should be moved from cncf/cncf-fuzzing first. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent c9c5fee commit f91616e

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

integration/client/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ require (
2020
)
2121

2222
require (
23+
github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8 // indirect
2324
github.com/Microsoft/go-winio v0.5.2 // indirect
2425
github.com/blang/semver v3.5.1+incompatible // indirect
2526
github.com/cilium/ebpf v0.7.0 // indirect

integration/client/go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl
3838
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
3939
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
4040
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
41+
github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8 h1:V8krnnfGj4pV65YLUm3C0/8bl7V5Nry2Pwvy3ru/wLc=
4142
github.com/AdaLogics/go-fuzz-headers v0.0.0-20210715213245-6c3934b029d8/go.mod h1:CzsSbkDixRphAF5hS6wbMKq0eI6ccJRb7/A0M6JBnwg=
4243
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=
4344
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=

remotes/docker/converter_fuzz.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//go:build gofuzz
2+
// +build gofuzz
3+
4+
/*
5+
Copyright The containerd Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
*/
19+
20+
package docker
21+
22+
import (
23+
"context"
24+
"os"
25+
26+
fuzz "github.com/AdaLogics/go-fuzz-headers"
27+
"github.com/containerd/containerd/content/local"
28+
"github.com/containerd/containerd/log"
29+
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
30+
"github.com/sirupsen/logrus"
31+
)
32+
33+
func FuzzConvertManifest(data []byte) int {
34+
ctx := context.Background()
35+
36+
// Do not log the message below
37+
// level=warning msg="do nothing for media type: ..."
38+
log.G(ctx).Logger.SetLevel(logrus.PanicLevel)
39+
40+
f := fuzz.NewConsumer(data)
41+
desc := ocispec.Descriptor{}
42+
err := f.GenerateStruct(&desc)
43+
if err != nil {
44+
return 0
45+
}
46+
tmpdir, err := os.MkdirTemp("", "fuzzing-")
47+
if err != nil {
48+
return 0
49+
}
50+
cs, err := local.NewStore(tmpdir)
51+
if err != nil {
52+
return 0
53+
}
54+
_, _ = ConvertManifest(ctx, cs, desc)
55+
return 1
56+
}

0 commit comments

Comments
 (0)