spring-framework: initial integration (#7857)

Initial integration
This commit is contained in:
psy 2022-06-14 19:05:46 +02:00 committed by GitHub
parent 96758d6957
commit bc64e722b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,12 @@
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
import org.springframework.http.ContentDisposition;
import org.springframework.util.Assert;
public class ContentDispositionFuzzer {
public static void fuzzerTestOneInput(FuzzedDataProvider data) {
String value = data.consumeRemainingAsString();
try {
ContentDisposition content = ContentDisposition.parse(value);
} catch (IllegalArgumentException e) {}
}
}

View File

@ -0,0 +1,31 @@
# Copyright 2022 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
ARG java_home="/out/open-jdk-17"
RUN mkdir -p $java_home
RUN apt update && apt install -y openjdk-17-jdk
ENV JAVA_HOME $java_home
ENV PATH "${java_home}:${PATH}"
ENV JVM_LD_LIBRARY_PATH "$java_home/lib/server"
RUN git clone --depth 1 https://github.com/spring-projects/spring-framework
COPY build.sh $SRC/
COPY *Fuzzer.java $SRC/
WORKDIR $SRC/spring-framework

View File

@ -0,0 +1,70 @@
#!/bin/bash -eu
# Copyright 2022 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.
#
################################################################################
cp -r "/usr/lib/jvm/java-17-openjdk-amd64/." "$JAVA_HOME" || true
cat > patch.diff <<- EOM
diff --git a/spring-core/spring-core.gradle b/spring-core/spring-core.gradle
index d9ce720..dc4e1c6 100644
--- a/spring-core/spring-core.gradle
+++ b/spring-core/spring-core.gradle
@@ -3,6 +3,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
description = "Spring Core"
apply plugin: "kotlin"
+apply plugin: 'com.github.johnrengelman.shadow'
// spring-core includes asm, javapoet and repackages cglib, inlining all into the
// spring-core jar. cglib itself depends on asm and is therefore further transformed by
EOM
git apply patch.diff
CURRENT_VERSION=$(./gradlew properties --console=plain | sed -nr "s/^version:\ (.*)/\1/p")
./gradlew build -x test -i -x javadoc
./gradlew shadowJar --build-file spring-core/spring-core.gradle -x javadoc
cp "spring-core/build/libs/spring-core-$CURRENT_VERSION-all.jar" "$OUT/spring-core.jar"
cp "spring-web/build/libs/spring-web-$CURRENT_VERSION.jar" "$OUT/spring-web.jar"
ALL_JARS="spring-web.jar spring-core.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 -name '*Fuzzer.java'); do
fuzzer_basename=$(basename -s .java $fuzzer)
javac -cp $BUILD_CLASSPATH $fuzzer --release 17
cp $SRC/$fuzzer_basename.class $OUT/
# Create an execution wrapper that executes Jazzer with the correct arguments.
echo "#!/bin/sh
# LLVMFuzzerTestOneInput for fuzzer detection.
this_dir=\$(dirname \"\$0\")
JAVA_HOME=\"\$this_dir/open-jdk-17/\" \
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=\"-Xmx2048m\" \
\$@" > $OUT/$fuzzer_basename
chmod u+x $OUT/$fuzzer_basename
done

View File

@ -0,0 +1,12 @@
homepage: "https://github.com/spring-projects/spring-framework"
language: jvm
main_repo: "https://github.com/spring-projects/spring-framework.git"
fuzzing_engines:
- libfuzzer
sanitizers:
- address
vendor_ccs:
- "wagner@code-intelligence.com"
- "yakdan@code-intelligence.com"
- "glendowne@code-intelligence.com"
- "patrice.salathe@code-intelligence.com"