Skip to content

ci(tests): fuzz testing workflow for REST API #6

ci(tests): fuzz testing workflow for REST API

ci(tests): fuzz testing workflow for REST API #6

name: REST API Fuzz Test
on:
workflow_dispatch:
pull_request: # Pushing a new commit to the HEAD ref of a pull request will trigger the “synchronize” event
paths:
- .yarnrc.yml .
- .yarn
- package.json
- '.github/workflows/rest-api-fuzzer.yml'
- 'packages/server/**/*'
- 'packages/shared/**/*'
env:
BUILD_CONFIGURATION: Release
BUILD_PLATFORM: 'Any CPU'
RESTLER_VERSION: '9.2.4'
PYTHON_VERSION: '3.8'
DOTNET_VERSION: '6.0.x'
jobs:
build-restler-fuzzer:
name: Fuzz test speckle-server REST API
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
name: Checkout RESTler Fuzzer
with:
repository: microsoft/restler-fuzzer
ref: v${{ env.RESTLER_VERSION }}
path: 'restler-fuzzer' # The path to clone the repository under {{ github.workspace }}
- name: Setup .NET ${{ env.DOTNET_VERSION }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Restore NuGet packages
run: dotnet restore ${{ github.workspace }}/restler-fuzzer/src/Restler.sln
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install engine (Python) dependencies
run: |
pip install -r ${{ github.workspace }}/restler-fuzzer/restler/requirements.txt
- name: Build RESTler
run: |
python ${{ github.workspace }}/restler-fuzzer/build-restler.py --dest_dir ${{ github.workspace }}/bin
- name: Debug the built output
run: |
ls -la ${{ github.workspace }}/bin/restler
ls -la ${{ github.workspace }}/bin/restler/restler
- uses: actions/checkout@v4
name: Checkout speckle-server
with:
path: 'speckle-server'
- name: Compile RESTler grammar from OpenAPI specification
run: |
${{ github.workspace }}/bin/restler/restler compile --api_spec ${{ github.workspace }}/speckle-server/utils/specifications/speckle-server.openapi.json
- name: Print the results
run: ls -lat ${{ github.workspace }}/restlerConfig
# fuzz-rest-api-lite:
# runs-on: ubuntu-latest
# needs:
# - compile-fuzzer-syntax
# timeout-minutes: 15
# services:
# postgres:
# # Docker Hub image
# image: postgres:16.4-bookworm@sha256:91f464e7ba0ad91a106c94cff079fb4384139291b8c0502fd36989cf2c788bbb
# env:
# POSTGRES_DB: fuzz_test
# POSTGRES_PASSWORD: fuzz_test
# POSTGRES_USER: fuzz_test
# # Set health checks to wait until postgres has started
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# ports:
# - 5432:5432
# # 4. Run the fuzzer in lite mode
# steps:
# - name: Compile from OpenAPI
# run: docker run ${{ needs.build-restler-fuzzer.outputs.tags }} compile --api_spec <full path to API specification>
# # 5. Print the results
# fuzz-rest-api-full:
# runs-on: ubuntu-latest
# needs:
# - compile-fuzzer-syntax
# timeout-minutes: 45
# steps:
# - name: Run RESTler Fuzzer
# run: docker run /RESTler/restler/restler.exe fuzz --api_spec <full path to API specification> --fuzz_mode full
# # 7. Print the results