mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 06:20:07 +00:00
commit
f1aa3ff6e9
@ -22,5 +22,7 @@ group("fuzztest") {
|
||||
"distributedwant_fuzzer:fuzztest",
|
||||
"distributedwantparams_fuzzer:fuzztest",
|
||||
"dmsfreeinstallcallbackstub_fuzzer:fuzztest",
|
||||
"dschedsoftbussession_fuzzer:fuzztest",
|
||||
"dschedtransportsoftbusadapter_fuzzer:fuzztest",
|
||||
]
|
||||
}
|
||||
|
92
test/fuzztest/dschedsoftbussession_fuzzer/BUILD.gn
Normal file
92
test/fuzztest/dschedsoftbussession_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,92 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/dmsfwk/dmsfwk.gni")
|
||||
ohos_fuzztest("DSchedSoftbusSessionFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"${dms_path}/test/fuzztest/dschedsoftbussession_fuzzer",
|
||||
"${dms_path}/services/dtbschedmgr/include/",
|
||||
"${dms_path}/interfaces/innerkits/common/include/",
|
||||
"${dms_path}/services/dtbschedmgr/include/collaborate/",
|
||||
"${dms_path}/common/include/",
|
||||
"${dms_path}/services/dtbschedmgr/include/softbus_adapter/transport",
|
||||
]
|
||||
|
||||
fuzz_config_file = "${dms_path}/test/fuzztest/dschedsoftbussession_fuzzer"
|
||||
|
||||
configs = [ "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-Dprivate=public",
|
||||
]
|
||||
|
||||
sources = [ "dschedsoftbussession_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "${dms_path}/services/dtbschedmgr:distributedschedsvr" ]
|
||||
|
||||
defines = []
|
||||
if (dmsfwk_mission_manager) {
|
||||
defines += [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ]
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
"ability_base:base",
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:dataobs_manager",
|
||||
"ability_runtime:mission_info",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken_shared",
|
||||
"access_token:libtokensetproc_shared",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"cJSON:cjson",
|
||||
"c_utils:utils",
|
||||
"data_share:datashare_consumer",
|
||||
"device_auth:deviceauth_sdk",
|
||||
"device_info_manager:distributed_device_profile_common",
|
||||
"device_info_manager:distributed_device_profile_sdk",
|
||||
"device_manager:devicemanagersdk",
|
||||
"device_security_level:dslm_sdk",
|
||||
"distributed_bundle_framework:dbms_fwk",
|
||||
"dsoftbus:softbus_client",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
"hitrace:libhitracechain",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = [ ":DSchedSoftbusSessionFuzzTest" ]
|
||||
}
|
16
test/fuzztest/dschedsoftbussession_fuzzer/corpus/init
Normal file
16
test/fuzztest/dschedsoftbussession_fuzzer/corpus/init
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
FUZZ
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* 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 "dschedsoftbussession_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "dsched_data_buffer.h"
|
||||
#include "dsched_softbus_session.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
void FuzzOnBytesReceived(const uint8_t* data, size_t size)
|
||||
{
|
||||
std::shared_ptr<DSchedDataBuffer> buffer = std::make_shared<DSchedDataBuffer>(size);
|
||||
DSchedSoftbusSession dschedSoftbusSession;
|
||||
dschedSoftbusSession.OnBytesReceived(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
OHOS::DistributedSchedule::FuzzOnBytesReceived(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DSCHED_SOFTBUSS_SSESSION_FUZZER_H
|
||||
#define OHOS_DSCHED_SOFTBUSS_SSESSION_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dschedsoftbussession_fuzzer"
|
||||
|
||||
#endif
|
25
test/fuzztest/dschedsoftbussession_fuzzer/project.xml
Normal file
25
test/fuzztest/dschedsoftbussession_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
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.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
93
test/fuzztest/dschedtransportsoftbusadapter_fuzzer/BUILD.gn
Normal file
93
test/fuzztest/dschedtransportsoftbusadapter_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,93 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# 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.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/dmsfwk/dmsfwk.gni")
|
||||
ohos_fuzztest("DSchedTransportSoftbusAdapterFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"${dms_path}/test/fuzztest/dschedtransportsoftbusadapter_fuzzer",
|
||||
"${dms_path}/services/dtbschedmgr/include/",
|
||||
"${dms_path}/interfaces/innerkits/common/include/",
|
||||
"${dms_path}/services/dtbschedmgr/include/collaborate/",
|
||||
"${dms_path}/common/include/",
|
||||
"${dms_path}/services/dtbschedmgr/include/softbus_adapter/transport",
|
||||
]
|
||||
|
||||
fuzz_config_file =
|
||||
"${dms_path}/test/fuzztest/dschedtransportsoftbusadapter_fuzzer"
|
||||
|
||||
configs = [ "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-Dprivate=public",
|
||||
]
|
||||
|
||||
sources = [ "dschedtransportsoftbusadapter_fuzzer.cpp" ]
|
||||
|
||||
deps = [ "${dms_path}/services/dtbschedmgr:distributedschedsvr" ]
|
||||
|
||||
defines = []
|
||||
if (dmsfwk_mission_manager) {
|
||||
defines += [ "SUPPORT_DISTRIBUTED_MISSION_MANAGER" ]
|
||||
}
|
||||
|
||||
external_deps = [
|
||||
"ability_base:base",
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:dataobs_manager",
|
||||
"ability_runtime:mission_info",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken_shared",
|
||||
"access_token:libtokensetproc_shared",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"cJSON:cjson",
|
||||
"c_utils:utils",
|
||||
"data_share:datashare_consumer",
|
||||
"device_auth:deviceauth_sdk",
|
||||
"device_info_manager:distributed_device_profile_common",
|
||||
"device_info_manager:distributed_device_profile_sdk",
|
||||
"device_manager:devicemanagersdk",
|
||||
"device_security_level:dslm_sdk",
|
||||
"distributed_bundle_framework:dbms_fwk",
|
||||
"dsoftbus:softbus_client",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
"hitrace:libhitracechain",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = [ ":DSchedTransportSoftbusAdapterFuzzTest" ]
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
FUZZ
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* 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 "dschedtransportsoftbusadapter_fuzzer.h"
|
||||
|
||||
#include "dsched_transport_softbus_adapter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
void FuzzOnBind(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(size_t))) {
|
||||
return;
|
||||
}
|
||||
int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
|
||||
std::string peerDeviceId(reinterpret_cast<const char*>(data), size);
|
||||
DSchedTransportSoftbusAdapter dschedTransportSoftbusAdapter;
|
||||
dschedTransportSoftbusAdapter.OnBind(sessionId, peerDeviceId);
|
||||
}
|
||||
|
||||
void FuzzOnShutdown(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(size_t))) {
|
||||
return;
|
||||
}
|
||||
int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
|
||||
bool isSelfcalled = *(reinterpret_cast<const bool*>(data));
|
||||
DSchedTransportSoftbusAdapter dschedTransportSoftbusAdapter;
|
||||
dschedTransportSoftbusAdapter.OnShutdown(sessionId, isSelfcalled);
|
||||
}
|
||||
|
||||
void FuzzOnBytes(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(size_t))) {
|
||||
return;
|
||||
}
|
||||
int32_t sessionId = *(reinterpret_cast<const int32_t*>(data));
|
||||
const void* newdata = reinterpret_cast<const void*>(data);
|
||||
int32_t dataLen = *(reinterpret_cast<const int32_t*>(data));
|
||||
DSchedTransportSoftbusAdapter dschedTransportSoftbusAdapter;
|
||||
dschedTransportSoftbusAdapter.OnBytes(sessionId, newdata, dataLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
OHOS::DistributedSchedule::FuzzOnBind(data, size);
|
||||
OHOS::DistributedSchedule::FuzzOnShutdown(data, size);
|
||||
OHOS::DistributedSchedule::FuzzOnBytes(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DSCHED_TRANSPORT_SOFTBUS_ADAPTER_FUZZER_H
|
||||
#define OHOS_DSCHED_TRANSPORT_SOFTBUS_ADAPTER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dschedtransportsoftbusadapter_fuzzer"
|
||||
|
||||
#endif
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
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.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
Loading…
Reference in New Issue
Block a user