MCPcopy
hub / github.com/containerd/containerd / FuzzArchiveExport

Function FuzzArchiveExport

contrib/fuzz/content_fuzz_test.go:135–163  ·  view source on GitHub ↗
(f *testing.F)

Source from the content-addressed store, hash-verified

133}
134
135func FuzzArchiveExport(f *testing.F) {
136 f.Fuzz(func(t *testing.T, data []byte) {
137 f := fuzz.NewConsumer(data)
138 manifest := ocispec.Descriptor{}
139 err := f.GenerateStruct(&manifest)
140 if err != nil {
141 return
142 }
143 ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second)
144 defer cancel()
145 tmpDir := t.TempDir()
146 cs, err := local.NewStore(tmpDir)
147 if err != nil {
148 return
149 }
150 _, err = populateBlobStore(ctx, cs, f)
151 if err != nil {
152 return
153 }
154
155 // use `t.TempDir` to clean up temp dir and files
156 w, err := os.CreateTemp(t.TempDir(), "fuzz-output-file")
157 if err != nil {
158 return
159 }
160 defer w.Close()
161 _ = archive.Export(ctx, cs, w, archive.WithManifest(manifest, "name"))
162 })
163}

Callers

nothing calls this directly

Calls 5

NewStoreFunction · 0.92
ExportFunction · 0.92
WithManifestFunction · 0.92
populateBlobStoreFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…