forked from dergoegge/fuzzamoto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.coverage
More file actions
104 lines (81 loc) · 3.25 KB
/
Dockerfile.coverage
File metadata and controls
104 lines (81 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
FROM debian:bookworm
# ------ Coverage for fuzzamoto ------
ARG LLVM_V=19
# Add the LLVM apt repo
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates gnupg lsb-release software-properties-common wget && \
wget https://apt.llvm.org/llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh ${LLVM_V}
# Install LLVM toolchain & Bitcoin Core build dependencies
# vim & tmux are useful
RUN apt-get update && apt install -y --no-install-recommends \
build-essential \
clang-${LLVM_V} \
cmake \
curl \
git \
libclang-rt-${LLVM_V}-dev \
lld-${LLVM_V} \
llvm-${LLVM_V} \
llvm-${LLVM_V}-dev \
patch \
python3 \
tmux \
vim
# Install rust and tools
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup install nightly && rustup default nightly
# ------ Build Bitcoin Core ------
# Build Bitcoin Core
ARG OWNER=bitcoin
ARG REPO=bitcoin
ARG BRANCH=master
RUN git clone --depth 1 --branch $BRANCH https://github.com/$OWNER/$REPO.git
ENV CC=clang-${LLVM_V}
ENV CXX=clang++-${LLVM_V}
ENV SOURCES_PATH=/tmp/bitcoin-depends
RUN make -C bitcoin/depends NO_QT=1 NO_ZMQ=1 NO_USDT=1 download-linux SOURCES_PATH=$SOURCES_PATH
# Keep extracted source
RUN sed -i --regexp-extended '/.*rm -rf .*extract_dir.*/d' ./bitcoin/depends/funcs.mk && \
make -C ./bitcoin/depends DEBUG=1 NO_QT=1 NO_ZMQ=1 NO_USDT=1 \
SOURCES_PATH=$SOURCES_PATH \
AR=llvm-ar-${LLVM_V} NM=llvm-nm-${LLVM_V} RANLIB=llvm-ranlib-${LLVM_V} STRIP=llvm-strip-${LLVM_V} \
-j$(nproc)
COPY ./target-patches/bitcoin-core-aggressive-rng.patch bitcoin/
RUN cd bitcoin/ && \
git apply bitcoin-core-aggressive-rng.patch
RUN cd bitcoin/ && cmake -B build_fuzz_cov \
--toolchain ./depends/$(./depends/config.guess)/toolchain.cmake \
-DAPPEND_CFLAGS="-fprofile-instr-generate -fcoverage-mapping" \
-DAPPEND_CXXFLAGS="-fprofile-instr-generate -fcoverage-mapping" \
-DAPPEND_LDFLAGS="-fprofile-instr-generate -fcoverage-mapping -fuse-ld=lld-${LLVM_V}" \
-DAPPEND_CPPFLAGS="-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
RUN cmake --build bitcoin/build_fuzz_cov -j$(nproc) --target bitcoind
WORKDIR /fuzzamoto/fuzzamoto-nyx-sys
COPY ./fuzzamoto-nyx-sys/Cargo.toml .
COPY ./fuzzamoto-nyx-sys/src/ src/
COPY ./fuzzamoto-nyx-sys/build.rs .
WORKDIR /fuzzamoto/fuzzamoto
COPY ./fuzzamoto/Cargo.toml .
COPY ./fuzzamoto/src/ src/
WORKDIR /fuzzamoto/fuzzamoto-cli
COPY ./fuzzamoto-cli/Cargo.toml .
COPY ./fuzzamoto-cli/src/ src/
WORKDIR /fuzzamoto/fuzzamoto-ir
COPY ./fuzzamoto-ir/Cargo.toml .
COPY ./fuzzamoto-ir/src/ src/
WORKDIR /fuzzamoto/fuzzamoto-libafl
COPY ./fuzzamoto-libafl/Cargo.toml .
COPY ./fuzzamoto-libafl/src/ src/
WORKDIR /fuzzamoto/fuzzamoto-scenarios
COPY ./fuzzamoto-scenarios/Cargo.toml .
COPY ./fuzzamoto-scenarios/bin/ bin/
WORKDIR /fuzzamoto
COPY ./Cargo.toml .
RUN mkdir .cargo && cargo vendor > .cargo/config
ENV BITCOIND_PATH=/bitcoin/build_fuzz_cov/bin/bitcoind
RUN cargo build -p fuzzamoto-scenarios --bins -p fuzzamoto-cli --verbose --features "reproduce" --release
ENV LLVM_V=${LLVM_V}
ENTRYPOINT ["/fuzzamoto/target/release/fuzzamoto-cli", "coverage", "--output", "/mnt/output", \
"--corpus", "/mnt/corpus", "--bitcoind", "/bitcoin/build_fuzz_cov/bin/bitcoind", "--scenario"]