Skip to content

Commit

Permalink
feat: add fuzzing core-data dockerfile and script
Browse files Browse the repository at this point in the history
Closes: issue #4568
Signed-off-by: Valina Li <[email protected]>
  • Loading branch information
vli11 committed May 16, 2023
1 parent 50d4b10 commit 67c93f7
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ stage/*
snap/.snapcraft/*
squashfs-root/

# result files
fuzz_results/*
16 changes: 16 additions & 0 deletions Dockerfile.fuzz
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine as builder

RUN apk add --no-cache python3 py3-pip bash

RUN wget https://github.com/microsoft/restler-fuzzer/archive/refs/tags/v9.2.0.tar.gz
RUN tar -xvf v9.2.0.tar.gz && mv restler-fuzzer-9.2.0 restler-fuzzer

RUN cd restler-fuzzer; mkdir -p restler_bin
WORKDIR /restler-fuzzer
RUN python3 ./build-restler.py --dest_dir ./restler_bin/

COPY fuzzing_docker.sh /restler-fuzzer/fuzzing.sh
COPY /openapi/v3/core-data.yaml /restler-fuzzer/

ENTRYPOINT ["/restler-fuzzer/fuzzing.sh"]
CMD ["core-data", "/restler-fuzzer", "core-data.yaml"]
22 changes: 22 additions & 0 deletions fuzzing_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

EDGEX_PROJECT_NAME=${1}
echo $EDGEX_PROJECT_NAME
SWAGGER_FILE_PATH=${2}
echo $SWAGGER_FILE_PATH
SWAGGER_FILE_NAME=${3}
echo $SWAGGER_FILE_NAME

echo "--compile from swagger file"
./restler_bin/restler/Restler compile --api_spec /$SWAGGER_FILE_PATH/$SWAGGER_FILE_NAME

echo "--test the grammar"
./restler_bin/restler/Restler test --grammar_file ./Compile/grammar.py --dictionary_file ./Compile/dict.json --settings ./Compile/engine_settings.json --no_ssl

# assuming edgex service is already running on host
echo "--run fuzz-lean"
./restler_bin/restler/Restler fuzz-lean --grammar_file ./Compile/grammar.py --dictionary_file ./Compile/dict.json --settings ./Compile/engine_settings.json --no_ssl

echo "--copy result logs into $EDGEX_PROJECT_NAME"
mkdir -p /fuzz_result/$EDGEX_PROJECT_NAME
cp -r ./Test/RestlerResults/ /fuzz_results/$EDGEX_PROJECT_NAME/

0 comments on commit 67c93f7

Please sign in to comment.