mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-27 04:00:43 +00:00
FUZZ用例补齐
Signed-off-by: 不名 <lizhirong4@huawei.com>
This commit is contained in:
parent
1df0fbe0bf
commit
19f61f5133
@ -22,5 +22,10 @@ group("fuzztest") {
|
||||
"cmdqueryohosaccountinfostub_fuzzer:CmdQueryOhosAccountInfoStubFuzzTest",
|
||||
"cmdsetohosaccountinfostub_fuzzer:CmdSetOhosAccountInfoStubFuzzTest",
|
||||
"cmdupdateohosaccountinfostub_fuzzer:CmdUpdateOhosAccountInfoStubFuzzTest",
|
||||
"cmdgetaccountiamservicestub_fuzzer:CmdGetAccountIAMServiceStubFuzzTest",
|
||||
"cmdgetappaccountservicestub_fuzzer:CmdGetAppAccountServiceStubFuzzTest",
|
||||
"cmdgetosaccountservicestub_fuzzer:CmdGetOsAccountServiceStubFuzzTest",
|
||||
"cmdgetdomainaccountservicestub_fuzzer:CmdGetDomainAccountServiceStubFuzzTest",
|
||||
"cmdsetohosaccountinfobyuseridstub_fuzzer:CmdSetOhosAccountInfoByUserIdStubFuzzTest"
|
||||
]
|
||||
}
|
||||
|
@ -0,0 +1,75 @@
|
||||
# Copyright (c) 2023 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.
|
||||
|
||||
import("../../../../os_account.gni")
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("CmdGetAccountIAMServiceStubFuzzTest") {
|
||||
module_out_path = fuzz_output_path
|
||||
|
||||
fuzz_config_file = "."
|
||||
include_dirs = [
|
||||
"${innerkits_path}/include",
|
||||
"${os_account_core_path}/include",
|
||||
"${os_account_interfaces_native_path}/include",
|
||||
"${os_account_path}/dfx/hidumper_adapter",
|
||||
"${os_account_path}/dfx/hitrace_adapter",
|
||||
"${services_path}/accountmgr/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
sources = [
|
||||
"${app_account_services_path}/src/account_mgr_service.cpp",
|
||||
"cmdgetaccountiamservicestub_fuzzer.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${os_account_path}/frameworks/appaccount/native:app_account_innerkits",
|
||||
"${os_account_path}/frameworks/common:libaccount_common",
|
||||
"${os_account_path}/services/accountmgr:accountmgr",
|
||||
"${os_account_path}/services/accountmgr/src/appaccount:app_account_service_core",
|
||||
"//third_party/selinux:libselinux",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"ACCOUNT_LOG_TAG = \"AppAccountFuzzTest\"",
|
||||
"LOG_DOMAIN = 0xD001B00",
|
||||
]
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 "cmdgetaccountiamservicestub_fuzzer.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "src/callbacks.h"
|
||||
|
||||
#define private public
|
||||
#include "account_mgr_service.h"
|
||||
#undef private
|
||||
#include "iaccount.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
const std::u16string ACCOUNT_TOKEN = u"ohos.accountfwk.IAccount";
|
||||
static pthread_once_t g_fcOnce = PTHREAD_ONCE_INIT;
|
||||
}
|
||||
|
||||
static int SelinuxLog(int logLevel, const char *fmt, ...)
|
||||
{
|
||||
(void)logLevel;
|
||||
(void)fmt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SelinuxSetCallback()
|
||||
{
|
||||
union selinux_callback cb;
|
||||
cb.func_log = SelinuxLog;
|
||||
selinux_set_callback(SELINUX_CB_LOG, cb);
|
||||
}
|
||||
|
||||
bool CmdGetAccountIAMServiceStubFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
__selinux_once(g_fcOnce, SelinuxSetCallback);
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataTemp;
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
uint32_t code = static_cast<uint32_t>(AccountMgrInterfaceCode::GET_ACCOUNT_IAM_SERVICE);
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().state_ = ServiceRunningState::STATE_RUNNING;
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::CmdGetAccountIAMServiceStubFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 TEST_FUZZTEST_CMDGETACCOUNTIAMSERVICESTUB_FUZZER_H
|
||||
#define TEST_FUZZTEST_CMDGETACCOUNTIAMSERVICESTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "cmdgetaccountiamservicestub_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_CMDGETACCOUNTIAMSERVICESTUB_FUZZER_H
|
@ -0,0 +1,14 @@
|
||||
# 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.
|
||||
|
||||
FUZZ
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<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>
|
@ -0,0 +1,75 @@
|
||||
# Copyright (c) 2023 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.
|
||||
|
||||
import("../../../../os_account.gni")
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("CmdGetAppAccountServiceStubFuzzTest") {
|
||||
module_out_path = fuzz_output_path
|
||||
|
||||
fuzz_config_file = "."
|
||||
include_dirs = [
|
||||
"${innerkits_path}/include",
|
||||
"${os_account_core_path}/include",
|
||||
"${os_account_interfaces_native_path}/include",
|
||||
"${os_account_path}/dfx/hidumper_adapter",
|
||||
"${os_account_path}/dfx/hitrace_adapter",
|
||||
"${services_path}/accountmgr/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
sources = [
|
||||
"${app_account_services_path}/src/account_mgr_service.cpp",
|
||||
"cmdgetappaccountservicestub_fuzzer.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${os_account_path}/frameworks/appaccount/native:app_account_innerkits",
|
||||
"${os_account_path}/frameworks/common:libaccount_common",
|
||||
"${os_account_path}/services/accountmgr:accountmgr",
|
||||
"${os_account_path}/services/accountmgr/src/appaccount:app_account_service_core",
|
||||
"//third_party/selinux:libselinux",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"ACCOUNT_LOG_TAG = \"AppAccountFuzzTest\"",
|
||||
"LOG_DOMAIN = 0xD001B00",
|
||||
]
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 "cmdgetappaccountservicestub_fuzzer.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "src/callbacks.h"
|
||||
|
||||
#define private public
|
||||
#include "account_mgr_service.h"
|
||||
#undef private
|
||||
#include "iaccount.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
const std::u16string ACCOUNT_TOKEN = u"ohos.accountfwk.IAccount";
|
||||
static pthread_once_t g_fcOnce = PTHREAD_ONCE_INIT;
|
||||
}
|
||||
|
||||
static int SelinuxLog(int logLevel, const char *fmt, ...)
|
||||
{
|
||||
(void)logLevel;
|
||||
(void)fmt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SelinuxSetCallback()
|
||||
{
|
||||
union selinux_callback cb;
|
||||
cb.func_log = SelinuxLog;
|
||||
selinux_set_callback(SELINUX_CB_LOG, cb);
|
||||
}
|
||||
|
||||
bool CmdGetAppAccountServiceStubFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
__selinux_once(g_fcOnce, SelinuxSetCallback);
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataTemp;
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
uint32_t code = static_cast<uint32_t>(AccountMgrInterfaceCode::GET_APP_ACCOUNT_SERVICE);
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().state_ = ServiceRunningState::STATE_RUNNING;
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::CmdGetAppAccountServiceStubFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 TEST_FUZZTEST_CMDGETAPPACCOUNTSERVICESTUB_FUZZER_H
|
||||
#define TEST_FUZZTEST_CMDGETAPPACCOUNTSERVICESTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "cmdgetappaccountservicestub_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_CMDGETAPPACCOUNTSERVICESTUB_FUZZER_H
|
@ -0,0 +1,14 @@
|
||||
# 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.
|
||||
|
||||
FUZZ
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<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>
|
@ -0,0 +1,75 @@
|
||||
# Copyright (c) 2023 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.
|
||||
|
||||
import("../../../../os_account.gni")
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("CmdGetDomainAccountServiceStubFuzzTest") {
|
||||
module_out_path = fuzz_output_path
|
||||
|
||||
fuzz_config_file = "."
|
||||
include_dirs = [
|
||||
"${innerkits_path}/include",
|
||||
"${os_account_core_path}/include",
|
||||
"${os_account_interfaces_native_path}/include",
|
||||
"${os_account_path}/dfx/hidumper_adapter",
|
||||
"${os_account_path}/dfx/hitrace_adapter",
|
||||
"${services_path}/accountmgr/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
sources = [
|
||||
"${app_account_services_path}/src/account_mgr_service.cpp",
|
||||
"cmdgetdomainaccountservicestub_fuzzer.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${os_account_path}/frameworks/appaccount/native:app_account_innerkits",
|
||||
"${os_account_path}/frameworks/common:libaccount_common",
|
||||
"${os_account_path}/services/accountmgr:accountmgr",
|
||||
"${os_account_path}/services/accountmgr/src/appaccount:app_account_service_core",
|
||||
"//third_party/selinux:libselinux",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"ACCOUNT_LOG_TAG = \"AppAccountFuzzTest\"",
|
||||
"LOG_DOMAIN = 0xD001B00",
|
||||
]
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 "cmdgetdomainaccountservicestub_fuzzer.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "src/callbacks.h"
|
||||
|
||||
#define private public
|
||||
#include "account_mgr_service.h"
|
||||
#undef private
|
||||
#include "iaccount.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
const std::u16string ACCOUNT_TOKEN = u"ohos.accountfwk.IAccount";
|
||||
static pthread_once_t g_fcOnce = PTHREAD_ONCE_INIT;
|
||||
}
|
||||
|
||||
static int SelinuxLog(int logLevel, const char *fmt, ...)
|
||||
{
|
||||
(void)logLevel;
|
||||
(void)fmt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SelinuxSetCallback()
|
||||
{
|
||||
union selinux_callback cb;
|
||||
cb.func_log = SelinuxLog;
|
||||
selinux_set_callback(SELINUX_CB_LOG, cb);
|
||||
}
|
||||
|
||||
bool CmdGetDomainAccountServiceStubFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
__selinux_once(g_fcOnce, SelinuxSetCallback);
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataTemp;
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
uint32_t code = static_cast<uint32_t>(AccountMgrInterfaceCode::GET_DOMAIN_ACCOUNT_SERVICE);
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().state_ = ServiceRunningState::STATE_RUNNING;
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::CmdGetDomainAccountServiceStubFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 TEST_FUZZTEST_CMDGETDOMAINACCOUNTSERVICESTUB_FUZZER_H
|
||||
#define TEST_FUZZTEST_CMDGETDOMAINACCOUNTSERVICESTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "cmdgetdomainaccountservicestub_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_CMDGETDOMAINACCOUNTSERVICESTUB_FUZZER_H
|
@ -0,0 +1,14 @@
|
||||
# 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.
|
||||
|
||||
FUZZ
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<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>
|
@ -0,0 +1,75 @@
|
||||
# Copyright (c) 2023 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.
|
||||
|
||||
import("../../../../os_account.gni")
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("CmdGetOsAccountServiceStubFuzzTest") {
|
||||
module_out_path = fuzz_output_path
|
||||
|
||||
fuzz_config_file = "."
|
||||
include_dirs = [
|
||||
"${innerkits_path}/include",
|
||||
"${os_account_core_path}/include",
|
||||
"${os_account_interfaces_native_path}/include",
|
||||
"${os_account_path}/dfx/hidumper_adapter",
|
||||
"${os_account_path}/dfx/hitrace_adapter",
|
||||
"${services_path}/accountmgr/include",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
sources = [
|
||||
"${app_account_services_path}/src/account_mgr_service.cpp",
|
||||
"cmdgetosaccountservicestub_fuzzer.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${os_account_path}/frameworks/appaccount/native:app_account_innerkits",
|
||||
"${os_account_path}/frameworks/common:libaccount_common",
|
||||
"${os_account_path}/services/accountmgr:accountmgr",
|
||||
"${os_account_path}/services/accountmgr/src/appaccount:app_account_service_core",
|
||||
"//third_party/selinux:libselinux",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"ACCOUNT_LOG_TAG = \"AppAccountFuzzTest\"",
|
||||
"LOG_DOMAIN = 0xD001B00",
|
||||
]
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 "cmdgetosaccountservicestub_fuzzer.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "src/callbacks.h"
|
||||
|
||||
#define private public
|
||||
#include "account_mgr_service.h"
|
||||
#undef private
|
||||
#include "iaccount.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
const std::u16string ACCOUNT_TOKEN = u"ohos.accountfwk.IAccount";
|
||||
static pthread_once_t g_fcOnce = PTHREAD_ONCE_INIT;
|
||||
}
|
||||
|
||||
static int SelinuxLog(int logLevel, const char *fmt, ...)
|
||||
{
|
||||
(void)logLevel;
|
||||
(void)fmt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SelinuxSetCallback()
|
||||
{
|
||||
union selinux_callback cb;
|
||||
cb.func_log = SelinuxLog;
|
||||
selinux_set_callback(SELINUX_CB_LOG, cb);
|
||||
}
|
||||
|
||||
bool CmdGetOsAccountServiceStubFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
__selinux_once(g_fcOnce, SelinuxSetCallback);
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel dataTemp;
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
uint32_t code = static_cast<uint32_t>(AccountMgrInterfaceCode::GET_OS_ACCOUNT_SERVICE);
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().state_ = ServiceRunningState::STATE_RUNNING;
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::CmdGetOsAccountServiceStubFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 TEST_FUZZTEST_CMDGETOSACCOUNTSERVICESTUB_FUZZER_H
|
||||
#define TEST_FUZZTEST_CMDGETOSACCOUNTSERVICESTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "cmdgetosaccountservicestub_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_CMDGETOSACCOUNTSERVICESTUB_FUZZER_H
|
@ -0,0 +1,14 @@
|
||||
# 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.
|
||||
|
||||
FUZZ
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<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>
|
@ -0,0 +1,75 @@
|
||||
# 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.
|
||||
|
||||
import("../../../../os_account.gni")
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("CmdSetOhosAccountInfoByUserIdStubFuzzTest") {
|
||||
module_out_path = fuzz_output_path
|
||||
|
||||
fuzz_config_file = "."
|
||||
include_dirs = [
|
||||
"${innerkits_path}/include",
|
||||
"${os_account_core_path}/include",
|
||||
"${os_account_interfaces_native_path}/include",
|
||||
"${os_account_path}/dfx/hidumper_adapter",
|
||||
"${os_account_path}/dfx/hitrace_adapter",
|
||||
"${services_path}/accountmgr/include",
|
||||
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
|
||||
]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
sources = [
|
||||
"${app_account_services_path}/src/account_mgr_service.cpp",
|
||||
"cmdsetohosaccountinfobyuseridstub_fuzzer.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${os_account_path}/frameworks/appaccount/native:app_account_innerkits",
|
||||
"${os_account_path}/frameworks/common:libaccount_common",
|
||||
"${os_account_path}/services/accountmgr:accountmgr",
|
||||
"${os_account_path}/services/accountmgr/src/appaccount:app_account_service_core",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"ACCOUNT_LOG_TAG = \"AppAccountFuzzTest\"",
|
||||
"LOG_DOMAIN = 0xD001B00",
|
||||
]
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* 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 "cmdsetohosaccountinfobyuseridstub_fuzzer.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define private public
|
||||
#include "account_mgr_service.h"
|
||||
#undef private
|
||||
#include "fuzz_data.h"
|
||||
#include "iaccount.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
const std::u16string ACCOUNT_TOKEN = u"ohos.accountfwk.IAccount";
|
||||
bool WriteOhosAccountInfo(MessageParcel &data, const OhosAccountInfo &ohosAccountInfo)
|
||||
{
|
||||
if (!data.WriteString16(Str8ToStr16(ohosAccountInfo.name_))) {
|
||||
ACCOUNT_LOGE("write name failed!");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteString16(Str8ToStr16(ohosAccountInfo.uid_))) {
|
||||
ACCOUNT_LOGE("write uid failed!");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteString16(Str8ToStr16(ohosAccountInfo.GetRawUid()))) {
|
||||
ACCOUNT_LOGE("write rawUid failed!");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(ohosAccountInfo.status_)) {
|
||||
ACCOUNT_LOGE("write status failed!");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteString16(Str8ToStr16(ohosAccountInfo.nickname_))) {
|
||||
ACCOUNT_LOGE("write nickname failed!");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(ohosAccountInfo.avatar_.size() + 1)) {
|
||||
ACCOUNT_LOGE("write avatarSize failed!");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteRawData(ohosAccountInfo.avatar_.c_str(), ohosAccountInfo.avatar_.size() + 1)) {
|
||||
ACCOUNT_LOGE("write avatar failed!");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteParcelable(&(ohosAccountInfo.scalableData_))) {
|
||||
ACCOUNT_LOGE("write scalableData failed!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdSetOhosAccountInfoByUserIdStubFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
if ((data == nullptr) || (size == 0)) {
|
||||
return false;
|
||||
}
|
||||
MessageParcel dataTemp;
|
||||
|
||||
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FuzzData fuzzData(data, size);
|
||||
OhosAccountInfo ohosAccountInfo;
|
||||
ohosAccountInfo.name_ = fuzzData.GenerateRandomString();
|
||||
ohosAccountInfo.uid_ = fuzzData.GenerateRandomString();
|
||||
ohosAccountInfo.status_ = fuzzData.GetData<int32_t>();
|
||||
ohosAccountInfo.callingUid_ = fuzzData.GetData<int32_t>();
|
||||
ohosAccountInfo.nickname_ = fuzzData.GenerateRandomString();
|
||||
ohosAccountInfo.avatar_ = fuzzData.GenerateRandomString();
|
||||
|
||||
if (!WriteOhosAccountInfo(dataTemp, ohosAccountInfo)) {
|
||||
ACCOUNT_LOGE("Write ohosAccountInfo failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string eventStr = fuzzData.GenerateRandomString();
|
||||
if (!dataTemp.WriteString16(Str8ToStr16(eventStr))) {
|
||||
ACCOUNT_LOGE("Write eventStr failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t userId = fuzzData.GetData<int32_t>();
|
||||
if (!dataTemp.WriteInt32(userId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
uint32_t code = static_cast<uint32_t>(AccountMgrInterfaceCode::SET_OHOS_ACCOUNT_INFO_BY_USER_ID);
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().state_ = ServiceRunningState::STATE_RUNNING;
|
||||
DelayedRefSingleton<AccountMgrService>::GetInstance().OnRemoteRequest(code, dataTemp, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::CmdSetOhosAccountInfoByUserIdStubFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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 TEST_FUZZTEST_CMDSETOHOSACCOUNTINFOBYUSERIDSTUB_FUZZER_H
|
||||
#define TEST_FUZZTEST_CMDSETOHOSACCOUNTINFOBYUSERIDSTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "cmdsetohosaccountinfobyuseridstub_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_CMDSETOHOSACCOUNTINFOBYUSERIDSTUB_FUZZER_H
|
||||
|
@ -0,0 +1,14 @@
|
||||
# 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.
|
||||
|
||||
FUZZ
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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.
|
||||
-->
|
||||
<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>
|
@ -55,10 +55,19 @@ ohos_fuzztest("ProcAddServerConfigStubFuzzTest") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = [
|
||||
|
@ -56,9 +56,18 @@ ohos_fuzztest("ProcGetAccountServerConfigStubFuzzTest") {
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = [
|
||||
|
@ -56,9 +56,18 @@ ohos_fuzztest("ProcRemoveServerConfigStubFuzzTest") {
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
"kv_store:distributeddata_inner",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
defines = [
|
||||
|
@ -69,9 +69,9 @@ ohos_fuzztest("GetAvailableStatusStubFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"access_token:libnativetoken_shared",
|
||||
"access_token:libtokenid_sdk",
|
||||
"access_token:libtokensetproc_shared",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
|
@ -69,9 +69,9 @@ ohos_fuzztest("OpenSessionStubFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"access_token:libnativetoken_shared",
|
||||
"access_token:libtokenid_sdk",
|
||||
"access_token:libtokensetproc_shared",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
|
Loading…
Reference in New Issue
Block a user