MCPcopy
hub / github.com/containerd/containerd / FuzzCSWalk

Function FuzzCSWalk

contrib/fuzz/content_fuzz_test.go:98–133  ·  view source on GitHub ↗

FuzzCSWalk implements a fuzzer that targets contentStore.Walk()

(f *testing.F)

Source from the content-addressed store, hash-verified

96
97// FuzzCSWalk implements a fuzzer that targets contentStore.Walk()
98func FuzzCSWalk(f *testing.F) {
99 f.Fuzz(func(t *testing.T, data []byte) {
100 ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second)
101 defer cancel()
102 expected := map[digest.Digest]struct{}{}
103 found := map[digest.Digest]struct{}{}
104 tmpDir := t.TempDir()
105 cs, err := local.NewStore(tmpDir)
106 if err != nil {
107 return
108 }
109
110 f := fuzz.NewConsumer(data)
111 blobs, err := populateBlobStore(ctx, cs, f)
112 if err != nil {
113 return
114 }
115
116 for dgst := range blobs {
117 expected[dgst] = struct{}{}
118 }
119
120 if err := cs.Walk(ctx, func(bi content.Info) error {
121 found[bi.Digest] = struct{}{}
122 err = checkBlobPath(bi.Digest, tmpDir)
123 if err != nil {
124 return err
125 }
126 return nil
127 }); err != nil {
128 return
129 }
130
131 require.Equal(t, expected, found)
132 })
133}
134
135func FuzzArchiveExport(f *testing.F) {
136 f.Fuzz(func(t *testing.T, data []byte) {

Callers

nothing calls this directly

Calls 4

NewStoreFunction · 0.92
populateBlobStoreFunction · 0.70
checkBlobPathFunction · 0.70
WalkMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…