-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuzz: lay down the foundation for continuous fuzzing
- Loading branch information
1 parent
afd1541
commit 3f66cb5
Showing
10 changed files
with
424 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# Mutilated beyond recognition from the example at: | ||
# https://docs.microsoft.com/azure/devops/pipelines/languages/go | ||
|
||
trigger: | ||
- v2 | ||
|
||
strategy: | ||
matrix: | ||
linux: | ||
imageName: ubuntu-16.04 | ||
gorootDir: /usr/local | ||
mac: | ||
imageName: macos-10.13 | ||
gorootDir: /usr/local | ||
windows: | ||
imageName: windows-2019 | ||
gorootDir: C:\ | ||
|
||
pool: | ||
vmImage: $(imageName) | ||
|
||
variables: | ||
GOROOT: $(gorootDir)/go | ||
GOPATH: $(system.defaultWorkingDirectory)/gopath | ||
GOBIN: $(GOPATH)/bin | ||
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' | ||
# TODO: modules should be the default in Go 1.13, so this won't be needed | ||
GO111MODULE: on | ||
|
||
steps: | ||
- bash: | | ||
latestGo=$(curl "https://golang.org/VERSION?m=text") | ||
echo "##vso[task.setvariable variable=LATEST_GO]$latestGo" | ||
echo "Latest Go version: $latestGo" | ||
displayName: "Get latest Go version" | ||
|
||
- bash: | | ||
sudo rm -f $(which go) | ||
echo '##vso[task.prependpath]$(GOBIN)' | ||
echo '##vso[task.prependpath]$(GOROOT)/bin' | ||
mkdir -p '$(modulePath)' | ||
shopt -s extglob | ||
shopt -s dotglob | ||
mv !(gopath) '$(modulePath)' | ||
displayName: Remove old Go, set GOBIN/GOROOT, and move project into GOPATH | ||
|
||
# Install Go (this varies by platform) | ||
|
||
- bash: | | ||
wget "https://dl.google.com/go/$(LATEST_GO).linux-amd64.tar.gz" | ||
sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).linux-amd64.tar.gz" | ||
condition: eq( variables['Agent.OS'], 'Linux' ) | ||
displayName: Install Go on Linux | ||
|
||
- bash: | | ||
wget "https://dl.google.com/go/$(LATEST_GO).darwin-amd64.tar.gz" | ||
sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).darwin-amd64.tar.gz" | ||
condition: eq( variables['Agent.OS'], 'Darwin' ) | ||
displayName: Install Go on macOS | ||
|
||
- powershell: | | ||
Write-Host "Downloading Go... (please be patient, I am very slow)" | ||
(New-Object System.Net.WebClient).DownloadFile("https://dl.google.com/go/$(LATEST_GO).windows-amd64.zip", "$(LATEST_GO).windows-amd64.zip") | ||
Write-Host "Extracting Go... (I'm slow too)" | ||
Expand-Archive "$(LATEST_GO).windows-amd64.zip" -DestinationPath "$(gorootDir)" | ||
condition: eq( variables['Agent.OS'], 'Windows_NT' ) | ||
displayName: Install Go on Windows | ||
|
||
# TODO: When this issue is fixed, replace with installer script: | ||
# https://github.com/golangci/golangci-lint/issues/472 | ||
- script: go get -v github.com/golangci/golangci-lint/cmd/golangci-lint | ||
displayName: Install golangci-lint | ||
|
||
- bash: | | ||
printf "Using go at: $(which go)\n" | ||
printf "Go version: $(go version)\n" | ||
printf "\n\nGo environment:\n\n" | ||
go env | ||
printf "\n\nSystem environment:\n\n" | ||
env | ||
displayName: Print Go version and environment | ||
|
||
- script: | | ||
go get -v -t -d ./... | ||
# temporary disable golangci-lint | ||
#golangci-lint run -E gofmt -E goimports -E misspell | ||
go test -race ./... | ||
workingDirectory: '$(modulePath)' | ||
displayName: Run tests | ||
|
||
- bash: | | ||
# Install Clang-9 | ||
sudo echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main" >> /etc/apt/sources.list | ||
sudo echo "deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial main" >> /etc/apt/sources.list | ||
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key| apt-key add - | ||
sudo apt update && sudo apt install -y clang-9 lldb-9 lld-9 | ||
go get -v github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build | ||
wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.24/fuzzit_Linux_x86_64 | ||
chmod a+x fuzzit | ||
mv fuzzit $(GOBIN) | ||
displayName: Download go-fuzz tools and the Fuzzit CLI, and move Fuzzit CLI to GOBIN | ||
condition: eq( variables['Agent.OS'], 'Linux' ) | ||
|
||
# Uncomment once configuration is validated | ||
# - script: fuzzit auth $FUZZIT_API_KEY | ||
# condition: eq( variables['Agent.OS'], 'Linux' ) | ||
# env: | ||
# FUZZIT_API_KEY: $(FUZZIT_API_KEY) | ||
|
||
- bash: | | ||
go mod vendor | ||
rm -rf gopath | ||
mkdir -p gopath/src/ | ||
mv vendor/*/ gopath/src/ | ||
rm -rf vendor | ||
export GOPATH=$PWD/gopath | ||
export GO111MODULES=off | ||
for f in $(find . -maxdepth 1 -name \*_fuzz.go); do | ||
FUZZ_FILENAME_PREFIX=$(echo $f | awk -F '/' '{printf $NF}' - | awk -F '_' '{printf $1}' -) | ||
go-fuzz-build -func "Fuzz${FUZZ_FILENAME_PREFIX[@]^}" -libfuzzer -o "${FUZZ_FILENAME_PREFIX}_fuzz.a" $f | ||
clang-9 -fsanitize=fuzzer "${FUZZ_FILENAME_PREFIX}_fuzz.a" -o "${FUZZ_FILENAME_PREFIX}.fuzzer" | ||
#fuzzit create job --type 'regression' --branch "PR-${System.PullRequest.PullRequestNumber}" caddyserver/$f ${f}.fuzzer | ||
done | ||
rm -rf gopath/ *.a *.fuzzer | ||
workingDirectory: '$(modulePath)/fuzz' | ||
condition: eq( variables['Agent.OS'], 'Linux' ) | ||
displayName: Generate fuzzers & submit them to Fuzzit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Fuzz Submodule | ||
|
||
At the time of writing, [go-fuzz isn't compatible with Go modules](https://github.com/dvyukov/go-fuzz/issues/195). This workaround is adapted from [mvdan's](https://github.com/mvdan) work as described in [this comment](https://github.com/dvyukov/go-fuzz/issues/195#issuecomment-523526736) and implemented [here](https://github.com/mvdan/sh/commit/6c13161a56af5dece4e33497e909ee4cbe3ee6bf). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2015 Matthew Holt and The Caddy Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// +build gofuzz | ||
// +build gofuzz_libfuzzer | ||
|
||
package fuzz | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/caddyserver/caddy/v2" | ||
|
||
// This package is required for go-fuzz-build, so pin it here for | ||
// 'go mod vendor' to include it. | ||
_ "github.com/dvyukov/go-fuzz/go-fuzz-dep" | ||
) | ||
|
||
func FuzzAdmin(data []byte) (score int) { | ||
err := caddy.Load(bytes.NewReader(data)) | ||
if err != nil { | ||
return 0 | ||
} | ||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module local.tld/fuzz | ||
|
||
go 1.12 | ||
|
||
replace github.com/caddyserver/caddy/v2 => ./.. | ||
|
||
require ( | ||
github.com/caddyserver/caddy/v2 v2.0.0-00010101000000-000000000000 | ||
github.com/dvyukov/go-fuzz v0.0.0-20190819180756-98cec4f75045 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= | ||
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg= | ||
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= | ||
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc= | ||
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= | ||
github.com/Masterminds/sprig v2.20.0+incompatible h1:dJTKKuUkYW3RMFdQFXPU/s6hg10RgctmTjRcbZ98Ap8= | ||
github.com/Masterminds/sprig v2.20.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= | ||
github.com/andybalholm/brotli v0.0.0-20190704151324-71eb68cc467c/go.mod h1:+lx6/Aqd1kLJ1GQfkvOnaZ1WGmLpMpbprPuIOOZX30U= | ||
github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY= | ||
github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | ||
github.com/dvyukov/go-fuzz v0.0.0-20190819180756-98cec4f75045 h1:ik3KETxXrXa3cGhagpheF8MGbPYPnh/sZ4lWwYc4IUw= | ||
github.com/dvyukov/go-fuzz v0.0.0-20190819180756-98cec4f75045/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= | ||
github.com/go-acme/lego v2.5.0+incompatible/go.mod h1:yzMNe9CasVUhkquNvti5nAtPmG94USbYxYrZfTkIn0M= | ||
github.com/go-acme/lego v2.6.0+incompatible h1:KxcEWOF5hKtgou4xIqPaXSRF9DoO4OJ90ndwdK6YH/k= | ||
github.com/go-acme/lego v2.6.0+incompatible/go.mod h1:yzMNe9CasVUhkquNvti5nAtPmG94USbYxYrZfTkIn0M= | ||
github.com/golang/gddo v0.0.0-20190419222130-af0f2af80721/go.mod h1:xEhNfoBDX1hzLm2Nf80qUvZ2sVwoMZ8d6IE2SrsQfh4= | ||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= | ||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= | ||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= | ||
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= | ||
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= | ||
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= | ||
github.com/klauspost/compress v1.7.1-0.20190613161414-0b31f265a57b/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= | ||
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= | ||
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= | ||
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= | ||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | ||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||
github.com/mholt/certmagic v0.6.2 h1:yy9cKm3rtxdh12SW4E51lzG3Eo6N59LEOfBQ0CTnMms= | ||
github.com/mholt/certmagic v0.6.2/go.mod h1:g4cOPxcjV0oFq3qwpjSA30LReKD8AoIfwAY9VvG35NY= | ||
github.com/miekg/dns v1.1.3 h1:1g0r1IvskvgL8rR+AcHzUA+oFmGcQlaIm4IqakufeMM= | ||
github.com/miekg/dns v1.1.3/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= | ||
github.com/mitchellh/go-ps v0.0.0-20170309133038-4fdf99ab2936/go.mod h1:r1VsdOzOPt1ZSrGZWFoNhsAedKnEd6r9Np1+5blZCWk= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/rs/cors v1.6.0 h1:G9tHG9lebljV9mfp9SNPDL36nCDxmo3zTlAf1YgvzmI= | ||
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= | ||
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= | ||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= | ||
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= | ||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= | ||
github.com/starlight-go/starlight v0.0.0-20181207205707-b06f321544f3 h1:/fBh1Ot84ILt/ociFHO98wJ9LxIMA3UG8B0unUJPFpY= | ||
github.com/starlight-go/starlight v0.0.0-20181207205707-b06f321544f3/go.mod h1:pxOc2ZuBV+CNlQgzq/HJ9Z9G/eoEMHFeuGohOvva4Co= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | ||
go.starlark.net v0.0.0-20190604130855-6ddc71c0ba77 h1:KPzANX1mXqnSWenqVWkSTsQWiaUSpTY5GyGZKI6lStw= | ||
go.starlark.net v0.0.0-20190604130855-6ddc71c0ba77/go.mod h1:c1/X6cHgvdXj6pUlmWKMkuqRnW4K8x2vwt6JAaaircg= | ||
golang.org/x/crypto v0.0.0-20190123085648-057139ce5d2b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= | ||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65 h1:+rhAzEzT3f4JtomfC371qB+0Ola2caSKcY69NUBZrRQ= | ||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= | ||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= | ||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= | ||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 h1:SvFZT6jyqRaOeXpc5h/JSfZenJ2O330aBsf7JfSUXmQ= | ||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/square/go-jose.v2 v2.2.2 h1:orlkJ3myw8CN1nVQHBFfloD+L3egixIa4FvUP6RosSA= | ||
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2015 Matthew Holt and The Caddy Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// +build gofuzz | ||
// +build gofuzz_libfuzzer | ||
|
||
package fuzz | ||
|
||
import ( | ||
"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile" | ||
|
||
// This package is required for go-fuzz-build, so pin it here for | ||
// 'go mod vendor' to include it. | ||
_ "github.com/dvyukov/go-fuzz/go-fuzz-dep" | ||
) | ||
|
||
func ParseAddressFuzz(data []byte) int { | ||
addr, err := httpcaddyfile.ParseAddress(string(data)) | ||
if err != nil { | ||
if addr == (httpcaddyfile.Address{}) { | ||
return 1 | ||
} | ||
return 0 | ||
} | ||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2015 Matthew Holt and The Caddy Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// +build gofuzz | ||
// +build gofuzz_libfuzzer | ||
|
||
package fuzz | ||
|
||
import ( | ||
"bytes" | ||
|
||
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile" | ||
|
||
// This package is required for go-fuzz-build, so pin it here for | ||
// 'go mod vendor' to include it. | ||
_ "github.com/dvyukov/go-fuzz/go-fuzz-dep" | ||
) | ||
|
||
func FuzzParse(data []byte) (score int) { | ||
sb, err := caddyfile.Parse("Caddyfile", bytes.NewReader(data)) | ||
if err != nil { | ||
// if both an error is received and some ServerBlocks, | ||
// then the parse was able to parse partially. Mark this | ||
// result as interesting to push the fuzzer further through the parser. | ||
if sb != nil && len(sb) > 0 { | ||
return 1 | ||
} | ||
return 0 | ||
} | ||
return 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2015 Matthew Holt and The Caddy Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// +build gofuzz | ||
// +build gofuzz_libfuzzer | ||
|
||
package fuzz | ||
|
||
import ( | ||
"github.com/caddyserver/caddy/v2" | ||
|
||
// This package is required for go-fuzz-build, so pin it here for | ||
// 'go mod vendor' to include it. | ||
_ "github.com/dvyukov/go-fuzz/go-fuzz-dep" | ||
) | ||
|
||
func FuzzReplacer(data []byte) (score int) { | ||
caddy.NewReplacer().ReplaceAll(string(data), "") | ||
return 0 | ||
} |
Oops, something went wrong.