FuzzCSWalk implements a fuzzer that targets contentStore.Walk()
(f *testing.F)
| 96 | |
| 97 | // FuzzCSWalk implements a fuzzer that targets contentStore.Walk() |
| 98 | func 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 | |
| 135 | func FuzzArchiveExport(f *testing.F) { |
| 136 | f.Fuzz(func(t *testing.T, data []byte) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…