• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2021 Google Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18# Copy seed corpus and dictionary.
19mv $SRC/{*.zip,*.dict} $OUT
20
21MAVEN_ARGS="-P!java14+ -Dmaven.test.skip=true -Djavac.src.version=15 -Djavac.target.version=15"
22
23DEPENDENCIES="jackson-core jackson-databind jackson-annotations"
24for dependency in $DEPENDENCIES; do
25  cd $SRC/$dependency
26  mvn package $MAVEN_ARGS
27  current_version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
28  -Dexpression=project.version -q -DforceStdout)
29  cp "target/$dependency-$current_version.jar" $OUT/$dependency.jar
30done
31
32ALL_JARS=$(echo $DEPENDENCIES | xargs printf -- "%s.jar ")
33
34# The classpath at build-time includes the project jars in $OUT as well as the
35# Jazzer API.
36BUILD_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "$OUT/%s:"):$JAZZER_API_PATH
37
38# All .jar and .class files lie in the same directory as the fuzzer at runtime.
39RUNTIME_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "\$this_dir/%s:"):\$this_dir
40
41for fuzzer in $(find $SRC -name '*Fuzzer.java'); do
42  fuzzer_basename=$(basename -s .java $fuzzer)
43  javac -cp $BUILD_CLASSPATH $fuzzer
44  cp $SRC/$fuzzer_basename.class $OUT/
45
46  # Create an execution wrapper that executes Jazzer with the correct arguments.
47  echo "#!/bin/sh
48# LLVMFuzzerTestOneInput for fuzzer detection.
49this_dir=\$(dirname \"\$0\")
50LD_LIBRARY_PATH=\"$JVM_LD_LIBRARY_PATH\":\$this_dir \
51\$this_dir/jazzer_driver --agent_path=\$this_dir/jazzer_agent_deploy.jar \
52--cp=$RUNTIME_CLASSPATH \
53--target_class=$fuzzer_basename \
54--jvm_args=\"-Xmx2048m\" \
55\$@" > $OUT/$fuzzer_basename
56  chmod +x $OUT/$fuzzer_basename
57done
58