diff --git a/chaoscenter/fuzz_build.sh b/chaoscenter/fuzz_build.sh index b942e1612f3..3c7f52db9d9 100755 --- a/chaoscenter/fuzz_build.sh +++ b/chaoscenter/fuzz_build.sh @@ -14,8 +14,24 @@ # limitations under the License. # ################################################################################ -cd chaoscenter/graphql/server && go mod download -go install github.com/AdamKorcz/go-118-fuzz-build@latest -go get github.com/AdamKorcz/go-118-fuzz-build/testing +export GO_MOD_PATHS_MAPPING=( "graphql/server" "authentication" "subscriber" ) -compile_native_go_fuzzer $(pwd)/pkg/environment/handler/fuzz_tests FuzzTestGetEnvironment test-fuzz \ No newline at end of file +cd chaoscenter +export rootDir=$(pwd) + +for dir in "${GO_MOD_PATHS_MAPPING[@]}"; do + cd ${dir} && go mod download + go install github.com/AdamKorcz/go-118-fuzz-build@latest + go get github.com/AdamKorcz/go-118-fuzz-build/testing + fuzz_files=($(find "$(pwd)" -type f -name '*_fuzz_test.go')) + for file in "${fuzz_files[@]}"; do + pkg=$(grep -m 1 '^package' "$file" | awk '{print $2}') + package_path=$(dirname "${file%$pkg}") + functionList=($(grep -o 'func Fuzz[A-Za-z0-9_]*' ${file} | awk '{print $2}')) + for i in "${functionList[@]}" + do + compile_native_go_fuzzer ${package_path} ${i} ${i} + done + done + cd ${rootDir} +done \ No newline at end of file