You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536
  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. // +build gofuzz
  5. package fuzz
  6. import (
  7. "code.gitea.io/gitea/modules/markup"
  8. "code.gitea.io/gitea/modules/markup/markdown"
  9. )
  10. // Contains fuzzing functions executed by
  11. // fuzzing engine https://github.com/dvyukov/go-fuzz
  12. //
  13. // The function must return 1 if the fuzzer should increase priority of the given input during subsequent fuzzing
  14. // (for example, the input is lexically correct and was parsed successfully).
  15. // -1 if the input must not be added to corpus even if gives new coverage and 0 otherwise.
  16. func FuzzMarkdownRenderRaw(data []byte) int {
  17. _ = markdown.RenderRaw(data, "", false)
  18. return 1
  19. }
  20. func FuzzMarkupPostProcess(data []byte) int {
  21. var localMetas = map[string]string{
  22. "user": "go-gitea",
  23. "repo": "gitea",
  24. }
  25. _, err := markup.PostProcess(data, "https://example.com", localMetas, false)
  26. if err != nil {
  27. return 0
  28. }
  29. return 1
  30. }