2018-12-21 19:19:14 +00:00
|
|
|
#!/bin/bash -eu
|
|
|
|
# Copyright (C) 2018 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
[clamav] Add flex, bison to Dockerfile (#3755)
Flex & Bison are needed to generate source files for yara syntax
support. While the generated source are currently in the clamav-devel
repo, the build system sometimes thinks the files must be regenerated.
In the future, these and the autotools generated files will be removed
from the clamav-devel repo and will need to be generated for every
build.
We're also planning to add CMake tooling (still a work in progress).
Once the generated files are removed, we'll either have ot build the
fuzz targets with CMake or bring in autoconf, automake, m4, libtool, and
pkg-config to generate the files in build.sh. At that time, we should
also update build.sh to build the dependencies statically, many of which
are missing at present meaning we're not getting great code coverage.
We'll also want to load a small signature set to improve code coverage
for the fuzz targets.
2020-05-03 21:28:30 +00:00
|
|
|
set -ex
|
|
|
|
|
2018-12-21 19:19:14 +00:00
|
|
|
#
|
|
|
|
# Build the library.
|
|
|
|
#
|
2019-01-23 22:04:47 +00:00
|
|
|
rm -rf ${WORK}/build
|
2019-01-23 17:26:18 +00:00
|
|
|
mkdir -p ${WORK}/build
|
|
|
|
cd ${WORK}/build
|
[clamav] Add flex, bison to Dockerfile (#3755)
Flex & Bison are needed to generate source files for yara syntax
support. While the generated source are currently in the clamav-devel
repo, the build system sometimes thinks the files must be regenerated.
In the future, these and the autotools generated files will be removed
from the clamav-devel repo and will need to be generated for every
build.
We're also planning to add CMake tooling (still a work in progress).
Once the generated files are removed, we'll either have ot build the
fuzz targets with CMake or bring in autoconf, automake, m4, libtool, and
pkg-config to generate the files in build.sh. At that time, we should
also update build.sh to build the dependencies statically, many of which
are missing at present meaning we're not getting great code coverage.
We'll also want to load a small signature set to improve code coverage
for the fuzz targets.
2020-05-03 21:28:30 +00:00
|
|
|
|
2020-07-27 01:40:34 +00:00
|
|
|
if [ -f "${SRC}/clamav-devel/autogen.sh" ]
|
|
|
|
then
|
|
|
|
/bin/chmod +x ${SRC}/clamav-devel/autogen.sh
|
|
|
|
${SRC}/clamav-devel/autogen.sh
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Remove ltdl so clamav build doesn't detect it and add it as a dependency.
|
|
|
|
apt remove -y libtool libltdl-dev libltdl7
|
|
|
|
|
[clamav] Add flex, bison to Dockerfile (#3755)
Flex & Bison are needed to generate source files for yara syntax
support. While the generated source are currently in the clamav-devel
repo, the build system sometimes thinks the files must be regenerated.
In the future, these and the autotools generated files will be removed
from the clamav-devel repo and will need to be generated for every
build.
We're also planning to add CMake tooling (still a work in progress).
Once the generated files are removed, we'll either have ot build the
fuzz targets with CMake or bring in autoconf, automake, m4, libtool, and
pkg-config to generate the files in build.sh. At that time, we should
also update build.sh to build the dependencies statically, many of which
are missing at present meaning we're not getting great code coverage.
We'll also want to load a small signature set to improve code coverage
for the fuzz targets.
2020-05-03 21:28:30 +00:00
|
|
|
#
|
|
|
|
# Run ./configure
|
|
|
|
#
|
|
|
|
ac_cv_c_mmap_anonymous=no \
|
|
|
|
${SRC}/clamav-devel/configure \
|
|
|
|
--disable-mempool \
|
|
|
|
--enable-fuzz=yes \
|
|
|
|
--with-libjson=no \
|
|
|
|
--with-pcre=no \
|
|
|
|
--enable-static=yes \
|
|
|
|
--enable-shared=no \
|
|
|
|
--disable-llvm \
|
|
|
|
--host=x86_64-unknown-linux-gnu
|
|
|
|
|
|
|
|
# Build libclamav
|
2018-12-21 19:19:14 +00:00
|
|
|
make clean
|
|
|
|
make -j"$(nproc)"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Build the fuzz targets.
|
|
|
|
#
|
2019-01-23 17:26:18 +00:00
|
|
|
make -j"$(nproc)" fuzz-all
|
|
|
|
cp ./fuzz/clamav_* ${OUT}/.
|
2018-12-21 19:19:14 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Collect the fuzz corpora.
|
|
|
|
#
|
|
|
|
|
|
|
|
# `scanfile` & `scanmap`
|
|
|
|
# ----------
|
2019-01-23 17:26:18 +00:00
|
|
|
mkdir ${WORK}/all-scantype-seeds
|
2018-12-21 19:19:14 +00:00
|
|
|
|
|
|
|
for type in ARCHIVE MAIL OLE2 PDF HTML PE ELF SWF XMLDOCS HWP3; do
|
[clamav] Add flex, bison to Dockerfile (#3755)
Flex & Bison are needed to generate source files for yara syntax
support. While the generated source are currently in the clamav-devel
repo, the build system sometimes thinks the files must be regenerated.
In the future, these and the autotools generated files will be removed
from the clamav-devel repo and will need to be generated for every
build.
We're also planning to add CMake tooling (still a work in progress).
Once the generated files are removed, we'll either have ot build the
fuzz targets with CMake or bring in autoconf, automake, m4, libtool, and
pkg-config to generate the files in build.sh. At that time, we should
also update build.sh to build the dependencies statically, many of which
are missing at present meaning we're not getting great code coverage.
We'll also want to load a small signature set to improve code coverage
for the fuzz targets.
2020-05-03 21:28:30 +00:00
|
|
|
# Prepare seed corpus for the type-specific fuzz targets.
|
|
|
|
zip ${OUT}/clamav_scanfile_${type}_fuzzer_seed_corpus.zip ${SRC}/clamav-fuzz-corpus/scantype/${type}/*
|
|
|
|
zip ${OUT}/clamav_scanmap_${type}_fuzzer_seed_corpus.zip ${SRC}/clamav-fuzz-corpus/scantype/${type}/*
|
2018-12-21 19:19:14 +00:00
|
|
|
|
[clamav] Add flex, bison to Dockerfile (#3755)
Flex & Bison are needed to generate source files for yara syntax
support. While the generated source are currently in the clamav-devel
repo, the build system sometimes thinks the files must be regenerated.
In the future, these and the autotools generated files will be removed
from the clamav-devel repo and will need to be generated for every
build.
We're also planning to add CMake tooling (still a work in progress).
Once the generated files are removed, we'll either have ot build the
fuzz targets with CMake or bring in autoconf, automake, m4, libtool, and
pkg-config to generate the files in build.sh. At that time, we should
also update build.sh to build the dependencies statically, many of which
are missing at present meaning we're not getting great code coverage.
We'll also want to load a small signature set to improve code coverage
for the fuzz targets.
2020-05-03 21:28:30 +00:00
|
|
|
# Prepare dictionary for the type-specific fuzz targets (may not exist for all types).
|
|
|
|
cp ${SRC}/clamav-fuzz-corpus/scantype/${type}.dict ${OUT}/clamav_scanfile_${type}_fuzzer.dict 2>/dev/null || :
|
|
|
|
cp ${SRC}/clamav-fuzz-corpus/scantype/${type}.dict ${OUT}/clamav_scanmap_${type}_fuzzer.dict 2>/dev/null || :
|
2018-12-21 19:19:14 +00:00
|
|
|
|
[clamav] Add flex, bison to Dockerfile (#3755)
Flex & Bison are needed to generate source files for yara syntax
support. While the generated source are currently in the clamav-devel
repo, the build system sometimes thinks the files must be regenerated.
In the future, these and the autotools generated files will be removed
from the clamav-devel repo and will need to be generated for every
build.
We're also planning to add CMake tooling (still a work in progress).
Once the generated files are removed, we'll either have ot build the
fuzz targets with CMake or bring in autoconf, automake, m4, libtool, and
pkg-config to generate the files in build.sh. At that time, we should
also update build.sh to build the dependencies statically, many of which
are missing at present meaning we're not getting great code coverage.
We'll also want to load a small signature set to improve code coverage
for the fuzz targets.
2020-05-03 21:28:30 +00:00
|
|
|
# Copy seeds for the generic fuzz target.
|
|
|
|
cp ${SRC}/clamav-fuzz-corpus/scantype/${type}/* ${WORK}/all-scantype-seeds/
|
2018-12-21 19:19:14 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Prepare seed corpus for the generic fuzz target.
|
2019-01-23 17:26:18 +00:00
|
|
|
cp ${SRC}/clamav-fuzz-corpus/scantype/other/* ${WORK}/all-scantype-seeds/
|
|
|
|
zip ${OUT}/clamav_scanfile_fuzzer_seed_corpus.zip ${WORK}/all-scantype-seeds/*
|
|
|
|
zip ${OUT}/clamav_scanmap_fuzzer_seed_corpus.zip ${WORK}/all-scantype-seeds/*
|
|
|
|
rm -r ${WORK}/all-scantype-seeds
|
2018-12-21 19:19:14 +00:00
|
|
|
|
|
|
|
# `dbload`
|
|
|
|
# --------
|
|
|
|
for type in CDB CFG CRB FP FTM HDB HSB IDB IGN IGN2 LDB MDB MSB NDB PDB WDB YARA; do
|
[clamav] Add flex, bison to Dockerfile (#3755)
Flex & Bison are needed to generate source files for yara syntax
support. While the generated source are currently in the clamav-devel
repo, the build system sometimes thinks the files must be regenerated.
In the future, these and the autotools generated files will be removed
from the clamav-devel repo and will need to be generated for every
build.
We're also planning to add CMake tooling (still a work in progress).
Once the generated files are removed, we'll either have ot build the
fuzz targets with CMake or bring in autoconf, automake, m4, libtool, and
pkg-config to generate the files in build.sh. At that time, we should
also update build.sh to build the dependencies statically, many of which
are missing at present meaning we're not getting great code coverage.
We'll also want to load a small signature set to improve code coverage
for the fuzz targets.
2020-05-03 21:28:30 +00:00
|
|
|
# Prepare seed corpus for the type-specific fuzz targets.
|
|
|
|
zip ${OUT}/clamav_dbload_${type}_fuzzer_seed_corpus.zip ${SRC}/clamav-fuzz-corpus/database/${type}/*
|
2018-12-21 19:19:14 +00:00
|
|
|
|
[clamav] Add flex, bison to Dockerfile (#3755)
Flex & Bison are needed to generate source files for yara syntax
support. While the generated source are currently in the clamav-devel
repo, the build system sometimes thinks the files must be regenerated.
In the future, these and the autotools generated files will be removed
from the clamav-devel repo and will need to be generated for every
build.
We're also planning to add CMake tooling (still a work in progress).
Once the generated files are removed, we'll either have ot build the
fuzz targets with CMake or bring in autoconf, automake, m4, libtool, and
pkg-config to generate the files in build.sh. At that time, we should
also update build.sh to build the dependencies statically, many of which
are missing at present meaning we're not getting great code coverage.
We'll also want to load a small signature set to improve code coverage
for the fuzz targets.
2020-05-03 21:28:30 +00:00
|
|
|
# Prepare dictionary for the type-specific fuzz targets (may not exist for all types).
|
|
|
|
cp ${SRC}/clamav-fuzz-corpus/database/${type}.dict ${OUT}/clamav_dbload_${type}_fuzzer.dict 2>/dev/null || :
|
2018-12-21 19:19:14 +00:00
|
|
|
done
|