aboutsummaryrefslogtreecommitdiff
path: root/projects/suricata
diff options
context:
space:
mode:
authorCatena cyber <35799796+catenacyber@users.noreply.github.com>2021-03-08 16:05:35 +0100
committerGitHub <noreply@github.com>2021-03-08 07:05:35 -0800
commitc41e46ffc8bc409bdfde0c0d2c97e1305f0c4106 (patch)
tree4001fbebec66e846cf957fe69e4b339774132c6f /projects/suricata
parent96ae2ed544659c7475a4296d4ee55d4ebd69f37e (diff)
downloadoss-fuzz-c41e46ffc8bc409bdfde0c0d2c97e1305f0c4106.tar.gz
Rust coverage report (for Suricata) (#4697)
* Rust coverage test * Workaround to get rust coverage for Suricata
Diffstat (limited to 'projects/suricata')
-rw-r--r--projects/suricata/Dockerfile1
-rwxr-xr-xprojects/suricata/build.sh10
-rw-r--r--projects/suricata/rustc.py28
3 files changed, 38 insertions, 1 deletions
diff --git a/projects/suricata/Dockerfile b/projects/suricata/Dockerfile
index 40352073f..deffdef30 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 d0e152d8b..0318d5140 100755
--- a/projects/suricata/build.sh
+++ b/projects/suricata/build.sh
@@ -52,8 +52,16 @@ 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
-make
+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 000000000..00f26df63
--- /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)