forked from google/oss-fuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit brings Ruzzy, a coverage-guided fuzzer developed for pure Ruby code and Ruby C extensions, into the OSS-Fuzz project. This addition effectively integrates Ruby fuzzing support into OSS-Fuzz. Similar to Atheris, a Python fuzzer, Ruzzy uses libFuzzer for coverage instrumentation and the fuzzing engine. It offers support for AddressSanitizer and UndefinedBehaviorSanitizer, particularly when fuzzing C extensions. While the current code is functional, additional refinement and bug fixes may be required to ensure reliability. You can find further discussion about this development in issue: google#11967
- Loading branch information
1 parent
1515519
commit d9cb8cb
Showing
7 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# 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. | ||
# | ||
################################################################################ | ||
|
||
FROM gcr.io/oss-fuzz-base/base-builder | ||
|
||
# TODO: I think it's not used. | ||
ENV ASAN_OPTIONS="allocator_may_return_null=1:detect_leaks=0:use_sigaltstack=0" | ||
|
||
RUN git clone https://github.com/trailofbits/ruzzy.git $SRC/ruzzy | ||
|
||
RUN install_ruby.sh | ||
ENV PATH="$PATH:/usr/local/rvm/rubies/ruby-3.3.1/bin" | ||
|
||
RUN gem update --system 3.5.11 | ||
|
||
# Install ruzzy | ||
WORKDIR $SRC/ruzzy | ||
|
||
# The MAKE variable allows overwriting the make command at runtime. This forces the | ||
# Ruby C extension to respect ENV variables when compiling, like CC, CFLAGS, etc. | ||
ENV MAKE="make --environment-overrides V=1" | ||
|
||
RUN CC="clang" \ | ||
CXX="clang++" \ | ||
LDSHARED="clang -shared" \ | ||
LDSHAREDXX="clang++ -shared" \ | ||
gem build | ||
|
||
RUN MAKE="make --environment-overrides V=1" \ | ||
CC="clang" \ | ||
CXX="clang++" \ | ||
LDSHARED="clang -shared" \ | ||
LDSHAREDXX="clang++ -shared" \ | ||
CXXFLAGS="-fPIC" \ | ||
CFLAGS="-fPIC" \ | ||
RUZZY_DEBUG=1 gem install --install-dir /install/ruzzy --development --verbose ruzzy-*.gem | ||
|
||
|
||
ENV LDSHARED="$CC -shared" | ||
ENV LDSHAREDXX="$CXX -shared" | ||
|
||
ENV GEM_HOME="$OUT/fuzz-gem" | ||
ENV GEM_PATH="/install/ruzzy" | ||
|
||
COPY ruzzy-build /usr/bin/ruzzy-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
fuzz_target=$(basename "$1") | ||
echo "BASENAME: $fuzz_target ---" | ||
harness_sh=${fuzz_target::-3} | ||
|
||
cp $1 $OUT/$fuzz_target | ||
|
||
echo """#!/usr/bin/env bash | ||
ruzzy $fuzz_target | ||
""" > $OUT/$harness_sh | ||
chmod +x $OUT/$harness_sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
# 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. | ||
# | ||
################################################################################ | ||
|
||
apt update | ||
# TODO: we should install a specific version of ruby | ||
apt install -y lsb-release software-properties-common gnupg2 binutils xz-utils libyaml-dev | ||
gpg2 --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB | ||
curl -sSL https://get.rvm.io | bash | ||
|
||
. /etc/profile.d/rvm.sh | ||
|
||
rvm install ruby-3.3.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
LD_PRELOAD=$(ruby -e 'require "ruzzy"; print Ruzzy::ASAN_PATH') \ | ||
ruby $@ |