1#!/bin/bash -eu 2# Copyright 2021 Google LLC 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 18MAVEN_ARGS="-P!java14+ -Dmaven.test.skip=true -Djavac.src.version=15 -Djavac.target.version=15" 19 20cd $SRC/jackson-dataformats-binary 21mvn package $MAVEN_ARGS 22CURRENT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \ 23 -Dexpression=project.version -q -DforceStdout) 24DATAFORMAT_PREFIX=jackson-dataformat 25cp "cbor/target/$DATAFORMAT_PREFIX-cbor-$CURRENT_VERSION.jar" $OUT/$DATAFORMAT_PREFIX-cbor.jar 26cp "smile/target/$DATAFORMAT_PREFIX-smile-$CURRENT_VERSION.jar" $OUT/$DATAFORMAT_PREFIX-smile.jar 27 28PROJECT_JARS="$DATAFORMAT_PREFIX-cbor.jar $DATAFORMAT_PREFIX-smile.jar" 29 30DEPENDENCIES="jackson-core jackson-databind jackson-annotations" 31for dependency in $DEPENDENCIES; do 32 cd $SRC/$dependency 33 mvn package $MAVEN_ARGS 34 current_version=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \ 35 -Dexpression=project.version -q -DforceStdout) 36 cp "target/$dependency-$current_version.jar" $OUT/$dependency.jar 37done 38 39FUZZER_JARS=$(echo $DEPENDENCIES | xargs printf -- "%s.jar ") 40 41ALL_JARS="$PROJECT_JARS $FUZZER_JARS" 42 43# The classpath at build-time includes the project jars in $OUT as well as the 44# Jazzer API. 45BUILD_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "$OUT/%s:"):$JAZZER_API_PATH 46 47# All .jar and .class files lie in the same directory as the fuzzer at runtime. 48RUNTIME_CLASSPATH=$(echo $ALL_JARS | xargs printf -- "\$this_dir/%s:"):\$this_dir 49 50for fuzzer in $(find $SRC -name '*Fuzzer.java'); do 51 fuzzer_basename=$(basename -s .java $fuzzer) 52 javac -cp $BUILD_CLASSPATH $fuzzer 53 cp $SRC/$fuzzer_basename.class $OUT/ 54 55 # Create an execution wrapper that executes Jazzer with the correct arguments. 56 echo "#!/bin/sh 57# LLVMFuzzerTestOneInput for fuzzer detection. 58this_dir=\$(dirname \"\$0\") 59LD_LIBRARY_PATH=\"$JVM_LD_LIBRARY_PATH\":\$this_dir \ 60\$this_dir/jazzer_driver --agent_path=\$this_dir/jazzer_agent_deploy.jar \ 61--cp=$RUNTIME_CLASSPATH \ 62--target_class=$fuzzer_basename \ 63--jvm_args=\"-Xmx2048m\" \ 64\$@" > $OUT/$fuzzer_basename 65 chmod +x $OUT/$fuzzer_basename 66done 67