diff --git a/.github/workflows/net_fuzzer-mayhem.yml b/.github/workflows/net_fuzzer-mayhem.yml new file mode 100644 index 0000000..0d3d3f5 --- /dev/null +++ b/.github/workflows/net_fuzzer-mayhem.yml @@ -0,0 +1,55 @@ +name: Mayhem +on: + push: + pull_request: + workflow_dispatch: + workflow_call: +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} +jobs: + build: + name: ${{ matrix.os }} shared=${{ matrix.shared }} ${{ matrix.build_type }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + shared: [false] + build_type: [Release] + include: + - os: ubuntu-latest + triplet: x64-linux + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + file: mayhem/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Start analysis + uses: forallsecure/mcode-action@v1 + with: + mayhem-token: ${{ secrets.MAYHEM_TOKEN }} + args: --image ${{ steps.meta.outputs.tags }} --cmd /out/net_fuzzer --target + net_fuzzer --file mayhem/net_fuzzer.mayhemfile + sarif-output: sarif + - name: Upload SARIF file(s) + uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: sarif diff --git a/mayhem/Dockerfile b/mayhem/Dockerfile new file mode 100644 index 0000000..645985d --- /dev/null +++ b/mayhem/Dockerfile @@ -0,0 +1,37 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder + +RUN apt-get update && apt-get install -y autoconf automake libtool ninja-build + +# Install Protobuf for C++ as the version in the base-builder repos may +# be outdated. +RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.18.1/protobuf-cpp-3.18.1.tar.gz +RUN tar xf protobuf-cpp-3.18.1.tar.gz +WORKDIR $SRC/protobuf-3.18.1 +# Build statically +RUN ./configure --disable-shared +RUN make -j $(nproc) +RUN make install + +WORKDIR $SRC +COPY . SockFuzzer +RUN rm -rf SockFuzzer/mayhem +COPY mayhem/build.sh $SRC + +ENV FUZZING_LANGUAGE=c SANITIZER=address +RUN compile \ No newline at end of file diff --git a/mayhem/Dockerfile.dockerignore b/mayhem/Dockerfile.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/mayhem/build.sh b/mayhem/build.sh new file mode 100755 index 0000000..c296a33 --- /dev/null +++ b/mayhem/build.sh @@ -0,0 +1,24 @@ +#!/bin/bash -eu +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +mkdir $SRC/build +cd $SRC/build + +cmake -GNinja $SRC/SockFuzzer +ninja + +cp $SRC/build/net_fuzzer $OUT diff --git a/mayhem/net_fuzzer.mayhemfile b/mayhem/net_fuzzer.mayhemfile new file mode 100644 index 0000000..81caf6f --- /dev/null +++ b/mayhem/net_fuzzer.mayhemfile @@ -0,0 +1,4 @@ +project: PROJECT +target: net_fuzzer +cmds: +- cmd: /out/net_fuzzer