Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix core command swagger #4630

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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_result/*
15 changes: 15 additions & 0 deletions Dockerfile.fuzz
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine as builder

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

RUN git clone https://github.com/microsoft/restler-fuzzer.git

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_result/$EDGEX_PROJECT_NAME/
21 changes: 19 additions & 2 deletions openapi/v3/core-command.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,14 @@ paths:
required: true
schema:
type: string
example: sensor01
example: Random-Boolean-Device
description: "A name uniquely identifying a device."
- in: path
name: command
required: true
schema:
type: string
example: command01
example: Bool
description: "A name uniquely identifying a command."
- in: query
name: ds-pushevent
Expand Down Expand Up @@ -562,6 +562,22 @@ paths:
$ref: '#/components/examples/503Example'
put:
summary: "Issue the specified write command referenced by the command name to the device/sensor that is also referenced by name."
parameters:
- $ref: '#/components/parameters/correlatedRequestHeader'
- in: path
name: name
required: true
schema:
type: string
example: Random-Boolean-Device
description: "A name uniquely identifying a device."
- in: path
name: command
required: true
schema:
type: string
example: Bool
description: "A name uniquely identifying a command."
requestBody:
content:
application/json:
Expand Down Expand Up @@ -647,6 +663,7 @@ paths:
required: true
schema:
type: string
example: Random-Boolean-Device
description: "A name uniquely identifying a device."
get:
summary: "Returns all commands associated with the specified device."
Expand Down