Skip to content

Commit

Permalink
Workaround to get rust coverage for Suricata
Browse files Browse the repository at this point in the history
  • Loading branch information
catenacyber committed Mar 8, 2021
1 parent ca9d614 commit 06d763c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions projects/suricata/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
8 changes: 8 additions & 0 deletions projects/suricata/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
28 changes: 28 additions & 0 deletions projects/suricata/rustc.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 06d763c

Please sign in to comment.