Skip to content

Commit 94415f7

Browse files
AdamKorcz6543silverwindzeripath
authored
Added 2 fuzzers (#13818)
* Added fuzzer Signed-off-by: AdamKorcz <[email protected]> * Added better fuzzer names Signed-off-by: AdamKorcz <[email protected]> * Moved fuzzer to /tools * Update tools/fuzz.go Co-authored-by: 6543 <[email protected]> * Update tools/fuzz.go * Update tools/fuzz.go Co-authored-by: silverwind <[email protected]> * Added tools to Makefile Co-authored-by: 6543 <[email protected]> Co-authored-by: silverwind <[email protected]> Co-authored-by: zeripath <[email protected]>
1 parent 0c5fca2 commit 94415f7

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ TAGS ?=
110110
TAGS_SPLIT := $(subst $(COMMA), ,$(TAGS))
111111
TAGS_EVIDENCE := $(MAKE_EVIDENCE_DIR)/tags
112112

113-
GO_DIRS := cmd integrations models modules routers build services vendor
113+
GO_DIRS := cmd integrations models modules routers build services vendor tools
114114
GO_SOURCES := $(wildcard *.go)
115115
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" -not -path modules/options/bindata.go -not -path modules/public/bindata.go -not -path modules/templates/bindata.go)
116116

tools/fuzz.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2020 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build gofuzz
6+
7+
package fuzz
8+
9+
import (
10+
"code.gitea.io/gitea/modules/markup"
11+
"code.gitea.io/gitea/modules/markup/markdown"
12+
)
13+
14+
// Contains fuzzing functions executed by
15+
// fuzzing engine https://github.com/dvyukov/go-fuzz
16+
//
17+
// The function must return 1 if the fuzzer should increase priority of the given input during subsequent fuzzing
18+
// (for example, the input is lexically correct and was parsed successfully).
19+
// -1 if the input must not be added to corpus even if gives new coverage and 0 otherwise.
20+
21+
func FuzzMarkdownRenderRaw(data []byte) int {
22+
_ = markdown.RenderRaw(data, "", false)
23+
return 1
24+
}
25+
26+
func FuzzMarkupPostProcess(data []byte) int {
27+
var localMetas = map[string]string{
28+
"user": "go-gitea",
29+
"repo": "gitea",
30+
}
31+
_, err := markup.PostProcess(data, "https://example.com", localMetas, false)
32+
if err != nil {
33+
return 0
34+
}
35+
return 1
36+
}

0 commit comments

Comments
 (0)