Skip to content

Commit 925cbd2

Browse files
ebell495ForAllSecure Mayhem Bot
authored and
ForAllSecure Mayhem Bot
committed
Integrate Mayhem
1 parent fd4f032 commit 925cbd2

File tree

4 files changed

+98
-0
lines changed

4 files changed

+98
-0
lines changed

.github/workflows/mayhem.yml

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Mayhem
2+
on:
3+
push:
4+
pull_request:
5+
workflow_dispatch:
6+
workflow_call:
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build:
14+
name: ${{ matrix.os }} shared=${{ matrix.shared }} ${{ matrix.build_type }}
15+
runs-on: ${{ matrix.os }}
16+
permissions:
17+
packages: write
18+
contents: write
19+
security-events: write
20+
21+
strategy:
22+
matrix:
23+
os: [ubuntu-latest]
24+
shared: [false]
25+
build_type: [Release]
26+
include:
27+
- os: ubuntu-latest
28+
triplet: x64-linux
29+
30+
steps:
31+
- uses: actions/checkout@v2
32+
33+
- name: Log in to the Container registry
34+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Extract metadata (tags, labels) for Docker
41+
id: meta
42+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
43+
with:
44+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
45+
46+
- name: Build and push Docker image
47+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
48+
with:
49+
context: .
50+
push: true
51+
tags: ${{ steps.meta.outputs.tags }}
52+
labels: ${{ steps.meta.outputs.labels }}
53+
54+
- name: Start analysis
55+
uses: ForAllSecure/mcode-action@v1
56+
with:
57+
mayhem-token: ${{ secrets.MAYHEM_TOKEN }}
58+
args: --image ${{ steps.meta.outputs.tags }} --duration 300
59+
sarif-output: sarif
60+
61+
- name: Upload SARIF file(s)
62+
uses: github/codeql-action/upload-sarif@v1
63+
with:
64+
sarif_file: sarif

Dockerfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM python:3.8-bullseye
2+
RUN pip3 install atheris
3+
4+
COPY . /html5lib
5+
WORKDIR /html5lib
6+
RUN python3 -m pip install -r requirements.txt
7+
RUN python3 -m pip install . && chmod +x fuzz/fuzz.py

Mayhemfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
project: html5lib-python
2+
target: html5lib-python
3+
image: ghcr.io/ebell495/html5lib-python:latest
4+
duration: 300
5+
6+
tests: null
7+
8+
cmds:
9+
- cmd: fuzz/fuzz.py
10+
libfuzzer: true

fuzz/fuzz.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/local/bin/python3
2+
import atheris
3+
import sys
4+
5+
with atheris.instrument_imports():
6+
import html5lib
7+
8+
9+
@atheris.instrument_func
10+
def TestOneInput(data):
11+
fdp = atheris.FuzzedDataProvider(data)
12+
html5lib.parse(fdp.ConsumeString(len(data)))
13+
14+
15+
# atheris.instrument_all()
16+
atheris.Setup(sys.argv, TestOneInput)
17+
atheris.Fuzz()

0 commit comments

Comments
 (0)