mirror of https://github.com/google/oss-fuzz.git
[osgi] Initial Integration (#8378)
* [osgi] Initial Integration * [osgi] Add trailing slashes to Docker COPY instructions
This commit is contained in:
parent
d7b7141068
commit
e51830c2d4
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
|
||||
|
||||
import org.osgi.framework.Filter;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
|
||||
import java.util.Dictionary;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class CoreFilterFuzzer {
|
||||
|
||||
Dictionary<String, String> m_dictionary;
|
||||
String m_filter;
|
||||
|
||||
CoreFilterFuzzer(FuzzedDataProvider fuzzedDataProvider) {
|
||||
m_filter = fuzzedDataProvider.consumeString(10);
|
||||
m_dictionary = new Hashtable<String, String>();
|
||||
|
||||
/*
|
||||
* build datasets
|
||||
*/
|
||||
while(fuzzedDataProvider.remainingBytes() > 0) {
|
||||
int blocksize = fuzzedDataProvider.consumeInt(1,10);
|
||||
String key = fuzzedDataProvider.consumeString(blocksize);
|
||||
m_dictionary.put(key, key);
|
||||
}
|
||||
}
|
||||
|
||||
void test() {
|
||||
Filter filter;
|
||||
try {
|
||||
filter = FrameworkUtil.createFilter(m_filter);
|
||||
} catch(InvalidSyntaxException ex) {
|
||||
/* ignore */
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
filter.match(m_dictionary);
|
||||
} catch(IllegalArgumentException ex) {
|
||||
/* ignore */
|
||||
}
|
||||
|
||||
filter.toString();
|
||||
}
|
||||
|
||||
public static void fuzzerTestOneInput(FuzzedDataProvider fuzzedDataProvider) {
|
||||
|
||||
CoreFilterFuzzer testClosure = new CoreFilterFuzzer(fuzzedDataProvider);
|
||||
testClosure.test();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
|
||||
|
||||
import org.osgi.framework.Version;
|
||||
|
||||
public class CoreVersionFuzzer {
|
||||
public static void fuzzerTestOneInput(FuzzedDataProvider fuzzedDataProvider) {
|
||||
Version v = null;
|
||||
try {
|
||||
v = new Version(fuzzedDataProvider.consumeRemainingAsString());
|
||||
} catch(IllegalArgumentException ex) {
|
||||
/* documented, ignore */
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* these don't throw exceptions
|
||||
*/
|
||||
v.getMajor();
|
||||
v.getMinor();
|
||||
v.getMicro();
|
||||
v.getQualifier();
|
||||
v.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
import com.code_intelligence.jazzer.api.FuzzedDataProvider;
|
||||
|
||||
import org.osgi.framework.Version;
|
||||
import org.osgi.framework.VersionRange;
|
||||
|
||||
public class CoreVersionRangeFuzzer {
|
||||
|
||||
int m_major, m_minor, m_micro;
|
||||
String m_range1, m_range2;
|
||||
String m_filter;
|
||||
|
||||
CoreVersionRangeFuzzer(FuzzedDataProvider fuzzedDataProvider) {
|
||||
m_major = fuzzedDataProvider.consumeInt(0, Integer.MAX_VALUE);
|
||||
m_minor = fuzzedDataProvider.consumeInt(0, Integer.MAX_VALUE);
|
||||
m_micro = fuzzedDataProvider.consumeInt(0, Integer.MAX_VALUE);
|
||||
|
||||
m_filter = fuzzedDataProvider.consumeString(5);
|
||||
m_range1 = fuzzedDataProvider.consumeString(fuzzedDataProvider.remainingBytes() / 2);
|
||||
m_range2 = fuzzedDataProvider.consumeRemainingAsString();
|
||||
}
|
||||
|
||||
void test() {
|
||||
VersionRange r1 = null, r2 = null;
|
||||
Version v;
|
||||
try {
|
||||
v = new Version(m_major, m_minor, m_micro);
|
||||
r1 = VersionRange.valueOf(m_range1);
|
||||
r2 = VersionRange.valueOf(m_range2);
|
||||
} catch(IllegalArgumentException ex) {
|
||||
/* documented, ignore */
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
r1.toFilterString(m_filter);
|
||||
} catch(IllegalArgumentException ex) {
|
||||
/* documented, ignore */
|
||||
}
|
||||
|
||||
/*
|
||||
* these don't throw exceptions
|
||||
*/
|
||||
r1.getLeft();
|
||||
r1.getRight();
|
||||
r1.includes(v);
|
||||
r1.intersection(r2);
|
||||
r1.isEmpty();
|
||||
r1.isExact();
|
||||
r1.toString();
|
||||
r1.hashCode();
|
||||
r1.equals(r2);
|
||||
}
|
||||
|
||||
public static void fuzzerTestOneInput(FuzzedDataProvider fuzzedDataProvider) {
|
||||
CoreVersionRangeFuzzer testClosure = new CoreVersionRangeFuzzer(fuzzedDataProvider);
|
||||
testClosure.test();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
# 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
|
||||
|
||||
WORKDIR ${SRC}
|
||||
#
|
||||
# clone repository
|
||||
#
|
||||
RUN git clone https://github.com/osgi/osgi.git
|
||||
|
||||
COPY build.sh ${SRC}/
|
||||
COPY *.java ${SRC}/
|
||||
WORKDIR ${SRC}/osgi
|
|
@ -0,0 +1,53 @@
|
|||
#!/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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
ALL_JARS=""
|
||||
|
||||
pushd "${SRC}/osgi"
|
||||
# use bundled gradlew deployer
|
||||
./gradlew -Dorg.gradle.java.home="$(dirname $(dirname $(which javac)))"
|
||||
|
||||
find -name '*.jar' -exec cp {} ${OUT} \;
|
||||
ALL_JARS="${ALL_JARS} $(find . -name '*.jar' -exec basename {} \;)"
|
||||
popd
|
||||
|
||||
# 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
|
||||
|
||||
# compile all java files and copy them to $OUT
|
||||
javac -cp $SRC:$BUILD_CLASSPATH -g $SRC/*.java
|
||||
cp $SRC/*.class $OUT/
|
||||
|
||||
for fuzzer in $(find $SRC -name '*Fuzzer.java'); do
|
||||
fuzzer_basename=$(basename -s .java $fuzzer)
|
||||
|
||||
# Create an execution wrapper that executes Jazzer with the correct arguments.
|
||||
echo "#!/bin/sh
|
||||
# LLVMFuzzerTestOneInput for fuzzer detection.
|
||||
this_dir=\$(dirname \"\$0\")
|
||||
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
|
|
@ -0,0 +1,14 @@
|
|||
homepage: "https://docs.osgi.org/"
|
||||
language: jvm
|
||||
main_repo: "https://github.com/osgi/osgi"
|
||||
fuzzing_engines:
|
||||
- libfuzzer
|
||||
sanitizers:
|
||||
- address
|
||||
vendor_ccs:
|
||||
- "wagner@code-intelligence.com"
|
||||
- "yakdan@code-intelligence.com"
|
||||
- "glendowne@code-intelligence.com"
|
||||
- "patrice.salathe@code-intelligence.com"
|
||||
- "hlin@code-intelligence.com"
|
||||
- "schaich@code-intelligence.com"
|
Loading…
Reference in New Issue