forked from valyala/fasthttp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'valyala:master' into master
- Loading branch information
Showing
19 changed files
with
173 additions
and
159 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: CIFuzz | ||
on: [pull_request] | ||
jobs: | ||
Fuzzing: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Build Fuzzers | ||
id: build | ||
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master | ||
with: | ||
oss-fuzz-project-name: 'fasthttp' | ||
dry-run: false | ||
language: go | ||
- name: Run Fuzzers | ||
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master | ||
with: | ||
oss-fuzz-project-name: 'fasthttp' | ||
fuzz-seconds: 300 | ||
dry-run: false | ||
language: go | ||
- name: Upload Crash | ||
uses: actions/upload-artifact@v3 | ||
if: failure() && steps.build.outcome == 'success' | ||
with: | ||
name: artifacts | ||
path: ./out/artifacts |
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 |
---|---|---|
|
@@ -6,3 +6,4 @@ tags | |
.vscode | ||
.DS_Store | ||
vendor/ | ||
testdata/fuzz |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,93 @@ | ||
package fasthttp | ||
|
||
import ( | ||
"bufio" | ||
"bytes" | ||
"testing" | ||
) | ||
|
||
func FuzzCookieParse(f *testing.F) { | ||
inputs := []string{ | ||
`xxx=yyy`, | ||
`xxx=yyy; expires=Tue, 10 Nov 2009 23:00:00 GMT; domain=foobar.com; path=/a/b`, | ||
" \n\t\"", | ||
} | ||
for _, input := range inputs { | ||
f.Add([]byte(input)) | ||
} | ||
c := AcquireCookie() | ||
defer ReleaseCookie(c) | ||
f.Fuzz(func(t *testing.T, cookie []byte) { | ||
_ = c.ParseBytes(cookie) | ||
|
||
w := bytes.Buffer{} | ||
if _, err := c.WriteTo(&w); err != nil { | ||
t.Fatalf("unexpected error: %v", err) | ||
} | ||
}) | ||
} | ||
|
||
func FuzzVisitHeaderParams(f *testing.F) { | ||
inputs := []string{ | ||
`application/json; v=1; foo=bar; q=0.938; param=param; param="big fox"; q=0.43`, | ||
`*/*`, | ||
`\\`, | ||
`text/plain; foo="\\\"\'\\''\'"`, | ||
} | ||
for _, input := range inputs { | ||
f.Add([]byte(input)) | ||
} | ||
f.Fuzz(func(t *testing.T, header []byte) { | ||
VisitHeaderParams(header, func(key, value []byte) bool { | ||
if len(key) == 0 { | ||
t.Errorf("Unexpected length zero parameter, failed input was: %s", header) | ||
} | ||
return true | ||
}) | ||
}) | ||
} | ||
|
||
func FuzzResponseReadLimitBody(f *testing.F) { | ||
res := AcquireResponse() | ||
defer ReleaseResponse(res) | ||
|
||
f.Add([]byte("HTTP/1.1 200 OK\r\nContent-Type: aa\r\nContent-Length: 10\r\n\r\n9876543210"), 1024*1024) | ||
|
||
f.Fuzz(func(t *testing.T, body []byte, max int) { | ||
_ = res.ReadLimitBody(bufio.NewReader(bytes.NewReader(body)), max) | ||
w := bytes.Buffer{} | ||
_, _ = res.WriteTo(&w) | ||
}) | ||
} | ||
|
||
func FuzzRequestReadLimitBody(f *testing.F) { | ||
req := AcquireRequest() | ||
defer ReleaseRequest(req) | ||
|
||
f.Add([]byte("POST /a HTTP/1.1\r\nHost: a.com\r\nTransfer-Encoding: chunked\r\nContent-Type: aa\r\n\r\n6\r\nfoobar\r\n3\r\nbaz\r\n0\r\nfoobar\r\n\r\n"), 1024*1024) | ||
|
||
f.Fuzz(func(t *testing.T, body []byte, max int) { | ||
_ = req.ReadLimitBody(bufio.NewReader(bytes.NewReader(body)), max) | ||
w := bytes.Buffer{} | ||
_, _ = req.WriteTo(&w) | ||
}) | ||
} | ||
|
||
func FuzzURIUpdateBytes(f *testing.F) { | ||
u := AcquireURI() | ||
defer ReleaseURI(u) | ||
|
||
f.Add([]byte(`http://foobar.com/aaa/bb?cc`)) | ||
f.Add([]byte(`//foobar.com/aaa/bb?cc`)) | ||
f.Add([]byte(`/aaa/bb?cc`)) | ||
f.Add([]byte(`xx?yy=abc`)) | ||
|
||
f.Fuzz(func(t *testing.T, uri []byte) { | ||
u.UpdateBytes(uri) | ||
|
||
w := bytes.Buffer{} | ||
if _, err := u.WriteTo(&w); err != nil { | ||
t.Fatalf("unexpected error: %v", err) | ||
} | ||
}) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.