Skip to content

Commit 44f4b89

Browse files
authored
[mp4parse-rust] Initial integration (#3322)
1 parent 5b34bb5 commit 44f4b89

File tree

3 files changed

+83
-0
lines changed

3 files changed

+83
-0
lines changed

projects/mp4parse-rust/Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2020 Google Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
################################################################################
16+
17+
FROM gcr.io/oss-fuzz-base/base-builder
18+
19+
RUN apt-get update && apt-get install -y make autoconf automake libtool curl cmake python llvm-dev libclang-dev clang
20+
21+
ENV CARGO_HOME=/rust RUSTUP_HOME=/rust/rustup PATH=$PATH:/rust/bin
22+
RUN curl https://sh.rustup.rs | sh -s -- -y --default-toolchain=nightly
23+
RUN cargo install cargo-fuzz
24+
25+
RUN git clone --depth 1 https://github.com/mozilla/mp4parse-rust mp4parse-rust
26+
WORKDIR mp4parse-rust
27+
28+
COPY build.sh $SRC/

projects/mp4parse-rust/build.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash -eu
2+
# Copyright 2020 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+
# Note: This project creates Rust fuzz targets exclusively
19+
20+
export CUSTOM_LIBFUZZER_PATH="$LIB_FUZZING_ENGINE_DEPRECATED"
21+
export CUSTOM_LIBFUZZER_STD_CXX=c++
22+
PROJECT_DIR=$SRC/mp4parse-rust
23+
24+
# Because Rust does not support sanitizers via CFLAGS/CXXFLAGS, the environment
25+
# variables are overridden with values from base-images/base-clang only
26+
27+
export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
28+
export CXXFLAGS_EXTRA="-stdlib=libc++"
29+
export CXXFLAGS="$CFLAGS $CXXFLAGS_EXTRA"
30+
export RUSTFLAGS="-Cdebuginfo=1 -Cforce-frame-pointers"
31+
32+
cd $PROJECT_DIR/mp4parse_capi/fuzz && cargo fuzz build -O --debug-assertions
33+
34+
mkdir $PROJECT_DIR/corpus
35+
cp $PROJECT_DIR/mp4parse/tests/*.mp4 $PROJECT_DIR/corpus
36+
cp $PROJECT_DIR/mp4parse_capi/tests/*.mp4 $PROJECT_DIR/corpus
37+
38+
FUZZ_TARGET_OUTPUT_DIR=$PROJECT_DIR/mp4parse_capi/fuzz/target/x86_64-unknown-linux-gnu/release
39+
for f in $SRC/mp4parse-rust/mp4parse_capi/fuzz/fuzz_targets/*.rs
40+
do
41+
FUZZ_TARGET_NAME=$(basename ${f%.*})
42+
cp $FUZZ_TARGET_OUTPUT_DIR/$FUZZ_TARGET_NAME $OUT/
43+
cp $PROJECT_DIR/mp4parse_capi/fuzz/mp4.dict $OUT/$FUZZ_TARGET_NAME.dict
44+
zip -jr $OUT/${FUZZ_TARGET_NAME}_seed_corpus.zip $PROJECT_DIR/corpus/
45+
done

projects/mp4parse-rust/project.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
homepage: "https://github.com/mozilla/mp4parse-rust"
2+
primary_contact: "[email protected]"
3+
sanitizers:
4+
- address
5+
fuzzing_engines:
6+
- libfuzzer
7+
language: rust
8+
vendor_ccs:
9+
10+

0 commit comments

Comments
 (0)