Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.
Open
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
78 changes: 78 additions & 0 deletions .github/workflows/mayhem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Mayhem
permissions: write-all
on:
push:
pull_request:
workflow_dispatch:

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@v3
with:
submodules: recursive

- name: Log in to the Container registry
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4.1.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v3.2.0
with:
context: .
push: true
file: mayhem/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

outputs:
image: ${{ steps.meta.outputs.tags }}

mayhem:
needs: build
name: 'fuzz ${{ matrix.mayhemfile }}'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
mayhemfile:
- mayhem/Mayhemfile_to_lower_copy

steps:
- uses: actions/checkout@v3

- name: Start analysis for ${{ matrix.mayhemfile }}
uses: ForAllSecure/mcode-action@v1
with:
mayhem-token: ${{ secrets.MAYHEM_TOKEN }}
args: --image ${{ needs.build.outputs.image }} --file ${{ matrix.mayhemfile }} --duration 300
sarif-output: sarif

- name: Upload SARIF file(s)
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: sarif
18 changes: 18 additions & 0 deletions mayhem/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM --platform=linux/amd64 ubuntu:22.04 as builder

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential clang libmicrohttpd-dev automake pkg-config libtool

COPY . /repo
WORKDIR /repo
RUN ./bootstrap
WORKDIR /repo/build
RUN ../configure --prefix=/install
RUN make -j8
RUN make install

RUN clang++ /repo/mayhem/fuzz_to_lower_copy.cpp -fsanitize=fuzzer,address -std=c++17 -I /repo/src/ /install/lib/libhttpserver.a -o /fuzz

FROM ubuntu:22.04 as package

COPY --from=builder /fuzz /fuzz_to_lower_copy
5 changes: 5 additions & 0 deletions mayhem/Mayhemfile_to_lower_copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project: libhttpserver
target: to-lower-copy
cmds:
- cmd: /fuzz_to_lower_copy
libfuzzer: true
17 changes: 17 additions & 0 deletions mayhem/fuzz_to_lower_copy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdint.h>
#include <stdio.h>

#define _HTTPSERVER_HPP_INSIDE_ 1

#include <fuzzer/FuzzedDataProvider.h>
#include "httpserver/string_utilities.hpp"


extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
FuzzedDataProvider provider(data, size);
std::string str = provider.ConsumeRandomLengthString();
httpserver::string_utilities::to_lower_copy(str);

return 0;
}