Skip to content

Commit 906d8cc

Browse files
authored
Rewrite fuzzers to native Go harnesses (#22313)
1 parent f41ad34 commit 906d8cc

File tree

2 files changed

+38
-50
lines changed

2 files changed

+38
-50
lines changed

tools/fuzz.go

Lines changed: 0 additions & 50 deletions
This file was deleted.

tools/fuzz_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package main
5+
6+
import (
7+
"bytes"
8+
"context"
9+
"io"
10+
"testing"
11+
12+
"code.gitea.io/gitea/modules/markup"
13+
"code.gitea.io/gitea/modules/markup/markdown"
14+
"code.gitea.io/gitea/modules/setting"
15+
)
16+
17+
var renderContext = markup.RenderContext{
18+
Ctx: context.Background(),
19+
URLPrefix: "https://example.com/go-gitea/gitea",
20+
Metas: map[string]string{
21+
"user": "go-gitea",
22+
"repo": "gitea",
23+
},
24+
}
25+
26+
func FuzzMarkdownRenderRaw(f *testing.F) {
27+
f.Fuzz(func(t *testing.T, data []byte) {
28+
setting.AppURL = "http://localhost:3000/"
29+
markdown.RenderRaw(&renderContext, bytes.NewReader(data), io.Discard)
30+
})
31+
}
32+
33+
func FuzzMarkupPostProcess(f *testing.F) {
34+
f.Fuzz(func(t *testing.T, data []byte) {
35+
setting.AppURL = "http://localhost:3000/"
36+
markup.PostProcess(&renderContext, bytes.NewReader(data), io.Discard)
37+
})
38+
}

0 commit comments

Comments
 (0)