From c93f57a1373c99da31df6f6fca3681f1b3fbaea8 Mon Sep 17 00:00:00 2001 From: ebell495 Date: Tue, 24 May 2022 15:34:05 -0700 Subject: [PATCH 1/4] Integrate Mayhem --- .github/workflows/mayhem.yml | 64 ++++++++++++++++++++++++++++++++++++ Dockerfile | 7 ++++ Mayhemfile | 10 ++++++ fuzz/fuzz.py | 17 ++++++++++ 4 files changed, 98 insertions(+) create mode 100644 .github/workflows/mayhem.yml create mode 100644 Dockerfile create mode 100644 Mayhemfile create mode 100644 fuzz/fuzz.py diff --git a/.github/workflows/mayhem.yml b/.github/workflows/mayhem.yml new file mode 100644 index 00000000..a437de8b --- /dev/null +++ b/.github/workflows/mayhem.yml @@ -0,0 +1,64 @@ +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 }} + permissions: + packages: write + contents: write + security-events: write + + strategy: + matrix: + os: [ubuntu-latest] + shared: [false] + build_type: [Release] + include: + - os: ubuntu-latest + triplet: x64-linux + + steps: + - uses: actions/checkout@v2 + + - 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: . + 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 }} --duration 300 + sarif-output: sarif + + - name: Upload SARIF file(s) + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: sarif \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..281fda1c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.8-bullseye +RUN pip3 install atheris + +COPY . /html5lib +WORKDIR /html5lib +RUN python3 -m pip install -r requirements.txt +RUN python3 -m pip install . && chmod +x fuzz/fuzz.py \ No newline at end of file diff --git a/Mayhemfile b/Mayhemfile new file mode 100644 index 00000000..3d02a7a9 --- /dev/null +++ b/Mayhemfile @@ -0,0 +1,10 @@ +project: html5lib-python +target: html5lib-python +image: ghcr.io/ebell495/html5lib-python:latest +duration: 300 + +tests: null + +cmds: + - cmd: fuzz/fuzz.py + libfuzzer: true \ No newline at end of file diff --git a/fuzz/fuzz.py b/fuzz/fuzz.py new file mode 100644 index 00000000..8c51ecdd --- /dev/null +++ b/fuzz/fuzz.py @@ -0,0 +1,17 @@ +#!/usr/local/bin/python3 +import atheris +import sys + +with atheris.instrument_imports(): + import html5lib + + +@atheris.instrument_func +def TestOneInput(data): + fdp = atheris.FuzzedDataProvider(data) + html5lib.parse(fdp.ConsumeString(len(data))) + + +# atheris.instrument_all() +atheris.Setup(sys.argv, TestOneInput) +atheris.Fuzz() \ No newline at end of file From 4d504c2b3e78026e278c175db0599419bda12c66 Mon Sep 17 00:00:00 2001 From: Eric Bell <48191180+ebell495@users.noreply.github.com> Date: Sun, 29 May 2022 15:31:51 -0700 Subject: [PATCH 2/4] Update Mayhemfile --- Mayhemfile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Mayhemfile b/Mayhemfile index 3d02a7a9..a4dbe979 100644 --- a/Mayhemfile +++ b/Mayhemfile @@ -1,10 +1,7 @@ project: html5lib-python -target: html5lib-python -image: ghcr.io/ebell495/html5lib-python:latest -duration: 300 - +target: fuzz tests: null cmds: - cmd: fuzz/fuzz.py - libfuzzer: true \ No newline at end of file + libfuzzer: true From dee3e5a1ccb6ed2e7ae73bf85a3a5a49828f18eb Mon Sep 17 00:00:00 2001 From: Eric Bell <48191180+ebell495@users.noreply.github.com> Date: Thu, 16 Jun 2022 23:12:03 -0700 Subject: [PATCH 3/4] Update Mayhemfile --- Mayhemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Mayhemfile b/Mayhemfile index a4dbe979..91a83bd7 100644 --- a/Mayhemfile +++ b/Mayhemfile @@ -1,6 +1,5 @@ project: html5lib-python target: fuzz -tests: null cmds: - cmd: fuzz/fuzz.py From 90779997f641f9975ef3563c28eb369dc864ee25 Mon Sep 17 00:00:00 2001 From: ebell495 Date: Sun, 24 Jul 2022 18:19:47 -0700 Subject: [PATCH 4/4] Rename Fuzz Harness --- Dockerfile | 2 +- Mayhemfile | 4 ++-- fuzz/{fuzz.py => fuzz_html_parser.py} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename fuzz/{fuzz.py => fuzz_html_parser.py} (100%) diff --git a/Dockerfile b/Dockerfile index 281fda1c..84395c81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,4 @@ RUN pip3 install atheris COPY . /html5lib WORKDIR /html5lib RUN python3 -m pip install -r requirements.txt -RUN python3 -m pip install . && chmod +x fuzz/fuzz.py \ No newline at end of file +RUN python3 -m pip install . && chmod +x fuzz/fuzz_html_parser.py \ No newline at end of file diff --git a/Mayhemfile b/Mayhemfile index 91a83bd7..d0ea9290 100644 --- a/Mayhemfile +++ b/Mayhemfile @@ -1,6 +1,6 @@ project: html5lib-python -target: fuzz +target: fuzz_html_parser cmds: - - cmd: fuzz/fuzz.py + - cmd: fuzz/fuzz_html_parser.py libfuzzer: true diff --git a/fuzz/fuzz.py b/fuzz/fuzz_html_parser.py similarity index 100% rename from fuzz/fuzz.py rename to fuzz/fuzz_html_parser.py