@@ -33,3 +33,87 @@ index 8f6486896..b4f50ac36 100644
3333 RUN /root/checkout_build_install_llvm.sh
3434 RUN rm /root/checkout_build_install_llvm.sh
3535
36+ diff --git a/infra/base-images/base-builder/compile b/infra/base-images/base-builder/compile
37+ index d9077510f..5baa138a6 100755
38+ --- a/infra/base-images/base-builder/compile
39+ +++ b/infra/base-images/base-builder/compile
40+ @@ -20,6 +20,7 @@ echo "---------------------------------------------------------------"
41+ sysctl -w vm.mmap_rnd_bits=28
42+
43+ OSS_FUZZ_ON_DEMAND="${OSS_FUZZ_ON_DEMAND:-0}"
44+ + RUST_SANITIZER=$SANITIZER
45+
46+ if [ "$FUZZING_LANGUAGE" = "jvm" ]; then
47+ if [ "$FUZZING_ENGINE" != "libfuzzer" ] && [ "$FUZZING_ENGINE" != "wycheproof" ]; then
48+ @@ -66,6 +67,13 @@ if [ "$FUZZING_LANGUAGE" = "python" ]; then
49+ fi
50+ fi
51+
52+ + if [ "$FUZZING_LANGUAGE" = "rust" ]; then
53+ + if [ "$SANITIZER" = "introspector" ]; then
54+ + # introspector sanitizer flag will cause cargo build failed, remove it temporary and store it in separate variable
55+ + export SANITIZER=address
56+ + fi
57+ + fi
58+ +
59+ if [ -z "${SANITIZER_FLAGS-}" ]; then
60+ FLAGS_VAR="SANITIZER_FLAGS_${SANITIZER}"
61+ export SANITIZER_FLAGS=${!FLAGS_VAR-}
62+ @@ -111,7 +119,7 @@ fi
63+ # use RUSTFLAGS.
64+ # FIXME: Support code coverage once support is in.
65+ # See https://github.com/rust-lang/rust/issues/34701.
66+ - if [ "$SANITIZER" != "undefined" ] && [ "$SANITIZER" != "coverage" ] && [ "$SANITIZER" != "none" ] && [ "$ARCHITECTURE" != 'i386' ]; then
67+ + if [ "$SANITIZER" != "undefined" ] && [ "$SANITIZER" != "coverage" ] && [ "$SANITIZER" != "none" ] && [ "$RUST_SANITIZER" != "introspector" ] && [ "$ARCHITECTURE" != 'i386' ]; then
68+ export RUSTFLAGS="--cfg fuzzing -Zsanitizer=${SANITIZER} -Cdebuginfo=1 -Cforce-frame-pointers"
69+ else
70+ export RUSTFLAGS="--cfg fuzzing -Cdebuginfo=1 -Cforce-frame-pointers"
71+ @@ -188,7 +196,7 @@ EOF
72+ export CXXFLAGS="$CXXFLAGS -fno-sanitize=leak"
73+ fi
74+
75+ - if [ "$SANITIZER" = "introspector" ]; then
76+ + if [ "$SANITIZER" = "introspector" ] || [ "$RUST_SANITIZER" = "introspector" ]; then
77+ export AR=llvm-ar
78+ export NM=llvm-nm
79+ export RANLIB=llvm-ranlib
80+ @@ -280,7 +288,7 @@ else
81+ fi
82+ fi
83+
84+ - if [ "$SANITIZER" = "introspector" ]; then
85+ + if [ "$SANITIZER" = "introspector" ] || [ "$RUST_SANITIZER" = "introspector" ]; then
86+ unset CXXFLAGS
87+ unset CFLAGS
88+ export G_ANALYTICS_TAG="G-8WTFM1Y62J"
89+ @@ -295,6 +303,21 @@ if [ "$SANITIZER" = "introspector" ]; then
90+ mkdir -p $SRC/my-fi-data
91+ find $OUT/ -name *.data -exec mv {} $SRC/my-fi-data/ \;
92+ find $OUT/ -name *.data.yaml -exec mv {} $SRC/my-fi-data/ \;
93+ + elif [ "$FUZZING_LANGUAGE" = "rust" ]; then
94+ + echo "GOING rust route"
95+ +
96+ + # Run the rust frontend
97+ + pushd /fuzz-introspector/frontends/rust/rust_function_analyser
98+ + cargo run -- $SRC
99+ +
100+ + # Move files temporarily to fix workflow of other languages.
101+ + mkdir -p $SRC/my-fi-data
102+ + find ./ -name "*.data" -exec mv {} $SRC/my-fi-data/ \;
103+ + find ./ -name "*.data.yaml" -exec mv {} $SRC/my-fi-data/ \;
104+ + popd
105+ +
106+ + # Restore the sanitizer flag for rust
107+ + export SANITIZER="introspector"
108+ fi
109+
110+ mkdir -p $SRC/inspector
111+ @@ -336,7 +359,7 @@ if [ "$SANITIZER" = "introspector" ]; then
112+ python3 /fuzz-introspector/src/main.py report $REPORT_ARGS
113+ cp -rf $SRC/inspector $OUT/inspector
114+ else
115+ - # C/C++
116+ + # C/C++/Rust
117+
118+ # Correlate fuzzer binaries to fuzz-introspector's raw data
119+ python3 /fuzz-introspector/src/main.py correlate --binaries_dir=$OUT/
0 commit comments