mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-27 00:20:44 +00:00
add fuzz
Signed-off-by: 师皓杰 <shihaojie10@huawei.com>
This commit is contained in:
parent
c7bc7393b0
commit
3fa1326813
@ -15,7 +15,10 @@ group("fuzztest") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
"abilityconnectionwrapperstub_fuzzer:fuzztest",
|
||||
"bundlemanagercallbackstub_fuzzer:fuzztest",
|
||||
"continuationmanager_fuzzer:fuzztest",
|
||||
"distributedschedstub_fuzzer:fuzztest",
|
||||
"dmsfreeinstallcallbackstub_fuzzer:fuzztest",
|
||||
]
|
||||
}
|
||||
|
96
test/fuzztest/abilityconnectionwrapperstub_fuzzer/BUILD.gn
Normal file
96
test/fuzztest/abilityconnectionwrapperstub_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,96 @@
|
||||
# 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("AbilityConnectionWrapperStubFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"${dms_path}/test/fuzztest/abilityconnectionwrapperstub_fuzzer",
|
||||
"${dms_path}/services/dtbschedmgr/include/",
|
||||
"${dms_path}/services/dtbschedmgr/test/unittest",
|
||||
"${dms_path}/interfaces/innerkits/common/include/",
|
||||
"${dms_path}/services/dtbschedmgr/include/collaborate/",
|
||||
"${dms_path}/common/include/",
|
||||
]
|
||||
|
||||
fuzz_config_file =
|
||||
"${dms_path}/test/fuzztest/abilityconnectionwrapperstub_fuzzer"
|
||||
|
||||
configs = [ "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-Dprivate=public",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"${dms_path}/services/dtbschedmgr/test/unittest/mock_distributed_sched.cpp",
|
||||
"abilityconnectionwrapperstub_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 = [ ":AbilityConnectionWrapperStubFuzzTest" ]
|
||||
}
|
@ -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.
|
||||
*/
|
||||
|
||||
#include "abilityconnectionwrapperstub_fuzzer.h"
|
||||
|
||||
#include "ability_connection_wrapper_stub.h"
|
||||
#include "mock_distributed_sched.h"
|
||||
#include "parcel_helper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
using namespace AAFwk;
|
||||
|
||||
bool OnAbilityConnectDoneFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(int32_t))) {
|
||||
return false;
|
||||
}
|
||||
sptr<IRemoteObject> connection(new MockDistributedSched());
|
||||
std::string localDeviceId(reinterpret_cast<const char*>(data), size);
|
||||
std::shared_ptr<AbilityConnectionWrapperStub> abilityConnection_ =
|
||||
std::make_shared<AbilityConnectionWrapperStub>(connection, localDeviceId);
|
||||
uint32_t code = IAbilityConnection::ON_ABILITY_CONNECT_DONE;
|
||||
int32_t resultCode = *(reinterpret_cast<const int32_t*>(data));
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
dataParcel.WriteInt32(resultCode);
|
||||
abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
|
||||
std::u16string descriptor = IAbilityConnection::GetDescriptor();
|
||||
dataParcel.WriteInterfaceToken(descriptor);
|
||||
abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
|
||||
std::string str1(reinterpret_cast<const char*>(data), size);
|
||||
std::string str2(reinterpret_cast<const char*>(data), size);
|
||||
std::string str3(reinterpret_cast<const char*>(data), size);
|
||||
AppExecFwk::ElementName element(str1, str2, str3);
|
||||
dataParcel.WriteParcelable(&element);
|
||||
abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
|
||||
dataParcel.WriteRemoteObject(connection);
|
||||
abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnAbilityDisconnectDoneFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(int32_t))) {
|
||||
return false;
|
||||
}
|
||||
sptr<IRemoteObject> connection(new MockDistributedSched());
|
||||
std::shared_ptr<AbilityConnectionWrapperStub> abilityConnection_ =
|
||||
std::make_shared<AbilityConnectionWrapperStub>(connection);
|
||||
uint32_t code = IAbilityConnection::ON_ABILITY_DISCONNECT_DONE;
|
||||
int32_t resultCode = *(reinterpret_cast<const int32_t*>(data));
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
dataParcel.WriteInt32(resultCode);
|
||||
std::string str1(reinterpret_cast<const char*>(data), size);
|
||||
std::string str2(reinterpret_cast<const char*>(data), size);
|
||||
std::string str3(reinterpret_cast<const char*>(data), size);
|
||||
std::u16string descriptor = IAbilityConnection::GetDescriptor();
|
||||
dataParcel.WriteInterfaceToken(descriptor);
|
||||
AppExecFwk::ElementName element(str1, str2, str3);
|
||||
dataParcel.WriteParcelable(&element);
|
||||
dataParcel.WriteRemoteObject(connection);
|
||||
abilityConnection_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
OHOS::DistributedSchedule::OnAbilityConnectDoneFuzzTest(data, size);
|
||||
OHOS::DistributedSchedule::OnAbilityDisconnectDoneFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITYCONNECTIONWRAPPERSTUB_FUZZER_H
|
||||
#define OHOS_ABILITYCONNECTIONWRAPPERSTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "abilityconnectionwrapperstub_fuzzer"
|
||||
|
||||
#endif
|
@ -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,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>
|
91
test/fuzztest/bundlemanagercallbackstub_fuzzer/BUILD.gn
Normal file
91
test/fuzztest/bundlemanagercallbackstub_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,91 @@
|
||||
# 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("BundleManagerCallBackStubFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"${dms_path}/test/fuzztest/bundlemanagercallbackstub_fuzzer",
|
||||
"${dms_path}/services/dtbschedmgr/include/",
|
||||
"${dms_path}/interfaces/innerkits/common/include/",
|
||||
"${dms_path}/services/dtbschedmgr/include/collaborate/",
|
||||
"${dms_path}/common/include/",
|
||||
]
|
||||
|
||||
fuzz_config_file = "${dms_path}/test/fuzztest/bundlemanagercallbackstub_fuzzer"
|
||||
|
||||
configs = [ "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-Dprivate=public",
|
||||
]
|
||||
|
||||
sources = [ "bundlemanagercallbackstub_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 = [ ":BundleManagerCallBackStubFuzzTest" ]
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 "bundlemanagercallbackstub_fuzzer.h"
|
||||
|
||||
#include "bundle/bundle_manager_callback_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
|
||||
bool OnQueryInstallationFinishedInnerFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(int32_t))) {
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<DmsBundleManagerCallbackStub> bundleManager_ =
|
||||
std::make_shared<DmsBundleManagerCallbackStub>();
|
||||
uint32_t code = 0;
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
bundleManager_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
|
||||
std::u16string descriptor = bundleManager_->GetDescriptor();
|
||||
dataParcel.WriteInterfaceToken(descriptor);
|
||||
bundleManager_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
|
||||
code = static_cast<uint32_t>(IDBundleManagerCallbackInterfaceCod::ON_QUERY_INSTALLATION_DONE);
|
||||
int32_t resultCode = *(reinterpret_cast<const int32_t*>(data));
|
||||
uint32_t versionCode = *(reinterpret_cast<const uint32_t*>(data));
|
||||
int32_t missionId = *(reinterpret_cast<const int32_t*>(data));
|
||||
dataParcel.WriteInt32(resultCode);
|
||||
dataParcel.WriteUint32(versionCode);
|
||||
dataParcel.WriteInt32(missionId);
|
||||
bundleManager_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
OHOS::DistributedSchedule::OnQueryInstallationFinishedInnerFuzzTest(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_BUNDLEMANAGERCALLBACKSTUB_FUZZER_H
|
||||
#define OHOS_BUNDLEMANAGERCALLBACKSTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "bundlemanagercallbackstub_fuzzer"
|
||||
|
||||
#endif
|
16
test/fuzztest/bundlemanagercallbackstub_fuzzer/corpus/init
Normal file
16
test/fuzztest/bundlemanagercallbackstub_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
|
25
test/fuzztest/bundlemanagercallbackstub_fuzzer/project.xml
Normal file
25
test/fuzztest/bundlemanagercallbackstub_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>
|
91
test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/BUILD.gn
Normal file
91
test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,91 @@
|
||||
# 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("DmsFreeInstallCallBackStubFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"${dms_path}/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer",
|
||||
"${dms_path}/services/dtbschedmgr/include/",
|
||||
"${dms_path}/interfaces/innerkits/common/include/",
|
||||
"${dms_path}/services/dtbschedmgr/include/collaborate/",
|
||||
"${dms_path}/common/include/",
|
||||
]
|
||||
|
||||
fuzz_config_file = "${dms_path}/test/fuzztest/dmsfreeinstallcallbackstub_fuzzer"
|
||||
|
||||
configs = [ "${dms_path}/services/dtbschedmgr/test/resource:coverage_flags" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
"-Dprivate=public",
|
||||
]
|
||||
|
||||
sources = [ "dmsfreeinstallcallbackstub_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 = [ ":DmsFreeInstallCallBackStubFuzzTest" ]
|
||||
}
|
16
test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/corpus/init
Normal file
16
test/fuzztest/dmsfreeinstallcallbackstub_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,66 @@
|
||||
/*
|
||||
* 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 "dmsfreeinstallcallbackstub_fuzzer.h"
|
||||
|
||||
#include "dms_free_install_callback.h"
|
||||
#include "distributed_sched_interface.h"
|
||||
#include "parcel_helper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
namespace {
|
||||
const uint32_t ONE = 1;
|
||||
}
|
||||
bool OnInstallFinishedInnerFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size < sizeof(int32_t))) {
|
||||
return false;
|
||||
}
|
||||
int64_t taskId = 0;
|
||||
IDistributedSched::FreeInstallInfo info;
|
||||
std::shared_ptr<DmsFreeInstallCallback> freeInstall_ =
|
||||
std::make_shared<DmsFreeInstallCallback>(taskId, info);
|
||||
uint32_t code = ONE;
|
||||
MessageParcel dataParcel;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
std::u16string descriptor = DmsFreeInstallCallbackStub::GetDescriptor();
|
||||
freeInstall_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
|
||||
dataParcel.WriteInterfaceToken(descriptor);
|
||||
freeInstall_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
|
||||
code = static_cast<uint32_t>(IDRreeInstallCallbackInterfaceCode::ON_FREE_INSTALL_DONE);
|
||||
int32_t resultCode = *(reinterpret_cast<const int32_t*>(data));
|
||||
int32_t requestCode = *(reinterpret_cast<const int32_t*>(data));
|
||||
dataParcel.WriteInt32(resultCode);
|
||||
dataParcel.WriteInt32(requestCode);
|
||||
freeInstall_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
|
||||
AAFwk::Want want;
|
||||
dataParcel.WriteParcelable(&want);
|
||||
freeInstall_->OnRemoteRequest(code, dataParcel, reply, option);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
OHOS::DistributedSchedule::OnInstallFinishedInnerFuzzTest(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_DMSFREEINSTALLCALLBACKSTUB_FUZZER_H
|
||||
#define OHOS_DMSFREEINSTALLCALLBACKSTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dmsfreeinstallcallbackstub_fuzzer"
|
||||
|
||||
#endif
|
25
test/fuzztest/dmsfreeinstallcallbackstub_fuzzer/project.xml
Normal file
25
test/fuzztest/dmsfreeinstallcallbackstub_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>
|
Loading…
Reference in New Issue
Block a user