This repository has been archived by the owner on May 14, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fuzzing to the
transform
package
- Loading branch information
Showing
5 changed files
with
82 additions
and
5 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 |
---|---|---|
@@ -1,12 +1,33 @@ | ||
dist: bionic | ||
language: go | ||
go: | ||
- 1.7 | ||
- 1.8 | ||
- "1.11" | ||
|
||
services: | ||
- docker | ||
|
||
before_install: | ||
- go get github.com/mattn/goveralls | ||
|
||
install: | ||
- make setup | ||
- make build | ||
|
||
script: | ||
- make test | ||
- bash scripts/cover.sh | ||
# Coveralls is down for maintenance currently | ||
# - bash scripts/cover.sh | ||
|
||
jobs: | ||
include: | ||
- stage: Build, Unit-Tests & Fuzz-Tests | ||
if: branch = master AND type IN (pull_request) | ||
go: 1.12.x | ||
script: | ||
- bash scripts/fuzzit.sh regression | ||
|
||
- stage: Fuzzit (Fuzzing) | ||
if: branch = master AND type IN (push) | ||
go: 1.12.x | ||
script: | ||
- bash scripts/fuzzit.sh fuzzing |
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,30 @@ | ||
#!/bin/bash | ||
# | ||
# Helper script for working with fuzzit.dev: | ||
# | ||
# https://github.com/fuzzitdev/example-go | ||
# | ||
# Based on: | ||
# | ||
# https://github.com/google/syzkaller/blob/master/fuzzit.sh | ||
set -eux | ||
|
||
function target { | ||
go-fuzz-build -libfuzzer -func $3 -o fuzzer.a $2 | ||
clang -fsanitize=fuzzer fuzzer.a -o fuzzer | ||
|
||
./fuzzit create target $1 || true | ||
./fuzzit create job $LOCAL --type fuzzing --branch $TRAVIS_BRANCH --revision $TRAVIS_COMMIT prose/$1 ./fuzzer | ||
} | ||
|
||
go get -u github.com/dvyukov/go-fuzz/go-fuzz-build | ||
wget -q -O fuzzit https://github.com/fuzzitdev/fuzzit/releases/download/v2.4.12/fuzzit_Linux_x86_64 | ||
chmod a+x fuzzit | ||
if [ "$1" = "fuzzing" ]; then | ||
./fuzzit auth $FUZZIT_API_KEY | ||
export LOCAL="" | ||
else | ||
export LOCAL="--local" | ||
fi | ||
|
||
target prose-transform ./transform 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
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,22 @@ | ||
// +build gofuzz | ||
|
||
package transform | ||
|
||
func Fuzz(data []byte) int { | ||
s := string(data) | ||
|
||
// Case transformations | ||
Simple(s) | ||
Snake(s) | ||
Dash(s) | ||
Dot(s) | ||
Constant(s) | ||
Pascal(s) | ||
Camel(s) | ||
|
||
// Title converters | ||
tc := NewTitleConverter(APStyle) | ||
tc.Title(s) | ||
|
||
return 0 | ||
} |