Skip to content

Commit 138356a

Browse files
committed
Add harness
1 parent cfcc1d0 commit 138356a

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed

.github/workflows/mayhem.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ jobs:
5151
fail-fast: false
5252
matrix:
5353
mayhemfile:
54-
- mayhem/Mayhemfile
54+
- mayhem/Mayhemfile_startsWith
55+
- mayhem/Mayhemfile_pycdc
5556

5657
steps:
5758
- uses: actions/checkout@v2

mayhem/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
FROM --platform=linux/amd64 ubuntu:22.04 as builder
22

33
RUN apt-get update
4-
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake python-is-python3
4+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake python-is-python3 clang
55

66
COPY . /repo
77
WORKDIR /repo/build
88
RUN cmake .. -DCMAKE_INSTALL_PREFIX=/install
99
RUN make -j8
1010
RUN make install
11+
RUN clang++ /repo/mayhem/fuzz_startsWith.cpp -fsanitize=fuzzer,address -I /repo/ -L /repo/build/ -lpycxx -o /fuzz
1112

1213
FROM ubuntu:22.04 as package
1314
COPY --from=builder /install /install
15+
COPY --from=builder /fuzz /fuzz_startsWith
File renamed without changes.

mayhem/Mayhemfile_startsWith

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
project: pycdc
2+
target: startswith
3+
4+
cmds:
5+
- cmd: /fuzz
6+
libfuzzer: true

mayhem/fuzz_startsWith.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <stdint.h>
2+
#include <stdio.h>
3+
#include <climits>
4+
5+
#include <fuzzer/FuzzedDataProvider.h>
6+
#include "pyc_string.h"
7+
8+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
9+
{
10+
FuzzedDataProvider provider(data, size);
11+
std::string str = provider.ConsumeRandomLengthString();
12+
13+
PycString pycString;
14+
pycString.startsWith(str);
15+
16+
return 0;
17+
}

0 commit comments

Comments
 (0)