oss-fuzz/infra/base-images/base-builder/install_java.sh

40 lines
2.0 KiB
Bash
Raw Normal View History

#!/bin/bash -eux
# 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.
#
################################################################################
# Install OpenJDK 15 and trim its size by removing unused components.
cd /tmp
curl -L -O https://download.java.net/java/GA/jdk15.0.2/0d1cfde4252546c6931946de8db48ee2/7/GPL/openjdk-15.0.2_linux-x64_bin.tar.gz && \
mkdir -p $JAVA_HOME
tar -xzv --strip-components=1 -f openjdk-15.0.2_linux-x64_bin.tar.gz --directory $JAVA_HOME && \
rm -f openjdk-15.0.2_linux-x64_bin.tar.gz
rm -rf $JAVA_HOME/jmods $JAVA_HOME/lib/src.zip
# Install the latest Jazzer in $OUT.
# jazzer_api_deploy.jar is required only at build-time, the agent and the
# drivers are copied to $OUT as they need to be present on the runners.
cd $SRC/
Pin Jazzer to older revision (#8275) All latest builds seem to be broken with: ``` OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended INFO: Loaded 112 hooks from com.code_intelligence.jazzer.runtime.TraceCmpHooks INFO: Loaded 4 hooks from com.code_intelligence.jazzer.runtime.TraceDivHooks INFO: Loaded 2 hooks from com.code_intelligence.jazzer.runtime.TraceIndirHooks INFO: Loaded 4 hooks from com.code_intelligence.jazzer.runtime.NativeLibHooks INFO: Loaded 8 hooks from com.code_intelligence.jazzer.sanitizers.Deserialization INFO: Loaded 5 hooks from com.code_intelligence.jazzer.sanitizers.ExpressionLanguageInjection INFO: Loaded 70 hooks from com.code_intelligence.jazzer.sanitizers.LdapInjection INFO: Loaded 46 hooks from com.code_intelligence.jazzer.sanitizers.NamingContextLookup INFO: Loaded 1 hooks from com.code_intelligence.jazzer.sanitizers.OsCommandInjection INFO: Loaded 52 hooks from com.code_intelligence.jazzer.sanitizers.ReflectiveCall INFO: Loaded 8 hooks from com.code_intelligence.jazzer.sanitizers.RegexInjection Exception in thread "main" java.lang.ExceptionInInitializerError at com.code_intelligence.jazzer.sanitizers.RegexRoadblocks.<clinit>(RegexRoadblocks.java:72) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:398) at com.code_intelligence.jazzer.instrumentor.Hooks$Companion$HooksLoader.loadHooks(Hooks.kt:66) at com.code_intelligence.jazzer.instrumentor.Hooks$Companion$HooksLoader.load(Hooks.kt:48) at com.code_intelligence.jazzer.instrumentor.Hooks$Companion.loadHooks(Hooks.kt:42) at com.code_intelligence.jazzer.agent.Agent.premain(Agent.kt:137) at com.code_intelligence.jazzer.driver.Driver.start(Driver.java:97) Caused by: java.lang.NumberFormatException: For input string: "./jazzer_driver" at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:66) at java.base/java.lang.Long.parseLong(Long.java:680) at java.base/java.lang.Integer.parseUnsignedInt(Integer.java:835) at java.base/java.lang.Integer.parseUnsignedInt(Integer.java:929) at com.code_intelligence.jazzer.api.Jazzer.getLibFuzzerSeed(Jazzer.java:635) at com.code_intelligence.jazzer.api.Jazzer.<clinit>(Jazzer.java:38) ... 8 more ```
2022-08-17 09:21:53 +00:00
git clone https://github.com/CodeIntelligenceTesting/jazzer && \
cd jazzer && \
git checkout a9cf2aa2c4e87fe6c26e49a1a6de3e424d179c1f
bazel build --java_runtime_version=local_jdk_15 -c opt --cxxopt="-stdlib=libc++" --linkopt=-lc++ \
//driver/src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar //deploy:jazzer-api //launcher:jazzer
cp $(bazel cquery --output=files //driver/src/main/java/com/code_intelligence/jazzer:jazzer_standalone_deploy.jar) /usr/local/bin/jazzer_agent_deploy.jar
cp $(bazel cquery --output=files //launcher:jazzer) /usr/local/bin/jazzer_driver
cp $(bazel cquery --output=files //deploy:jazzer-api) $JAZZER_API_PATH
rm -rf ~/.cache/bazel ~/.cache/bazelisk
rm -rf $SRC/jazzer