Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
fuzz: introduce continuous fuzzing for Caddy (#2723)
* fuzz: lay down the foundation for continuous fuzzing * improve the fuzzers and add some * fuzz: add Fuzzit badge to README & enable fuzzers submission in CI * v2-fuzz: do away with the submodule approach for fuzzers * fuzz: enable fuzzit
Mohammed Al Sahaf committed
Oct 26, 2019 at 03:52 UTC
2fbe2ff40be616712cf4edaac286629add268e0a
9 files changed
+394
-133
README.md
+1
@@ -2,6 +2,7 @@ Caddy 2 Development Branch
2
===========================
3
4
[](https://dev.azure.com/mholt-dev/Caddy/_build/latest?definitionId=5&branchName=v2)
5
+[](https://app.fuzzit.dev/orgs/caddyserver/dashboard)
6
7
This is the development branch for Caddy 2. This code (version 2) is not yet feature-complete or production-ready, but is already being used in production, and we encourage you to deploy it today on sites that are not very visible or important so that it can obtain crucial experience in the field.
8
admin_fuzz.go
new
+30
@@ -0,0 +1,30 @@
1
+// Copyright 2015 Matthew Holt and The Caddy Authors
2
+//
3
+// Licensed under the Apache License, Version 2.0 (the "License");
4
+// you may not use this file except in compliance with the License.
5
+// You may obtain a copy of the License at
6
+//
7
+// http://www.apache.org/licenses/LICENSE-2.0
8
+//
9
+// Unless required by applicable law or agreed to in writing, software
10
+// distributed under the License is distributed on an "AS IS" BASIS,
11
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+// See the License for the specific language governing permissions and
13
+// limitations under the License.
14
+
15
+// +build gofuzz
16
+// +build gofuzz_libfuzzer
17
+
18
+package caddy
19
+
20
+import (
21
+ "bytes"
22
+)
23
+
24
+func FuzzAdmin(data []byte) (score int) {
25
+ err := Load(bytes.NewReader(data))
26
+ if err != nil {
27
+ return 0
28
+ }
29
+ return 1
30
+}
azure-pipelines.yml
+230
-133
@@ -2,21 +2,15 @@
2
# https://docs.microsoft.com/azure/devops/pipelines/languages/go
3
4
trigger:
5
-- v2
6
-
7
-strategy:
8
- matrix:
9
- linux:
10
- imageName: ubuntu-16.04
11
- gorootDir: /usr/local
12
- mac:
13
- imageName: macos-10.13
14
- gorootDir: /usr/local
15
- windows:
16
- imageName: windows-2019
17
- gorootDir: C:\
18
-pool:
19
- vmImage: $(imageName)
5
+ - v2
6
+
7
+schedules:
8
+- cron: "0 0 * * *"
9
+ displayName: Daily midnight fuzzing
10
+ branches:
11
+ include:
12
+ - v2
13
+ always: true
14
15
variables:
16
GOROOT: $(gorootDir)/go
@@ -26,121 +20,224 @@ variables:
20
# TODO: Remove once it's enabled by default
21
GO111MODULE: on
22
29
-steps:
30
-- bash: |
31
- latestGo=$(curl "https://golang.org/VERSION?m=text")
32
- echo "##vso[task.setvariable variable=LATEST_GO]$latestGo"
33
- echo "Latest Go version: $latestGo"
34
- displayName: "Get latest Go version"
35
-
36
-- bash: |
37
- sudo rm -f $(which go)
38
- echo '##vso[task.prependpath]$(GOBIN)'
39
- echo '##vso[task.prependpath]$(GOROOT)/bin'
40
- mkdir -p '$(modulePath)'
41
- shopt -s extglob
42
- shopt -s dotglob
43
- mv !(gopath) '$(modulePath)'
44
- displayName: Remove old Go, set GOBIN/GOROOT, and move project into GOPATH
45
-
46
-# Install Go (this varies by platform)
47
-- bash: |
48
- wget "https://dl.google.com/go/$(LATEST_GO).linux-amd64.tar.gz"
49
- sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).linux-amd64.tar.gz"
50
- condition: eq( variables['Agent.OS'], 'Linux' )
51
- displayName: Install Go on Linux
52
-
53
-- bash: |
54
- wget "https://dl.google.com/go/$(LATEST_GO).darwin-amd64.tar.gz"
55
- sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).darwin-amd64.tar.gz"
56
- condition: eq( variables['Agent.OS'], 'Darwin' )
57
- displayName: Install Go on macOS
58
-
59
-# The low performance is partly due to PowerShell's attempt to update the progress bar. Disabling it speeds up the process.
60
-# Reference: https://github.com/PowerShell/PowerShell/issues/2138
61
-- powershell: |
62
- $ProgressPreference = 'SilentlyContinue'
63
- Write-Host "Downloading Go..."
64
- (New-Object System.Net.WebClient).DownloadFile("https://dl.google.com/go/$(LATEST_GO).windows-amd64.zip", "$(LATEST_GO).windows-amd64.zip")
65
- Write-Host "Extracting Go... (I'm slow too)"
66
- 7z x "$(LATEST_GO).windows-amd64.zip" -o"$(gorootDir)"
67
- condition: eq( variables['Agent.OS'], 'Windows_NT' )
68
- displayName: Install Go on Windows
69
-
70
-- bash: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.19.1
71
- displayName: Install golangci-lint
72
-
73
-- script: |
74
- go get github.com/axw/gocov/gocov
75
- go get github.com/AlekSi/gocov-xml
76
- go get -u github.com/jstemmer/go-junit-report
77
- displayName: Install test and coverage analysis tools
78
-
79
-- bash: |
80
- printf "Using go at: $(which go)\n"
81
- printf "Go version: $(go version)\n"
82
- printf "\n\nGo environment:\n\n"
83
- go env
84
- printf "\n\nSystem environment:\n\n"
85
- env
86
- displayName: Print Go version and environment
87
-
88
-- script: |
89
- go get -v -t -d ./...
90
- mkdir test-results
91
- workingDirectory: '$(modulePath)'
92
- displayName: Get dependencies
93
-
94
-# its behavior is governed by .golangci.yml
95
-- script: |
96
- (golangci-lint run --out-format junit-xml) > test-results/lint-result.xml
97
- exit 0
98
- workingDirectory: '$(modulePath)'
99
- continueOnError: true
100
- displayName: Run lint check
101
-
102
-- script: |
103
- (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out
104
- workingDirectory: '$(modulePath)'
105
- continueOnError: true
106
- displayName: Run tests
107
-
108
-- script: |
109
- mkdir coverage
110
- gocov convert cover-profile.out > coverage/coverage.json
111
- # Because Windows doesn't work with input redirection like *nix, but output redirection works.
112
- (cat ./coverage/coverage.json | gocov-xml) > coverage/coverage.xml
113
- workingDirectory: '$(modulePath)'
114
- displayName: Prepare coverage reports
115
-
116
-- script: |
117
- (cat ./test-results/test-result.out | go-junit-report) > test-results/test-result.xml
118
- workingDirectory: '$(modulePath)'
119
- displayName: Prepare test report
120
-
121
-- task: PublishCodeCoverageResults@1
122
- displayName: Publish test coverage report
123
- inputs:
124
- codeCoverageTool: Cobertura
125
- summaryFileLocation: $(modulePath)/coverage/coverage.xml
126
-
127
-- task: PublishTestResults@2
128
- displayName: Publish unit test
129
- inputs:
130
- testResultsFormat: 'JUnit'
131
- testResultsFiles: $(modulePath)/test-results/test-result.xml
132
- testRunTitle: $(agent.OS) Unit Test
133
- mergeTestResults: false
134
-
135
-- task: PublishTestResults@2
136
- displayName: Publish lint results
137
- inputs:
138
- testResultsFormat: 'JUnit'
139
- testResultsFiles: $(modulePath)/test-results/lint-result.xml
140
- testRunTitle: $(agent.OS) Lint
141
- mergeTestResults: false
142
-
143
-- bash: |
144
- exit 1
145
- condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues')
146
- displayName: Coerce correct build result
\ No newline at end of file
23
+jobs:
24
+- job: crossPlatformTest
25
+ displayName: "Cross-Platform Tests"
26
+ strategy:
27
+ matrix:
28
+ linux:
29
+ imageName: ubuntu-16.04
30
+ gorootDir: /usr/local
31
+ mac:
32
+ imageName: macos-10.13
33
+ gorootDir: /usr/local
34
+ windows:
35
+ imageName: windows-2019
36
+ gorootDir: C:\
37
+ pool:
38
+ vmImage: $(imageName)
39
+
40
+ steps:
41
+ - bash: |
42
+ latestGo=$(curl "https://golang.org/VERSION?m=text")
43
+ echo "##vso[task.setvariable variable=LATEST_GO]$latestGo"
44
+ echo "Latest Go version: $latestGo"
45
+ displayName: "Get latest Go version"
46
+
47
+ - bash: |
48
+ sudo rm -f $(which go)
49
+ echo '##vso[task.prependpath]$(GOBIN)'
50
+ echo '##vso[task.prependpath]$(GOROOT)/bin'
51
+ mkdir -p '$(modulePath)'
52
+ shopt -s extglob
53
+ shopt -s dotglob
54
+ mv !(gopath) '$(modulePath)'
55
+ displayName: Remove old Go, set GOBIN/GOROOT, and move project into GOPATH
56
+
57
+ # Install Go (this varies by platform)
58
+ - bash: |
59
+ wget "https://dl.google.com/go/$(LATEST_GO).linux-amd64.tar.gz"
60
+ sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).linux-amd64.tar.gz"
61
+ condition: eq( variables['Agent.OS'], 'Linux' )
62
+ displayName: Install Go on Linux
63
+
64
+ - bash: |
65
+ wget "https://dl.google.com/go/$(LATEST_GO).darwin-amd64.tar.gz"
66
+ sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).darwin-amd64.tar.gz"
67
+ condition: eq( variables['Agent.OS'], 'Darwin' )
68
+ displayName: Install Go on macOS
69
+
70
+ # The low performance is partly due to PowerShell's attempt to update the progress bar. Disabling it speeds up the process.
71
+ # Reference: https://github.com/PowerShell/PowerShell/issues/2138
72
+ - powershell: |
73
+ $ProgressPreference = 'SilentlyContinue'
74
+ Write-Host "Downloading Go..."
75
+ (New-Object System.Net.WebClient).DownloadFile("https://dl.google.com/go/$(LATEST_GO).windows-amd64.zip", "$(LATEST_GO).windows-amd64.zip")
76
+ Write-Host "Extracting Go... (I'm slow too)"
77
+ 7z x "$(LATEST_GO).windows-amd64.zip" -o"$(gorootDir)"
78
+ condition: eq( variables['Agent.OS'], 'Windows_NT' )
79
+ displayName: Install Go on Windows
80
+
81
+ - bash: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.19.1
82
+ displayName: Install golangci-lint
83
+
84
+ - script: |
85
+ go get github.com/axw/gocov/gocov
86
+ go get github.com/AlekSi/gocov-xml
87
+ go get -u github.com/jstemmer/go-junit-report
88
+ displayName: Install test and coverage analysis tools
89
+
90
+ - bash: |
91
+ printf "Using go at: $(which go)\n"
92
+ printf "Go version: $(go version)\n"
93
+ printf "\n\nGo environment:\n\n"
94
+ go env
95
+ printf "\n\nSystem environment:\n\n"
96
+ env
97
+ displayName: Print Go version and environment
98
+
99
+ - script: |
100
+ go get -v -t -d ./...
101
+ mkdir test-results
102
+ workingDirectory: '$(modulePath)'
103
+ displayName: Get dependencies
104
+
105
+ # its behavior is governed by .golangci.yml
106
+ - script: |
107
+ (golangci-lint run --out-format junit-xml) > test-results/lint-result.xml
108
+ exit 0
109
+ workingDirectory: '$(modulePath)'
110
+ continueOnError: true
111
+ displayName: Run lint check
112
+
113
+ - script: |
114
+ (go test -v -coverprofile=cover-profile.out -race ./... 2>&1) > test-results/test-result.out
115
+ workingDirectory: '$(modulePath)'
116
+ continueOnError: true
117
+ displayName: Run tests
118
+
119
+ - script: |
120
+ mkdir coverage
121
+ gocov convert cover-profile.out > coverage/coverage.json
122
+ # Because Windows doesn't work with input redirection like *nix, but output redirection works.
123
+ (cat ./coverage/coverage.json | gocov-xml) > coverage/coverage.xml
124
+ workingDirectory: '$(modulePath)'
125
+ displayName: Prepare coverage reports
126
+
127
+ - script: |
128
+ (cat ./test-results/test-result.out | go-junit-report) > test-results/test-result.xml
129
+ workingDirectory: '$(modulePath)'
130
+ displayName: Prepare test report
131
+
132
+ - task: PublishCodeCoverageResults@1
133
+ displayName: Publish test coverage report
134
+ inputs:
135
+ codeCoverageTool: Cobertura
136
+ summaryFileLocation: $(modulePath)/coverage/coverage.xml
137
+
138
+ - task: PublishTestResults@2
139
+ displayName: Publish unit test
140
+ inputs:
141
+ testResultsFormat: 'JUnit'
142
+ testResultsFiles: $(modulePath)/test-results/test-result.xml
143
+ testRunTitle: $(agent.OS) Unit Test
144
+ mergeTestResults: false
145
+
146
+ - task: PublishTestResults@2
147
+ displayName: Publish lint results
148
+ inputs:
149
+ testResultsFormat: 'JUnit'
150
+ testResultsFiles: $(modulePath)/test-results/lint-result.xml
151
+ testRunTitle: $(agent.OS) Lint
152
+ mergeTestResults: false
153
+
154
+ - bash: |
155
+ exit 1
156
+ condition: eq(variables['Agent.JobStatus'], 'SucceededWithIssues')
157
+ displayName: Coerce correct build result
158
+
159
+- job: fuzzing
160
+ displayName: 'Scheduled Fuzzing'
161
+ # Only run this job on schedules, not PRs.
162
+ condition: eq(variables['Build.Reason'], 'Schedule')
163
+ strategy:
164
+ matrix:
165
+ linux:
166
+ imageName: ubuntu-16.04
167
+ gorootDir: /usr/local
168
+ pool:
169
+ vmImage: $(imageName)
170
+
171
+ steps:
172
+ - bash: |
173
+ latestGo=$(curl "https://golang.org/VERSION?m=text")
174
+ echo "##vso[task.setvariable variable=LATEST_GO]$latestGo"
175
+ echo "Latest Go version: $latestGo"
176
+ displayName: "Get latest Go version"
177
+
178
+ - bash: |
179
+ sudo rm -f $(which go)
180
+ echo '##vso[task.prependpath]$(GOBIN)'
181
+ echo '##vso[task.prependpath]$(GOROOT)/bin'
182
+ mkdir -p '$(modulePath)'
183
+ shopt -s extglob
184
+ shopt -s dotglob
185
+ mv !(gopath) '$(modulePath)'
186
+ displayName: Remove old Go, set GOBIN/GOROOT, and move project into GOPATH
187
+
188
+ - bash: |
189
+ wget "https://dl.google.com/go/$(LATEST_GO).linux-amd64.tar.gz"
190
+ sudo tar -C $(gorootDir) -xzf "$(LATEST_GO).linux-amd64.tar.gz"
191
+ condition: eq( variables['Agent.OS'], 'Linux' )
192
+ displayName: Install Go on Linux
193
+
194
+ - bash: |
195
+ # Install Clang
196
+ sudo add-apt-repository "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main"
197
+ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
198
+ sudo apt update && sudo apt install -y clang lldb lld
199
+
200
+ go get -v github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build
201
+ wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.74/fuzzit_Linux_x86_64
202
+ chmod a+x fuzzit
203
+ mv fuzzit $(GOBIN)
204
+ displayName: Download go-fuzz tools and the Fuzzit CLI, and move Fuzzit CLI to GOBIN
205
+ condition: and(eq(variables['System.PullRequest.IsFork'], 'False') , eq( variables['Agent.OS'], 'Linux' ))
206
+
207
+ - script: fuzzit auth ${FUZZIT_API_KEY}
208
+ condition: and(eq(variables['System.PullRequest.IsFork'], 'False') , eq( variables['Agent.OS'], 'Linux' ))
209
+ displayName: Authenticate with Fuzzit
210
+ env:
211
+ FUZZIT_API_KEY: $(FUZZIT_API_KEY)
212
+
213
+ - bash: |
214
+ declare -A fuzzers_funcs=(\
215
+ ["./admin_fuzz.go"]="FuzzAdmin" \
216
+ ["./caddyconfig/httpcaddyfile/adapter_fuzz.go"]="FuzzHTTPCaddyfileAdapter" \
217
+ ["./caddyconfig/httpcaddyfile/addresses_fuzz.go"]="FuzzParseAddress" \
218
+ ["./caddyconfig/caddyfile/parse_fuzz.go"]="FuzzParseCaddyfile" \
219
+ ["./listeners_fuzz.go"]="FuzzParseNetworkAddress" \
220
+ ["./replacer_fuzz.go"]="FuzzReplacer" \
221
+ )
222
+
223
+ declare -A fuzzers_targets=(\
224
+ ["./admin_fuzz.go"]="admin" \
225
+ ["./caddyconfig/httpcaddyfile/adapter_fuzz.go"]="caddyfile-adapter" \
226
+ ["./caddyconfig/httpcaddyfile/addresses_fuzz.go"]="parse-address" \
227
+ ["./caddyconfig/caddyfile/parse_fuzz.go"]="parse-caddyfile" \
228
+ ["./listeners_fuzz.go"]="parse-listen-addr" \
229
+ ["./replacer_fuzz.go"]="replacer" \
230
+ )
231
+ fuzz_type="fuzzing"
232
+
233
+ for f in $(find . -name \*_fuzz.go); do
234
+ FUZZER_DIRECTORY=$(dirname $f)
235
+ echo "go-fuzz-build func ${fuzzers_funcs[$f]} residing in $f"
236
+ go-fuzz-build -func "${fuzzers_funcs[$f]}" -libfuzzer -o "$FUZZER_DIRECTORY/${fuzzers_targets[$f]}.a" $FUZZER_DIRECTORY
237
+ echo "Generating fuzzer binary of func ${fuzzers_funcs[$f]} which resides in $f"
238
+ clang -fsanitize=fuzzer "$FUZZER_DIRECTORY/${fuzzers_targets[$f]}.a" -o "$FUZZER_DIRECTORY/${fuzzers_targets[$f]}.fuzzer"
239
+ fuzzit create job --type "${fuzz_type}" --branch "${SYSTEM_PULLREQUEST_SOURCEBRANCH}" --revision "${BUILD_SOURCEVERSION}" caddyserver/${fuzzers_targets[$f]} $FUZZER_DIRECTORY/${fuzzers_targets[$f]}.fuzzer
240
+ echo "Completed $f"
241
+ done
242
+ workingDirectory: '$(modulePath)'
243
+ displayName: Generate fuzzers & submit them to Fuzzit
caddyconfig/httpcaddyfile/adapter_fuzz.go
new
+49
@@ -0,0 +1,49 @@
1
+// Copyright 2015 Matthew Holt and The Caddy Authors
2
+//
3
+// Licensed under the Apache License, Version 2.0 (the "License");
4
+// you may not use this file except in compliance with the License.
5
+// You may obtain a copy of the License at
6
+//
7
+// http://www.apache.org/licenses/LICENSE-2.0
8
+//
9
+// Unless required by applicable law or agreed to in writing, software
10
+// distributed under the License is distributed on an "AS IS" BASIS,
11
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+// See the License for the specific language governing permissions and
13
+// limitations under the License.
14
+
15
+// +build gofuzz
16
+// +build gofuzz_libfuzzer
17
+
18
+package httpcaddyfile
19
+
20
+import (
21
+ "bytes"
22
+
23
+ "github.com/caddyserver/caddy/v2"
24
+ "github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
25
+)
26
+
27
+func FuzzHTTPCaddyfileAdapter(data []byte) int {
28
+ adapter := caddyfile.Adapter{
29
+ ServerType: ServerType{},
30
+ }
31
+ b, warns, err := adapter.Adapt(data, nil)
32
+ // Adapt func calls the Setup() func of the ServerType,
33
+ // thus it's going across multiple layers, each can
34
+ // return warnings or errors. Marking the presence of
35
+ // errors or warnings as interesting in this case
36
+ // could push the fuzzer towards a path where we only
37
+ // catch errors. Let's push the fuzzer to where it passes
38
+ // but breaks.
39
+ if (err != nil) || (warns != nil && len(warns) > 0) {
40
+ return 0
41
+ }
42
+
43
+ // adapted Caddyfile should be parseable by the configuration loader in admin.go
44
+ err = caddy.Load(bytes.NewReader(b))
45
+ if err != nil {
46
+ return 0
47
+ }
48
+ return 1
49
+}
caddyconfig/httpcaddyfile/addresses_fuzz.go
new
+29
@@ -0,0 +1,29 @@
1
+// Copyright 2015 Matthew Holt and The Caddy Authors
2
+//
3
+// Licensed under the Apache License, Version 2.0 (the "License");
4
+// you may not use this file except in compliance with the License.
5
+// You may obtain a copy of the License at
6
+//
7
+// http://www.apache.org/licenses/LICENSE-2.0
8
+//
9
+// Unless required by applicable law or agreed to in writing, software
10
+// distributed under the License is distributed on an "AS IS" BASIS,
11
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+// See the License for the specific language governing permissions and
13
+// limitations under the License.
14
+
15
+// +build gofuzz
16
+// +build gofuzz_libfuzzer
17
+
18
+package httpcaddyfile
19
+
20
+func FuzzParseAddress(data []byte) int {
21
+ addr, err := ParseAddress(string(data))
22
+ if err != nil {
23
+ if addr == (Address{}) {
24
+ return 1
25
+ }
26
+ return 0
27
+ }
28
+ return 1
29
+}
go.mod
+1
@@ -6,6 +6,7 @@ require (
6
github.com/Masterminds/sprig/v3 v3.0.0
7
github.com/andybalholm/brotli v0.0.0-20190821151343-b60f0d972eeb
8
github.com/dustin/go-humanize v1.0.0
9
+ github.com/dvyukov/go-fuzz v0.0.0-20191022152526-8cb203812681 // indirect
10
github.com/go-acme/lego/v3 v3.1.0
11
github.com/golang/groupcache v0.0.0-20191002201903-404acd9df4cc
12
github.com/ilibs/json5 v1.0.1
go.sum
+2
@@ -59,6 +59,8 @@ github.com/dnaeon/go-vcr v0.0.0-20180814043457-aafff18a5cc2/go.mod h1:aBB1+wY4s9
59
github.com/dnsimple/dnsimple-go v0.30.0/go.mod h1:O5TJ0/U6r7AfT8niYNlmohpLbCSG+c71tQlGr9SeGrg=
60
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
61
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
62
+github.com/dvyukov/go-fuzz v0.0.0-20191022152526-8cb203812681 h1:3WV5aRRj1ELP3RcLlBp/v0WJTuy47OQMkL9GIQq8QEE=
63
+github.com/dvyukov/go-fuzz v0.0.0-20191022152526-8cb203812681/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
64
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
65
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
66
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
listeners_fuzz.go
new
+26
@@ -0,0 +1,26 @@
1
+// Copyright 2015 Matthew Holt and The Caddy Authors
2
+//
3
+// Licensed under the Apache License, Version 2.0 (the "License");
4
+// you may not use this file except in compliance with the License.
5
+// You may obtain a copy of the License at
6
+//
7
+// http://www.apache.org/licenses/LICENSE-2.0
8
+//
9
+// Unless required by applicable law or agreed to in writing, software
10
+// distributed under the License is distributed on an "AS IS" BASIS,
11
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+// See the License for the specific language governing permissions and
13
+// limitations under the License.
14
+
15
+// +build gofuzz
16
+// +build gofuzz_libfuzzer
17
+
18
+package caddy
19
+
20
+func FuzzParseNetworkAddress(data []byte) int {
21
+ _, _, err := ParseNetworkAddress(string(data))
22
+ if err != nil {
23
+ return 0
24
+ }
25
+ return 1
26
+}
replacer_fuzz.go
new
+26
@@ -0,0 +1,26 @@
1
+// Copyright 2015 Matthew Holt and The Caddy Authors
2
+//
3
+// Licensed under the Apache License, Version 2.0 (the "License");
4
+// you may not use this file except in compliance with the License.
5
+// You may obtain a copy of the License at
6
+//
7
+// http://www.apache.org/licenses/LICENSE-2.0
8
+//
9
+// Unless required by applicable law or agreed to in writing, software
10
+// distributed under the License is distributed on an "AS IS" BASIS,
11
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+// See the License for the specific language governing permissions and
13
+// limitations under the License.
14
+
15
+// +build gofuzz
16
+// +build gofuzz_libfuzzer
17
+
18
+package caddy
19
+
20
+func FuzzReplacer(data []byte) (score int) {
21
+ NewReplacer().ReplaceAll(string(data), "")
22
+ NewReplacer().ReplaceAll(NewReplacer().ReplaceAll(string(data), ""), "")
23
+ NewReplacer().ReplaceAll(NewReplacer().ReplaceAll(string(data), ""), NewReplacer().ReplaceAll(string(data), ""))
24
+ NewReplacer().ReplaceAll(string(data[:len(data)/2]), string(data[len(data)/2:]))
25
+ return 0
26
+}