1 1.1 christos # Copyright (c) 2019 Yubico AB. All rights reserved. 2 1.1 christos # Use of this source code is governed by a BSD-style 3 1.1 christos # license that can be found in the LICENSE file. 4 1.1 christos 5 1.1.1.4 christos IMAGE := libfido2-coverage:1.8.0 6 1.1 christos RUNNER := libfido2-runner 7 1.1.1.3 christos PROFDATA := llvm-profdata-11 8 1.1.1.3 christos COV := llvm-cov-11 9 1.1.1.3 christos TARGETS := fuzz_assert fuzz_bio fuzz_cred fuzz_credman fuzz_hid \ 10 1.1.1.3 christos fuzz_largeblob fuzz_netlink fuzz_mgmt 11 1.1 christos CORPORA := $(foreach f,${TARGETS},${f}/corpus) 12 1.1 christos MINIFY := $(foreach f,${TARGETS},/minify/${f}/corpus) 13 1.1 christos REMOTE := gs://libfido2-corpus.clusterfuzz-external.appspot.com 14 1.1 christos .DEFAULT_GOAL := all 15 1.1 christos 16 1.1 christos all: ${TARGETS} 17 1.1 christos 18 1.1 christos build: 19 1.1 christos docker build -t ${IMAGE} - < Dockerfile 20 1.1 christos 21 1.1 christos run: build 22 1.1 christos -docker run -it -d --name ${RUNNER} ${IMAGE} 23 1.1 christos docker start ${RUNNER} 24 1.1 christos 25 1.1 christos sync: run 26 1.1 christos tar Ccf .. - src fuzz | docker exec -i ${RUNNER} tar Cxf /libfido2 - 27 1.1 christos docker exec ${RUNNER} make -C libfido2/build 28 1.1 christos 29 1.1 christos corpus: sync 30 1.1.1.2 christos docker exec ${RUNNER} /bin/sh -c 'cd /libfido2/fuzz && rm -rf ${TARGETS}' 31 1.1 christos docker exec ${RUNNER} tar Czxf /libfido2/fuzz /libfido2/fuzz/corpus.tgz 32 1.1 christos 33 1.1 christos ${TARGETS}: corpus sync 34 1.1 christos docker exec -e LLVM_PROFILE_FILE=/profraw/$@ ${RUNNER} \ 35 1.1.1.2 christos /bin/sh -c 'rm -f /profraw/$@ && /libfido2/build/fuzz/$@ \ 36 1.1 christos -runs=1 /libfido2/fuzz/$@' 37 1.1 christos 38 1.1 christos ${MINIFY}: /minify/%/corpus: % 39 1.1.1.2 christos docker exec ${RUNNER} /bin/sh -c 'rm -rf $@ && mkdir -p $@ && \ 40 1.1 christos /libfido2/build/fuzz/$< -use_value_profile=1 -merge=1 $@ \ 41 1.1 christos /libfido2/fuzz/$</corpus' 42 1.1 christos 43 1.1 christos corpus.tgz-: ${MINIFY} 44 1.1 christos docker exec -i ${RUNNER} tar Czcf /minify - ${TARGETS} > $@ 45 1.1 christos 46 1.1 christos profdata: run 47 1.1.1.2 christos docker exec ${RUNNER} /bin/sh -c 'rm -f /$@ && ${PROFDATA} \ 48 1.1 christos merge -sparse profraw/* -o $@' 49 1.1 christos 50 1.1 christos report.tgz: profdata 51 1.1.1.2 christos docker exec ${RUNNER} /bin/sh -c 'rm -rf /report && mkdir /report && \ 52 1.1 christos ${COV} show -format=html -tab-size=8 -instr-profile=/$< \ 53 1.1 christos -output-dir=/report /libfido2/build/src/libfido2.so' 54 1.1 christos docker exec -i ${RUNNER} tar Czcf / - report > $@ 55 1.1 christos 56 1.1 christos summary.txt: profdata 57 1.1 christos docker exec ${RUNNER} ${COV} report -use-color=false \ 58 1.1 christos /libfido2/build/src/libfido2.so -instr-profile=/$< > $@ 59 1.1 christos 60 1.1 christos functions.txt: profdata 61 1.1.1.2 christos docker exec ${RUNNER} /bin/sh -c '${COV} report -use-color=false \ 62 1.1 christos -show-functions -instr-profile=/$< \ 63 1.1 christos /libfido2/build/src/libfido2.so /libfido2/src/*.[ch]' > $@ 64 1.1 christos 65 1.1 christos clean: run 66 1.1.1.2 christos docker exec ${RUNNER} /bin/sh -c 'rm -rf /profraw /profdata && \ 67 1.1 christos make -C /libfido2/build clean' 68 1.1 christos -docker stop ${RUNNER} 69 1.1 christos rm -rf ${TARGETS} 70 1.1 christos 71 1.1 christos ${CORPORA}: 72 1.1 christos -mkdir -p $@ 73 1.1 christos gsutil -q -m rsync -d -r ${REMOTE}/libFuzzer/libfido2_$(@:/corpus=) $@ 74 1.1 christos 75 1.1 christos corpus.tgz: ${CORPORA} 76 1.1 christos tar zcf $@ ${TARGETS} 77 1.1 christos 78 1.1 christos .PHONY: build run sync corpus ${TARGETS} ${CORPORA} 79 1.1 christos .PHONY: report.tgz summary.txt functions.txt 80