mirror of https://github.com/google/oss-fuzz.git
[brpc] initial integration (#8887)
Integration of brpc. Signed-off-by: 0x34d <ajsinghyadav00@gmail.com>
This commit is contained in:
parent
ca045844c4
commit
5e4fb0be81
|
@ -0,0 +1,30 @@
|
|||
--- CMakeLists.txt 2022-10-29 16:48:38.253513165 +0530
|
||||
+++ CMakeLists.txt.backup 2022-10-29 16:52:45.751660599 +0530
|
||||
@@ -51,7 +51,7 @@
|
||||
message(FATAL_ERROR "Googletest is not available")
|
||||
endif()
|
||||
|
||||
-set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DBRPC_WITH_RDMA=${WITH_RDMA_VAL} -DGFLAGS_NS=${GFLAGS_NS}")
|
||||
+set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DBRPC_WITH_RDMA=${WITH_RDMA_VAL} -DGFLAGS_NS=${GFLAGS_NS}")
|
||||
set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__=__unused__ -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DUNIT_TEST -Dprivate=public -Dprotected=public -DBVAR_NOT_LINK_DEFAULT_VARIABLES -D__STRICT_ANSI__ -include ${PROJECT_SOURCE_DIR}/test/sstream_workaround.h")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -g -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer")
|
||||
use_cxx11()
|
||||
@@ -196,7 +196,7 @@
|
||||
set_property(TARGET ${BUTIL_DEBUG_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
|
||||
set_property(TARGET ${SOURCES_DEBUG_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
|
||||
|
||||
-add_library(brpc-shared-debug SHARED $<TARGET_OBJECTS:BUTIL_DEBUG_LIB>
|
||||
+add_library(brpc-shared-debug STATIC $<TARGET_OBJECTS:BUTIL_DEBUG_LIB>
|
||||
$<TARGET_OBJECTS:SOURCES_DEBUG_LIB>
|
||||
$<TARGET_OBJECTS:PROTO_LIB>)
|
||||
# change the debug lib output dir to be different from the release output
|
||||
@@ -252,3 +252,9 @@
|
||||
${GPERFTOOLS_LIBRARIES})
|
||||
add_test(NAME ${BRPC_UT_WE} COMMAND ${BRPC_UT_WE})
|
||||
endforeach()
|
||||
+
|
||||
+add_executable(Fuzz_json Fuzz_json.cpp $<TARGET_OBJECTS:TEST_PROTO_LIB>)
|
||||
+target_link_libraries(Fuzz_json brpc-shared-debug ${LIB_FUZZING_ENGINE} -lsnappy)
|
||||
+
|
||||
+add_executable(Fuzz_http Fuzz_http.cpp $<TARGET_OBJECTS:TEST_PROTO_LIB>)
|
||||
+target_link_libraries(Fuzz_http brpc-shared-debug ${LIB_FUZZING_ENGINE} -lsnappy)
|
|
@ -0,0 +1,24 @@
|
|||
# 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
|
||||
RUN apt-get update && apt-get install -y cmake libgflags-dev libprotobuf-dev libprotoc-dev protobuf-compiler libleveldb-dev libgtest-dev libgoogle-perftools-dev libsnappy-dev
|
||||
RUN git clone --depth 1 https://github.com/apache/incubator-brpc brpc
|
||||
RUN git clone https://github.com/0x34d/oss-fuzz-bloat
|
||||
COPY build.sh $SRC/
|
||||
COPY Fuzz_http.cpp $SRC/brpc/test/Fuzz_http.cpp
|
||||
COPY Fuzz_json.cpp $SRC/brpc/test/Fuzz_json.cpp
|
||||
COPY CMakeLists.txt.patch $SRC/brpc/test/CMakeLists.txt.patch
|
||||
WORKDIR $SRC/brpc/
|
|
@ -0,0 +1,33 @@
|
|||
/* 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.
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include "brpc/server.h"
|
||||
#include "brpc/details/http_message.h"
|
||||
#include "brpc/policy/http_rpc_protocol.h"
|
||||
#include "echo.pb.h"
|
||||
|
||||
#define kMinInputLength 5
|
||||
#define kMaxInputLength 1024
|
||||
|
||||
extern "C" int
|
||||
LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
||||
{/*incubator-brpc/test/brpc_http_message_unittest.cpp*/
|
||||
|
||||
if (Size < kMinInputLength || Size > kMaxInputLength){
|
||||
return 0;
|
||||
}
|
||||
|
||||
brpc::HttpMessage http_message;
|
||||
http_message.ParseFromArray((char *)Data, Size);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/* 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.
|
||||
*/
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include "json2pb/json_to_pb.h"
|
||||
#include "addressbook1.pb.h"
|
||||
|
||||
#define kMinInputLength 5
|
||||
#define kMaxInputLength 1024
|
||||
|
||||
extern "C" int
|
||||
LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
|
||||
{/*incubator-brpc/test/brpc_protobuf_json_unittest.cpp*/
|
||||
|
||||
if (Size < kMinInputLength || Size > kMaxInputLength){
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string error;
|
||||
JsonContextBody data;
|
||||
std::string input_data((char *)Data,Size);
|
||||
|
||||
json2pb::JsonToProtoMessage(input_data, &data, &error);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -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.
|
||||
#
|
||||
################################################################################
|
||||
pushd test/
|
||||
patch < CMakeLists.txt.patch
|
||||
popd
|
||||
|
||||
mkdir build && cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_UNIT_TESTS=ON -DBUILD_SHARED_LIBS=OFF \
|
||||
-DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \
|
||||
-DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CFLAGS" \
|
||||
-DCMAKE_CPP_FLAGS="$CFLAGS" -DCMAKE_EXE_LINKER_FLAGS="$CFLAGS" \
|
||||
-DLIB_FUZZING_ENGINE="$LIB_FUZZING_ENGINE" \
|
||||
../
|
||||
|
||||
make -j$(nproc)
|
||||
|
||||
pushd test/
|
||||
cp Fuzz_json $OUT/Fuzz_json
|
||||
cp Fuzz_http $OUT/Fuzz_http
|
||||
popd
|
||||
pushd $SRC/oss-fuzz-bloat/brpc/
|
||||
cp Fuzz_json_seed_corpus.zip $OUT/Fuzz_json_seed_corpus.zip
|
||||
cp Fuzz_http_seed_corpus.zip $OUT/Fuzz_http_seed_corpus.zip
|
||||
popd
|
||||
|
||||
pushd $OUT/
|
||||
mkdir $OUT/lib/
|
||||
patchelf --set-rpath '$ORIGIN/lib' Fuzz_json
|
||||
patchelf --set-rpath '$ORIGIN/lib' Fuzz_http
|
||||
popd
|
||||
|
||||
pushd /lib/x86_64-linux-gnu/
|
||||
cp libgflags* $OUT/lib/.
|
||||
cp libprotobuf* $OUT/lib/.
|
||||
cp libleveldb* $OUT/lib/.
|
||||
cp libprotoc* $OUT/lib/.
|
||||
cp libsnappy* $OUT/lib/.
|
||||
popd
|
|
@ -0,0 +1,17 @@
|
|||
homepage: "https://brpc.apache.org"
|
||||
language: c++
|
||||
primary_contact: "security@apache.org"
|
||||
vendor_ccs:
|
||||
- "zhujiashun2010@gmail.com"
|
||||
- "wangweibing@baidu.com"
|
||||
- "serverglen@gmail.com"
|
||||
- "jerrytan@apache.org"
|
||||
auto_ccs:
|
||||
- "ajsinghyadav00@gmail.com"
|
||||
fuzzing_engines:
|
||||
- libfuzzer
|
||||
- afl
|
||||
- honggfuzz
|
||||
sanitizers:
|
||||
- address
|
||||
main_repo: 'https://github.com/apache/incubator-brpc'
|
Loading…
Reference in New Issue