diff --git a/projects/suricata/Dockerfile b/projects/suricata/Dockerfile index 40352073f0f1..deffdef3078e 100644 --- a/projects/suricata/Dockerfile +++ b/projects/suricata/Dockerfile @@ -32,3 +32,4 @@ RUN git clone --depth 1 https://github.com/OISF/libhtp.git libhtp RUN git clone --depth 1 https://github.com/OISF/suricata-verify suricata-verify WORKDIR $SRC COPY build.sh $SRC/ +COPY rustc.py $SRC/ diff --git a/projects/suricata/build.sh b/projects/suricata/build.sh index fa9a78548bd2..0318d51409c4 100755 --- a/projects/suricata/build.sh +++ b/projects/suricata/build.sh @@ -52,7 +52,15 @@ mv libhtp suricata/ cd suricata sh autogen.sh #run configure with right options +if [ "$SANITIZER" = "coverage" ] +then +export RUSTFLAGS="$RUSTFLAGS -C debug-assertions=no" +chmod +x $SRC/rustc.py +export RUSTC="$SRC/rustc.py" +./configure --disable-shared --enable-fuzztargets --enable-debug +else ./src/tests/fuzz/oss-fuzz-configure.sh +fi make -j$(nproc) cp src/fuzz_* $OUT/ diff --git a/projects/suricata/rustc.py b/projects/suricata/rustc.py new file mode 100644 index 000000000000..00f26df637ae --- /dev/null +++ b/projects/suricata/rustc.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +# Copyright 2021 Google LLC +# +# 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. + +import sys +import subprocess + +#disable coverage for crate brotli_decompressor +sys.argv[0] = "rustc" +if "brotli_decompressor" in sys.argv: + try: + sys.argv.remove("-Zinstrument-coverage") + except: + pass + print(sys.argv) +subprocess.call(sys.argv)