【帐号FUZZ_TEST】fuzz testcase fix

Signed-off-by: cclicn <lichenchen22@huawei.com>
This commit is contained in:
cclicn 2024-06-07 18:09:57 +08:00
parent ae36a69f92
commit 53891e99c9
143 changed files with 762 additions and 568 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -30,6 +30,7 @@ ohos_fuzztest("CmdGetOhosAccountInfoByUserIdStubFuzzTest") {
"${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",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -21,6 +21,7 @@
#define private public
#include "account_mgr_service.h"
#undef private
#include "fuzz_data.h"
#include "iaccount.h"
using namespace std;
@ -37,7 +38,8 @@ bool CmdGetOhosAccountInfoByUserIdStubFuzzTest(const uint8_t* data, size_t size)
return false;
}
MessageParcel dataTemp;
int32_t userId = static_cast<int32_t>(size);
FuzzData fuzzData(data, size);
int32_t userId = fuzzData.GetData<int32_t>();
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
return false;
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -30,6 +30,7 @@ ohos_fuzztest("CmdQueryOhosAccountInfoByUserIdStubFuzzTest") {
"${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",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -17,12 +17,12 @@
#include <string>
#include <vector>
#include "src/callbacks.h"
#define private public
#include "account_mgr_service.h"
#undef private
#include "fuzz_data.h"
#include "iaccount.h"
#include "src/callbacks.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -54,7 +54,8 @@ bool CmdQueryOhosAccountInfoByUserIdStubFuzzTest(const uint8_t* data, size_t siz
return false;
}
MessageParcel dataTemp;
int32_t userId = static_cast<int32_t>(size);
FuzzData fuzzData(data, size);
int32_t userId = fuzzData.GetData<int32_t>();
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
return false;
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -30,6 +30,7 @@ ohos_fuzztest("CmdSetOhosAccountInfoStubFuzzTest") {
"${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",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -21,6 +21,7 @@
#define private public
#include "account_mgr_service.h"
#undef private
#include "fuzz_data.h"
#include "iaccount.h"
using namespace std;
@ -29,6 +30,42 @@ 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 CmdSetOhosAccountInfoStubFuzzTest(const uint8_t* data, size_t size)
{
@ -39,6 +76,23 @@ bool CmdSetOhosAccountInfoStubFuzzTest(const uint8_t* data, size_t size)
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;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AccountMgrInterfaceCode::SET_OHOS_ACCOUNT_INFO);

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -30,6 +30,7 @@ ohos_fuzztest("CmdUpdateOhosAccountInfoStubFuzzTest") {
"${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",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -17,10 +17,10 @@
#include <string>
#include <vector>
#define private public
#include "account_mgr_service.h"
#undef private
#include "fuzz_data.h"
#include "iaccount.h"
using namespace std;
@ -39,6 +39,22 @@ bool CmdUpdateOhosAccountInfoStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(ACCOUNT_TOKEN)) {
return false;
}
FuzzData fuzzData(data, size);
std::string accountName = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString16(Str8ToStr16(accountName))) {
ACCOUNT_LOGE("Write accountName failed!");
return false;
}
std::string uid = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString16(Str8ToStr16(uid))) {
ACCOUNT_LOGE("Write uid failed!");
return false;
}
std::string eventStr = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString16(Str8ToStr16(eventStr))) {
ACCOUNT_LOGE("Write eventStr failed!");
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AccountMgrInterfaceCode::UPDATE_OHOS_ACCOUNT_INFO);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,14 +15,14 @@
#include "addaccountimplicitly_fuzzer.h"
#include "app_account_authenticator_callback_stub.h"
#define private public
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#define private public
#include "app_account_authenticator_callback_stub.h"
#include "app_account_manager.h"
#undef private
#include "fuzz_data.h"
#include "want.h"
using namespace std;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,13 +15,13 @@
#include "authenticate_fuzzer.h"
#include "app_account_manager.h"
#include "app_account_authenticator_callback_stub.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <cstddef>
#include <string>
#include <vector>
#include "app_account_authenticator_callback_stub.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,9 +17,9 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "app_account_common.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,12 @@
#include "checkauthtokenvisibility_fuzzer.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include "app_account_manager.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "checkoauthtokenvisibility_fuzzer.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include "app_account_manager.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,12 +15,12 @@
#include "createaccount_fuzzer.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include "app_account_manager.h"
#include "app_account_common.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "app_account_common.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,12 +15,12 @@
#include "createaccountimplicitly_fuzzer.h"
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_common.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "deleteaccountcredential_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "deleteauthtoken_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "deleteoauthtoken_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,14 +15,14 @@
#include "getallaccessibleaccounts_fuzzer.h"
#define private public
#include "app_account_manager.h"
#include "app_account_info.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
#include <string>
#include <vector>
#define private public
#include "account_log_wrapper.h"
#include "app_account_info.h"
#include "app_account_manager.h"
#undef private
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,13 +15,13 @@
#include "getalloauthtokens_fuzzer.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include "app_account_manager.h"
#include "app_account_info.h"
#include <set>
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_info.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "getauthenticatorcallback_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,12 +15,12 @@
#include "getauthenticatorinfo_fuzzer.h"
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_common.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,12 +15,12 @@
#include "getauthlist_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <set>
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,12 +15,13 @@
#include "getoauthlist_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <set>
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,13 +15,14 @@
#include "selectaccountsbyoptions_fuzzer.h"
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_common.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "setaccountcredential_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -17,8 +17,8 @@
#include <string>
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
#undef private

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "setassociateddata_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,12 +15,12 @@
#include "setauthenticatorproperties_fuzzer.h"
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_common.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "setauthtokenvisibility_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "setoauthtoken_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,11 +15,11 @@
#include "setoauthtokenvisibility_fuzzer.h"
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,12 +15,12 @@
#include "subscribeappaccount_fuzzer.h"
#include "app_account_manager.h"
#include "app_account_subscribe_info.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "app_account_subscribe_info.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,12 +15,13 @@
#include "unsubscribeappaccount_fuzzer.h"
#include "app_account_manager.h"
#include "app_account_subscribe_info.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager.h"
#include "app_account_subscribe_info.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -15,12 +15,12 @@
#include "verifycredential_fuzzer.h"
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_common.h"
#include "app_account_manager.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("AddAccountImplicitlyStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,12 +15,13 @@
#include "addaccountimplicitlystub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_authenticator_callback_stub.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -43,38 +44,34 @@ bool AddAccountImplicitlyStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
std::string owner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string owner = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(owner)) {
return false;
}
std::string authType(reinterpret_cast<const char*>(data), size);
std::string authType = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(authType)) {
return false;
}
AAFwk::Want options;
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testName = fuzzData.GenerateRandomString();
options.SetParam(Constants::KEY_CALLER_ABILITY_NAME, testName);
if (!dataTemp.WriteParcelable(&options)) {
return false;
}
sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
if (callback == nullptr) {
ACCOUNT_LOGI("AppAccountStub AddAccountImplicitly callback is null");
return false;
}
if (!dataTemp.WriteRemoteObject(callback->AsObject())) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::ADD_ACCOUNT_IMPLICITLY);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("AddAccountStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "addaccountstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -32,11 +33,12 @@ bool AddAccountStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
std::string testName(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(testName)) {
return false;
}
std::string extraInfo(reinterpret_cast<const char*>(data), size);
std::string extraInfo = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(extraInfo)) {
return false;
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("AuthenticateStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,12 +15,13 @@
#include "authenticatestub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_authenticator_callback_stub.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -39,9 +40,10 @@ bool AuthenticateStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string owner(reinterpret_cast<const char*>(data), size);
std::string name(reinterpret_cast<const char*>(data), size);
std::string authType(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string owner = fuzzData.GenerateRandomString();
std::string name = fuzzData.GenerateRandomString();
std::string authType = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -59,24 +61,19 @@ bool AuthenticateStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteParcelable(&options)) {
return false;
}
sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
if (callback == nullptr) {
ACCOUNT_LOGI("AppAccountStub Authenticate callback is null");
return false;
}
if (!dataTemp.WriteRemoteObject(callback->AsObject())) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::AUTHENTICATE);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("CheckAccountLabelsStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -14,13 +14,14 @@
*/
#include "checkaccountlabelsstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_authenticator_callback_stub.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -39,44 +40,38 @@ bool CheckAccountLabelsStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testOwner(reinterpret_cast<const char*>(data), size);
std::string testValue(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName = fuzzData.GenerateRandomString();
std::string testOwner = fuzzData.GenerateRandomString();
std::string testValue = fuzzData.GenerateRandomString();
std::vector<std::string> testLabels;
testLabels.emplace_back(testValue);
sptr<MockAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
if (callback == nullptr) {
ACCOUNT_LOGI("AppAccountStub CheckAccountLabels callback is null");
return false;
}
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
if (!dataTemp.WriteString(testName)) {
return false;
}
if (!dataTemp.WriteString(testOwner)) {
return false;
}
if (!dataTemp.WriteStringVector(testLabels)) {
return false;
}
if (!dataTemp.WriteRemoteObject(callback->AsObject())) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::CHECK_ACCOUNT_LABELS);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("CheckAppAccessStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "checkappaccessstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -30,8 +31,9 @@ bool CheckAppAccessStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string authorizedApp(reinterpret_cast<const char*>(data), size);
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string authorizedApp = fuzzData.GenerateRandomString();
std::string name = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -42,13 +44,11 @@ bool CheckAppAccessStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteString(authorizedApp)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::CHECK_APP_ACCESS);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("CheckAppAccountSyncEnableStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "checkappaccountsyncenablestub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -34,17 +35,16 @@ bool CheckAppAccountSyncEnableStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string name = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(name)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::CHECK_APP_ACCOUNT_SYNC_ENABLE);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("CheckOAuthTokenVisibilityStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -14,11 +14,13 @@
*/
#include "checkoauthtokenvisibilitystub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -29,9 +31,10 @@ bool CheckOAuthTokenVisibilityStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string bundleName(reinterpret_cast<const char*>(data), size);
std::string authType(reinterpret_cast<const char*>(data), size);
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string bundleName = fuzzData.GenerateRandomString();
std::string authType = fuzzData.GenerateRandomString();
std::string name = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -50,7 +53,6 @@ bool CheckOAuthTokenVisibilityStubFuzzTest(const uint8_t* data, size_t size)
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::CHECK_OAUTH_TOKEN_VISIBILITY);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("CreateAccountImplicitlyStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -17,11 +17,11 @@
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_authenticator_callback_stub.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -44,25 +44,22 @@ bool CreateAccountImplicitlyStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
std::string owner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string owner = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(owner)) {
return false;
}
CreateAccountImplicitlyOptions options;
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testName = fuzzData.GenerateRandomString();
options.parameters.SetParam(Constants::KEY_CALLER_ABILITY_NAME, testName);
if (!dataTemp.WriteParcelable(&options)) {
return false;
}
sptr<IAppAccountAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
if (callback == nullptr) {
ACCOUNT_LOGI("AppAccountStub CreateAccountImplicitly callback is null");
return false;
}
if (!dataTemp.WriteRemoteObject(callback->AsObject())) {
return false;
}
@ -71,7 +68,6 @@ bool CreateAccountImplicitlyStubFuzzTest(const uint8_t* data, size_t size)
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::CREATE_ACCOUNT_IMPLICITLY);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("CreateAccountStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "createaccountstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -30,10 +31,11 @@ bool CreateAccountStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string name = fuzzData.GenerateRandomString();
CreateAccountOptions options;
std::string testKey(reinterpret_cast<const char*>(data), size);
std::string testValue(reinterpret_cast<const char*>(data), size);
std::string testKey = fuzzData.GenerateRandomString();
std::string testValue = fuzzData.GenerateRandomString();
options.customData.emplace(testKey, testValue);
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
@ -42,7 +44,6 @@ bool CreateAccountStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteString(name)) {
return false;
}
if (!dataTemp.WriteParcelable(&options)) {
return false;
}
@ -51,7 +52,6 @@ bool CreateAccountStubFuzzTest(const uint8_t* data, size_t size)
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::CREATE_ACCOUNT);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("DeleteAccountCredentialStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "deleteaccountcredentialstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -31,8 +32,9 @@ bool DeleteAccountCredentialStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string credentialType(reinterpret_cast<const char*>(data), size);
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string credentialType = fuzzData.GenerateRandomString();
std::string name = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -43,13 +45,12 @@ bool DeleteAccountCredentialStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteString(credentialType)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::DELETE_ACCOUNT_CREDENTIAL);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("DeleteAccountStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "deleteaccountstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -34,17 +35,16 @@ bool DeleteAccountStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string name = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(name)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::DELETE_ACCOUNT);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("DeleteOAuthTokenStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -16,9 +16,11 @@
#include "deleteoauthtokenstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -29,10 +31,11 @@ bool DeleteOAuthTokenStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string token(reinterpret_cast<const char*>(data), size);
std::string authType(reinterpret_cast<const char*>(data), size);
std::string owner(reinterpret_cast<const char*>(data), size);
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string token = fuzzData.GenerateRandomString();
std::string authType = fuzzData.GenerateRandomString();
std::string owner = fuzzData.GenerateRandomString();
std::string name = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -54,7 +57,6 @@ bool DeleteOAuthTokenStubFuzzTest(const uint8_t* data, size_t size)
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::DELETE_OAUTH_TOKEN);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -0,0 +1,87 @@
/*
* 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 FUZZ_DATA_H
#define FUZZ_DATA_H
#include <string>
#include "securec.h"
namespace OHOS {
using namespace std;
constexpr int CONSTANTS_NUMBER_TWO = 2;
class FuzzData {
public:
explicit FuzzData(const uint8_t *data, const size_t size)
:data_(data), size_(size), pos_(0) {}
template <class T> T GetData()
{
T object{};
size_t objectSize = sizeof(object);
if (data_ == nullptr || objectSize > size_ - pos_) {
return object;
}
errno_t ret = memcpy_s(&object, objectSize, data_ + pos_, objectSize);
if (ret != EOK) {
return {};
}
pos_ += objectSize;
return object;
}
std::string GetStringFromData(size_t pos, size_t strlen)
{
if (pos > size_) {
return "test";
}
char cstr[strlen + 1];
cstr[strlen] = '\0';
pos_ = pos;
for (size_t i = 0; i < strlen; i++) {
char tmp = GetData<char>();
if (tmp == '\0') {
tmp = '1';
}
cstr[i] = tmp;
}
std::string str(cstr);
return str;
}
std::string GenerateRandomString()
{
return GetStringFromData(0, (GetData<uint32_t>() % size_));
}
template <class T> T GenerateRandomEnmu(T enmuMax)
{
return static_cast<T>(GetData<uint32_t>() % (static_cast<uint32_t>(enmuMax) + 1));
}
bool GenerateRandomBool()
{
return (GetData<uint32_t>() % CONSTANTS_NUMBER_TWO) == 0;
}
private:
const uint8_t *data_;
const size_t size_;
public:
size_t pos_;
};
} // OHOS
#endif // FUZZ_DATA_H

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("GetAccountCredentialStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "getaccountcredentialstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -30,8 +31,9 @@ bool GetAccountCredentialStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string credentialType(reinterpret_cast<const char*>(data), size);
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string credentialType = fuzzData.GenerateRandomString();
std::string name = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -42,13 +44,11 @@ bool GetAccountCredentialStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteString(credentialType)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_ACCOUNT_CREDENTIAL);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("GetAccountExtraInfoStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "getaccountextrainfostub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -35,17 +36,16 @@ bool GetAccountExtraInfoStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string name = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(name)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_ACCOUNT_EXTRA_INFO);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -33,13 +33,11 @@ bool GetAllAccessibleAccountsStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_ALL_ACCESSIBLE_ACCOUNTS);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("GetAllAccountsStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -14,11 +14,13 @@
*/
#include "getallaccountsstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -33,7 +35,8 @@ bool GetAllAccountsStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
std::string owner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string owner = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(owner)) {
return false;
}
@ -42,7 +45,7 @@ bool GetAllAccountsStubFuzzTest(const uint8_t* data, size_t size)
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_ALL_ACCOUNTS);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("GetAllOAuthTokensStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -14,11 +14,13 @@
*/
#include "getalloauthtokensstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -29,8 +31,9 @@ bool GetAllOAuthTokensStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string owner(reinterpret_cast<const char*>(data), size);
std::string name(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string owner = fuzzData.GenerateRandomString();
std::string name = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -46,7 +49,7 @@ bool GetAllOAuthTokensStubFuzzTest(const uint8_t* data, size_t size)
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_ALL_OAUTH_TOKENS);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("GetAssociatedDataStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "getassociateddatastub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -31,8 +32,9 @@ bool GetAssociatedDataStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string name(reinterpret_cast<const char*>(data), size);
std::string key(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string name = fuzzData.GenerateRandomString();
std::string key = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -43,13 +45,12 @@ bool GetAssociatedDataStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteString(key)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_ASSOCIATED_DATA);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("GetAuthenticatorCallbackStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -14,11 +14,13 @@
*/
#include "getauthenticatorcallbackstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -33,17 +35,16 @@ bool GetAuthenticatorCallbackStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
std::string sessionId(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string sessionId = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(sessionId)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_AUTHENTICATOR_CALLBACK);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("GetAuthenticatorInfoStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -14,11 +14,13 @@
*/
#include "getauthenticatorinfostub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -33,7 +35,8 @@ bool GetAuthenticatorInfoStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
std::string owner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string owner = fuzzData.GenerateRandomString();
if (!dataTemp.WriteString(owner)) {
return false;
}
@ -42,7 +45,6 @@ bool GetAuthenticatorInfoStubFuzzTest(const uint8_t* data, size_t size)
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_AUTHENTICATOR_INFO);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("GetAuthListStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -14,11 +14,13 @@
*/
#include "getauthliststub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -29,8 +31,9 @@ bool GetAuthListStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string name(reinterpret_cast<const char*>(data), size);
std::string authType(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string name = fuzzData.GenerateRandomString();
std::string authType = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -46,7 +49,6 @@ bool GetAuthListStubFuzzTest(const uint8_t* data, size_t size)
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_AUTH_LIST);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("GetOAuthTokenStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -14,12 +14,13 @@
*/
#include "getoauthtokenstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -30,9 +31,10 @@ bool GetOAuthTokenStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string name(reinterpret_cast<const char*>(data), size);
std::string owner(reinterpret_cast<const char*>(data), size);
std::string authType(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string name = fuzzData.GenerateRandomString();
std::string owner = fuzzData.GenerateRandomString();
std::string authType = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -46,13 +48,11 @@ bool GetOAuthTokenStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteString(authType)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::GET_OAUTH_TOKEN);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("SelectAccountsByOptionsStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -14,13 +14,14 @@
*/
#include "selectaccountsbyoptionsstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_authenticator_callback_stub.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -34,45 +35,39 @@ public:
namespace OHOS {
const std::u16string APPACCOUNT_TOKEN = u"ohos.accountfwk.IAppAccount";
const int CONSTANTS_NUMBER_TWO = 2;
bool SelectAccountsByOptionsStubFuzzTest(const uint8_t* data, size_t size)
{
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string testValue(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testValue = fuzzData.GenerateRandomString();
SelectAccountsOptions options;
options.hasAccounts = (size % CONSTANTS_NUMBER_TWO) == 0 ? true : false;
options.hasOwners = (size % CONSTANTS_NUMBER_TWO) == 0 ? true : false;
options.hasLabels = (size % CONSTANTS_NUMBER_TWO) == 0 ? true : false;
options.hasAccounts = fuzzData.GenerateRandomBool();
options.hasOwners = fuzzData.GenerateRandomBool();
options.hasLabels = fuzzData.GenerateRandomBool();
options.allowedOwners.emplace_back(testValue);
options.requiredLabels.emplace_back(testValue);
sptr<MockAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
if (callback == nullptr) {
ACCOUNT_LOGI("AppAccountStub SelectAccountsByOptions callback is null");
return false;
}
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
}
if (!dataTemp.WriteParcelable(&options)) {
return false;
}
if (!dataTemp.WriteRemoteObject(callback->AsObject())) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::SELECT_ACCOUNTS_BY_OPTIONS);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("SetAccountCredentialStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "setaccountcredentialstub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -31,9 +32,10 @@ bool SetAccountCredentialStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string name(reinterpret_cast<const char*>(data), size);
std::string credentialType(reinterpret_cast<const char*>(data), size);
std::string credential(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string name = fuzzData.GenerateRandomString();
std::string credentialType = fuzzData.GenerateRandomString();
std::string credential = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -47,13 +49,11 @@ bool SetAccountCredentialStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteString(credential)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::SET_ACCOUNT_CREDENTIAL);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("SetAccountExtraInfoStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-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
@ -15,11 +15,12 @@
#include "setaccountextrainfostub_fuzzer.h"
#include <string>
#include <vector>
#include "account_log_wrapper.h"
#include "app_account_manager_service.h"
#include "iapp_account.h"
#include <string>
#include <vector>
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -30,8 +31,9 @@ bool SetAccountExtraInfoStubFuzzTest(const uint8_t* data, size_t size)
if ((data == nullptr) || (size == 0)) {
return false;
}
std::string name(reinterpret_cast<const char*>(data), size);
std::string extraInfo(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string name = fuzzData.GenerateRandomString();
std::string extraInfo = fuzzData.GenerateRandomString();
MessageParcel dataTemp;
if (!dataTemp.WriteInterfaceToken(APPACCOUNT_TOKEN)) {
return false;
@ -42,13 +44,11 @@ bool SetAccountExtraInfoStubFuzzTest(const uint8_t* data, size_t size)
if (!dataTemp.WriteString(extraInfo)) {
return false;
}
MessageParcel reply;
MessageOption option;
uint32_t code = static_cast<uint32_t>(AppAccountInterfaceCode::SET_ACCOUNT_EXTRA_INFO);
auto appAccountManagerService = std::make_shared<AppAccountManagerService>();
appAccountManagerService->OnRemoteRequest(code, dataTemp, reply, option);
return true;
}
}

View File

@ -1,4 +1,4 @@
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Copyright (c) 2023-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
@ -28,6 +28,7 @@ ohos_fuzztest("SetAppAccessStubFuzzTest") {
"${services_path}/accountmgr/include",
"${services_path}/accountmgr/include/appaccount",
"${app_account_innerkits_native_path}/include",
"${os_account_path}/test/fuzztest/appaccount_stub/fuzz_data",
]
cflags = [
"-g",

Some files were not shown because too many files have changed in this diff Show More