Skip to content

Commit

Permalink
roaring-bitmap: initial integration (#10952)
Browse files Browse the repository at this point in the history
Initial integration for project RoaringBitmap.

---------

Signed-off-by: Arthur Chan <[email protected]>
  • Loading branch information
arthurscchan authored Sep 14, 2023
1 parent ee9f211 commit a76d1f8
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
19 changes: 19 additions & 0 deletions projects/roaring-bitmap/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2023 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-jvm
RUN git clone --depth 1 https://github.com/RoaringBitmap/RoaringBitmap RoaringBitmap
COPY *.sh *.java $SRC/
WORKDIR $SRC/RoaringBitmap
44 changes: 44 additions & 0 deletions projects/roaring-bitmap/RoaringBitmapFuzzer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2023 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 com.code_intelligence.jazzer.api.FuzzedDataProvider;
import org.roaringbitmap.longlong.Roaring64Bitmap;

// Generated with https://github.com/ossf/fuzz-introspector/tree/main/tools/auto-fuzz
// Minor modifications to beautify code and ensure exception is caught.
// Heuristic name: jvm-autofuzz-heuristics-1
// Target method: [org.roaringbitmap.longlong.Roaring64Bitmap] public static org.roaringbitmap.longlong.Roaring64Bitmap bitmapOf(long[])
// Heuristic name: jvm-autofuzz-heuristics-2
// Target method: [org.roaringbitmap.longlong.Roaring64Bitmap] public void and(org.roaringbitmap.longlong.Roaring64Bitmap)
// Target method: [org.roaringbitmap.longlong.Roaring64Bitmap] public void or(org.roaringbitmap.longlong.Roaring64Bitmap)
// Target method: [org.roaringbitmap.longlong.Roaring64Bitmap] public void xor(org.roaringbitmap.longlong.Roaring64Bitmap)
public class RoaringBitmapFuzzer {
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
Roaring64Bitmap bitmap1 = Roaring64Bitmap.bitmapOf(data.consumeLongs(data.consumeInt(1, 10)));
Roaring64Bitmap bitmap2 = Roaring64Bitmap.bitmapOf(data.consumeLongs(data.consumeInt(1, 10)));

switch (data.consumeInt(1, 3)) {
case 1:
bitmap1.and(bitmap2);
break;
case 2:
bitmap1.or(bitmap2);
break;
case 3:
bitmap1.xor(bitmap2);
break;
}
}
}
58 changes: 58 additions & 0 deletions projects/roaring-bitmap/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash -eu
# Copyright 2023 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.
#
##########################################################################
./gradlew clean build -x test -x javadoc -x sources

CURRENT_VERSION=$(./gradlew properties | grep ^version: | cut -d" " -f2)

cp "./RoaringBitmap/build/libs/RoaringBitmap-$CURRENT_VERSION.jar" $OUT/roaring-bitmap.jar
cp "./shims/build/libs/shims-$CURRENT_VERSION.jar" $OUT/shims.jar

ALL_JARS="roaring-bitmap.jar shims.jar"

# The classpath at build-time includes the project jars in $OUT as well as the
# Jazzer API.
BUILD_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "$OUT/%s:"):$JAZZER_API_PATH

# All .jar and .class files lie in the same directory as the fuzzer at runtime.
RUNTIME_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "\$this_dir/%s:"):\$this_dir

for fuzzer in $(find $SRC -maxdepth 1 -name '*Fuzzer.java')
do
fuzzer_basename=$(basename -s .java $fuzzer)
javac -cp $BUILD_CLASSPATH $fuzzer
cp $SRC/$fuzzer_basename.class $OUT/

# Create an execution wrapper that executes Jazzer with the correct arguments.
echo "#!/bin/bash
# LLVMFuzzerTestOneInput for fuzzer detection.
this_dir=\$(dirname "\$0")
if [[ "\$@" =~ (^| )-runs=[0-9]+($| ) ]]
then
mem_settings='-Xmx1900m:-Xss900k'
else
mem_settings='-Xmx2048m:-Xss1024k'
fi
LD_LIBRARY_PATH="$JVM_LD_LIBRARY_PATH":\$this_dir \
\$this_dir/jazzer_driver \
--agent_path=\$this_dir/jazzer_agent_deploy.jar \
--cp=$RUNTIME_CLASSPATH \
--target_class=$fuzzer_basename \
--jvm_args="\$mem_settings" \
\$@" > $OUT/$fuzzer_basename

chmod u+x $OUT/$fuzzer_basename
done
12 changes: 12 additions & 0 deletions projects/roaring-bitmap/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
homepage: https://github.com/RoaringBitmap/RoaringBitmap
main_repo: https://github.com/RoaringBitmap/RoaringBitmap
language: jvm
fuzzing_engines:
- libfuzzer
sanitizers:
- address
primary_contact: "[email protected]"
vendor_ccs:
- [email protected]
- [email protected]
- [email protected]

0 comments on commit a76d1f8

Please sign in to comment.