Merge pull request !1875 from steven_Q/master
This commit is contained in:
openharmony_ci 2024-06-07 07:59:10 +00:00 committed by Gitee
commit ae36a69f92
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
128 changed files with 544 additions and 208 deletions

View File

@ -23,7 +23,7 @@ ohos_fuzztest("AddAccountFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/addaccount_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,8 +30,9 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string extraInfo = "";
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string extraInfo(fuzzData.GenerateRandomString());
result = AppAccountManager::AddAccount(testName, extraInfo);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("AddAccountImplicitlyFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/addaccountimplicitly_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#define private public
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
#include <string>
#include <vector>
@ -51,10 +52,11 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testOwner(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testKey(reinterpret_cast<const char*>(data), size);
std::string testValue(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testOwner(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testKey(fuzzData.GenerateRandomString());
std::string testValue(fuzzData.GenerateRandomString());
AAFwk::Want options;
options.SetParam(testKey, testValue);
sptr<MockAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();

View File

@ -23,7 +23,7 @@ ohos_fuzztest("AuthenticateFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/authenticate_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#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>
@ -49,11 +50,12 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testOwner(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testKey(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 testAuthType(fuzzData.GenerateRandomString());
std::string testKey(fuzzData.GenerateRandomString());
std::string testValue(fuzzData.GenerateRandomString());
AAFwk::Want options;
options.SetParam(testKey, testValue);
sptr<MockAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();

View File

@ -23,7 +23,7 @@ ohos_fuzztest("CheckAccountLabelsFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/checkaccountlabels_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -20,6 +20,7 @@
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -49,9 +50,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
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();

View File

@ -23,7 +23,7 @@ ohos_fuzztest("CheckAppAccessFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/checkappaccess_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -28,8 +29,9 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthorizedApp(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testAuthorizedApp(fuzzData.GenerateRandomString());
bool isAccessible;
result = AppAccountManager::CheckAppAccess(testName, testAuthorizedApp, isAccessible);
}

View File

@ -22,7 +22,7 @@ ohos_fuzztest("CheckAppAccountSyncEnableFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/checkappaccountsyncenable_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,7 +30,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
bool isEnable = false;
result = AppAccountManager::CheckAppAccountSyncEnable(testName, isEnable);
}

View File

@ -22,7 +22,7 @@ ohos_fuzztest("CheckAuthTokenVisibilityFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/checkauthtokenvisibility_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -16,6 +16,7 @@
#include "checkauthtokenvisibility_fuzzer.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include "app_account_manager.h"
#include <string>
#include <vector>
@ -28,9 +29,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testBundleName(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testBundleName(fuzzData.GenerateRandomString());
bool isVisible = false;
result = AppAccountManager::CheckAuthTokenVisibility(testName, testAuthType, testBundleName, isVisible);
}

View File

@ -22,7 +22,7 @@ ohos_fuzztest("CheckOAuthTokenVisibilityFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/checkoauthtokenvisibility_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -16,6 +16,7 @@
#include "checkoauthtokenvisibility_fuzzer.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include "app_account_manager.h"
#include <string>
#include <vector>
@ -28,9 +29,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testBundleName(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testBundleName(fuzzData.GenerateRandomString());
bool isVisible = false;
result = AppAccountManager::CheckOAuthTokenVisibility(testName, testAuthType, testBundleName, isVisible);
}

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 {
namespace {
static constexpr uint32_t BOOL_MODULO_NUM = 2;
}
using namespace std;
class FuzzData {
public:
explicit FuzzData(const uint8_t *data, const size_t size) : pos_(0), data_(data), size_(size) {}
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>() % BOOL_MODULO_NUM) == 0;
}
public:
size_t pos_;
private:
const uint8_t *data_;
const size_t size_;
};
} // namespace OHOS
#endif // FUZZ_DATA_H

View File

@ -23,7 +23,7 @@ ohos_fuzztest("CreateAccountFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/createaccount_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -16,6 +16,7 @@
#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>
@ -29,9 +30,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testKey(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 testKey(fuzzData.GenerateRandomString());
std::string testValue(fuzzData.GenerateRandomString());
CreateAccountOptions options;
options.customData[testKey] = testValue;
result = AppAccountManager::CreateAccount(testName, options);

View File

@ -22,7 +22,7 @@ ohos_fuzztest("CreateAccountImplicitlyFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/createaccountimplicitly_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -49,8 +50,9 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testOwner(reinterpret_cast<const char*>(data), size);
std::string testValue(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testOwner(fuzzData.GenerateRandomString());
std::string testValue(fuzzData.GenerateRandomString());
CreateAccountImplicitlyOptions options;
options.authType = testValue;
options.requiredLabels.emplace_back(testValue);

View File

@ -23,7 +23,7 @@ ohos_fuzztest("DeleteAccountFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/deleteaccount_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,7 +30,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
result = AppAccountManager::DeleteAccount(testName);
}
return result;

View File

@ -22,7 +22,7 @@ ohos_fuzztest("DeleteAccountCredentialFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/deleteaccountcredential_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -28,8 +29,9 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testCredentialType(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testCredentialType(fuzzData.GenerateRandomString());
result = AppAccountManager::DeleteAccountCredential(testName, testCredentialType);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("DeleteAuthTokenFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/deleteauthtoken_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -28,10 +29,11 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testOwner(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testToken(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testOwner(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testToken(fuzzData.GenerateRandomString());
result = AppAccountManager::DeleteAuthToken(testName, testOwner, testAuthType, testToken);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("DeleteOAuthTokenFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/deleteoauthtoken_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -28,10 +29,11 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testOwner(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testToken(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testOwner(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testToken(fuzzData.GenerateRandomString());
result = AppAccountManager::DeleteOAuthToken(testName, testOwner, testAuthType, testToken);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("DisableAppAccessFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/disableappaccess_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,8 +30,9 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthorizedApp(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testAuthorizedApp(fuzzData.GenerateRandomString());
result = AppAccountManager::DisableAppAccess(testName, testAuthorizedApp);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("EnableAppAccessFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/enableappaccess_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,8 +30,9 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthorizedApp(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testAuthorizedApp(fuzzData.GenerateRandomString());
result = AppAccountManager::EnableAppAccess(testName, testAuthorizedApp);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetAccountCredentialFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getaccountcredential_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,9 +30,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testCredentialType(reinterpret_cast<const char*>(data), size);
std::string testCredential(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testCredentialType(fuzzData.GenerateRandomString());
std::string testCredential(fuzzData.GenerateRandomString());
result = AppAccountManager::GetAccountCredential(testName, testCredentialType, testCredential);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetAccountExtraInfoFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getaccountextrainfo_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,8 +30,9 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testExtraInfo(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testExtraInfo(fuzzData.GenerateRandomString());
result = AppAccountManager::GetAccountExtraInfo(testName, testExtraInfo);
}
return result;

View File

@ -22,7 +22,7 @@ ohos_fuzztest("GetAllAccessibleAccountsFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/getallaccessibleaccounts_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#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>
@ -31,7 +32,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testOwner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testOwner(fuzzData.GenerateRandomString());
std::vector<AppAccountInfo> appAccounts;
AppAccountInfo appAccount;
appAccount.owner_ = testOwner;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetAllAccountsFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getallaccounts_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#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>
@ -31,7 +32,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testOwner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testOwner(fuzzData.GenerateRandomString());
std::vector<AppAccountInfo> appAccounts;
AppAccountInfo appAccount;
appAccount.owner_ = testOwner;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetAllOAuthTokensFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getalloauthtokens_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -16,6 +16,7 @@
#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>
@ -30,9 +31,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testOwner(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testOwner(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::vector<OAuthTokenInfo> testTokenInfos;
OAuthTokenInfo testTokenInfo;
testTokenInfo.authType = testAuthType;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetAssociatedDataFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getassociateddata_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,9 +30,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testKey(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 testKey(fuzzData.GenerateRandomString());
std::string testValue(fuzzData.GenerateRandomString());
result = AppAccountManager::GetAssociatedData(testName, testKey, testValue);
}
return result;

View File

@ -22,7 +22,7 @@ ohos_fuzztest("GetAuthenticatorCallbackFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/getauthenticatorcallback_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -28,7 +29,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testSessionId(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testSessionId(fuzzData.GenerateRandomString());
sptr<IRemoteObject> callback;
result = AppAccountManager::GetAuthenticatorCallback(testSessionId, callback);
}

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetAuthenticatorInfoFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getauthenticatorinfo_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -29,7 +30,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testOwner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testOwner(fuzzData.GenerateRandomString());
AuthenticatorInfo testInfo;
testInfo.owner = testOwner;
result = AppAccountManager::GetAuthenticatorInfo(testOwner, testInfo);

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetAuthListFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getauthlist_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <set>
#include <string>
#include <vector>
@ -29,9 +30,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthType(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 testAuthType(fuzzData.GenerateRandomString());
std::string testValue(fuzzData.GenerateRandomString());
std::set<std::string> oauthList;
oauthList.insert(testValue);
result = AppAccountManager::GetAuthList(testName, testAuthType, oauthList);

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetAuthTokenFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getauthtoken_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,10 +30,11 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testOwner(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testToken(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testOwner(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testToken(fuzzData.GenerateRandomString());
result = AppAccountManager::GetAuthToken(testName, testOwner, testAuthType, testToken);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetOAuthListFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getoauthlist_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <set>
#include <string>
#include <vector>
@ -29,9 +30,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthType(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 testAuthType(fuzzData.GenerateRandomString());
std::string testValue(fuzzData.GenerateRandomString());
std::set<std::string> oauthList;
oauthList.insert(testValue);
result = AppAccountManager::GetOAuthList(testName, testAuthType, oauthList);

View File

@ -23,7 +23,7 @@ ohos_fuzztest("GetOAuthTokenFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/getoauthtoken_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,10 +30,11 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testOwner(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testToken(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testOwner(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testToken(fuzzData.GenerateRandomString());
result = AppAccountManager::GetOAuthToken(testName, testOwner, testAuthType, testToken);
}
return result;

View File

@ -22,7 +22,7 @@ ohos_fuzztest("SelectAccountsByOptionsFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/selectaccountsbyoptions_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -51,7 +52,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
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;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("SetAccountCredentialFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/setaccountcredential_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -28,9 +29,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testCredentialType(reinterpret_cast<const char*>(data), size);
std::string testCredential(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testCredentialType(fuzzData.GenerateRandomString());
std::string testCredential(fuzzData.GenerateRandomString());
result = AppAccountManager::SetAccountCredential(testName, testCredentialType, testCredential);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("SetAccountExtraInfoFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/setaccountextrainfo_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,8 +30,9 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testExtraInfo(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testExtraInfo(fuzzData.GenerateRandomString());
result = AppAccountManager::SetAccountExtraInfo(testName, testExtraInfo);
}
return result;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("SetAppAccessFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/setappaccess_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -31,8 +32,9 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthorizedApp(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testAuthorizedApp(fuzzData.GenerateRandomString());
bool isAccessible = ((size % CONSTANTS_NUMBER_TWO) == 0);
result = AppAccountManager::SetAppAccess(testName, testAuthorizedApp, isAccessible);
}

View File

@ -22,7 +22,7 @@ ohos_fuzztest("SetAppAccountSyncEnableFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/setappaccountsyncenable_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#undef private
using namespace std;
@ -29,7 +30,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
bool isEnable = false;
result = AppAccountManager::SetAppAccountSyncEnable(testName, isEnable);
}

View File

@ -23,7 +23,7 @@ ohos_fuzztest("SetAssociatedDataFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/setassociateddata_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -28,9 +29,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testKey(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 testKey(fuzzData.GenerateRandomString());
std::string testValue(fuzzData.GenerateRandomString());
result = AppAccountManager::SetAssociatedData(testName, testKey, testValue);
}
return result;

View File

@ -22,7 +22,7 @@ ohos_fuzztest("SetAuthenticatorPropertiesFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/setauthenticatorproperties_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -49,7 +50,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testOwner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testOwner(fuzzData.GenerateRandomString());
sptr<MockAuthenticatorCallback> callback = new (std::nothrow) MockAuthenticatorCallback();
SetPropertiesOptions options;
result = AppAccountManager::SetAuthenticatorProperties(testOwner, options, callback);

View File

@ -22,7 +22,7 @@ ohos_fuzztest("SetAuthTokenVisibilityFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/setauthtokenvisibility_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -30,9 +31,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testBundleName(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testBundleName(fuzzData.GenerateRandomString());
bool isVisible = ((size % CONSTANTS_NUMBER_TWO) == 0);
result = AppAccountManager::SetAuthTokenVisibility(testName, testAuthType, testBundleName, isVisible);
}

View File

@ -23,7 +23,7 @@ ohos_fuzztest("SetOAuthTokenFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/setoauthtoken_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -28,9 +29,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testToken(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testToken(fuzzData.GenerateRandomString());
result = AppAccountManager::SetOAuthToken(testName, testAuthType, testToken);
}
return result;

View File

@ -22,7 +22,7 @@ ohos_fuzztest("SetOAuthTokenVisibilityFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/appaccount/setoauthtokenvisibility_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -17,6 +17,7 @@
#include "app_account_manager.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -28,9 +29,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testName(reinterpret_cast<const char*>(data), size);
std::string testAuthType(reinterpret_cast<const char*>(data), size);
std::string testBundleName(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testName(fuzzData.GenerateRandomString());
std::string testAuthType(fuzzData.GenerateRandomString());
std::string testBundleName(fuzzData.GenerateRandomString());
bool isVisible = false;
result = AppAccountManager::SetOAuthTokenVisibility(testName, testAuthType, testBundleName, isVisible);
}

View File

@ -23,7 +23,7 @@ ohos_fuzztest("SubscribeAppAccountFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/subscribeappaccount_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include "app_account_manager.h"
#include "app_account_subscribe_info.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -44,7 +45,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testOwner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testOwner(fuzzData.GenerateRandomString());
std::vector<std::string> owners;
owners.emplace_back(testOwner);
AppAccountSubscribeInfo subscribeInfo(owners);

View File

@ -23,7 +23,7 @@ ohos_fuzztest("UnsubscribeAppAccountFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/unsubscribeappaccount_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include "app_account_manager.h"
#include "app_account_subscribe_info.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -44,7 +45,8 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
std::string testOwner(reinterpret_cast<const char*>(data), size);
FuzzData fuzzData(data, size);
std::string testOwner(fuzzData.GenerateRandomString());
std::vector<std::string> owners;
owners.emplace_back(testOwner);
AppAccountSubscribeInfo subscribeInfo(owners);

View File

@ -23,7 +23,7 @@ ohos_fuzztest("VerifyCredentialFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/appaccount/verifycredential_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/appaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include "app_account_manager.h"
#include "app_account_common.h"
#include "account_log_wrapper.h"
#include "fuzz_data.h"
#include <string>
#include <vector>
@ -49,9 +50,10 @@ namespace OHOS {
{
bool result = false;
if (size > 0) {
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());
VerifyCredentialOptions options;
options.credentialType = testValue;
options.credential = testValue;

View File

@ -23,7 +23,7 @@ ohos_fuzztest("AddCredentialFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/iamaccount/addcredential_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/iamaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -19,6 +19,7 @@
#include <vector>
#include "account_iam_client.h"
#include "fuzz_data.h"
using namespace std;
@ -40,10 +41,11 @@ public:
namespace OHOS {
bool AddCredentialFuzzTest(const uint8_t* data, size_t size)
{
int32_t userId = static_cast<int32_t>(size);
AuthType authType = static_cast<AuthType>(size);
std::optional<PinSubType> pinType = {static_cast<PinSubType>(size)};
std::vector<uint8_t> token = {static_cast<uint8_t>(size)};
FuzzData fuzzData(data, size);
int32_t userId = fuzzData.GetData<int32_t>();
AuthType authType = fuzzData.GenerateRandomEnmu(UserIam::UserAuth::RECOVERY_KEY);
std::optional<PinSubType> pinType = {fuzzData.GenerateRandomEnmu(UserIam::UserAuth::PIN_MAX)};
std::vector<uint8_t> token = {fuzzData.GetData<uint8_t>()};
CredentialParameters credInfo = {
.authType = authType,
.pinType = pinType,

View File

@ -22,7 +22,7 @@ ohos_fuzztest("AuthFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/iamaccount/auth_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/iamaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,7 +18,7 @@
#include <string>
#include <vector>
#include "account_iam_client.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -39,9 +39,10 @@ public:
namespace OHOS {
bool AuthFuzzTest(const uint8_t* data, size_t size)
{
std::vector<uint8_t> challenge = {static_cast<uint8_t>(size)};
AuthType authType = static_cast<AuthType>(size);
AuthTrustLevel authTrustLevel = static_cast<AuthTrustLevel>(size);
FuzzData fuzzData(data, size);
std::vector<uint8_t> challenge = {fuzzData.GetData<uint8_t>()};
AuthType authType = fuzzData.GenerateRandomEnmu(UserIam::UserAuth::RECOVERY_KEY);
AuthTrustLevel authTrustLevel = fuzzData.GenerateRandomEnmu(UserIam::UserAuth::ATL4);
std::shared_ptr<IDMCallback> callback = make_shared<MockIDMCallback>();
AuthOptions authOptions;
uint64_t result = AccountIAMClient::GetInstance().Auth(authOptions,

View File

@ -23,7 +23,7 @@ ohos_fuzztest("AuthUserFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/iamaccount/authuser_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/iamaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include <string>
#include <vector>
#include "account_iam_client.h"
#include "fuzz_data.h"
using namespace std;
@ -39,10 +40,11 @@ public:
namespace OHOS {
bool AuthUserFuzzTest(const uint8_t* data, size_t size)
{
int32_t userId = static_cast<int32_t>(size);
std::vector<uint8_t> challenge = {static_cast<uint8_t>(size)};
AuthType authType = static_cast<AuthType>(size);
AuthTrustLevel authTrustLevel = static_cast<AuthTrustLevel>(size);
FuzzData fuzzData(data, size);
int32_t userId = fuzzData.GetData<int32_t>();
std::vector<uint8_t> challenge = {fuzzData.GetData<uint8_t>()};
AuthType authType = fuzzData.GenerateRandomEnmu(UserIam::UserAuth::RECOVERY_KEY);
AuthTrustLevel authTrustLevel = fuzzData.GenerateRandomEnmu(UserIam::UserAuth::ATL4);
std::shared_ptr<IDMCallback> callback = make_shared<MockIDMCallback>();
AuthOptions authOptions;
authOptions.accountId = userId;

View File

@ -22,7 +22,7 @@ ohos_fuzztest("CancelFuzzTest") {
module_out_path = fuzz_output_path
fuzz_config_file = "${os_account_path}/test/fuzztest/iamaccount/cancel_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/iamaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include <string>
#include <vector>
#include "account_iam_client.h"
#include "fuzz_data.h"
using namespace std;
@ -26,7 +27,8 @@ using namespace OHOS::AccountSA;
namespace OHOS {
bool CancelFuzzTest(const uint8_t* data, size_t size)
{
int32_t userId = static_cast<int32_t>(size);
FuzzData fuzzData(data, size);
int32_t userId = fuzzData.GetData<int32_t>();
int32_t result = AccountIAMClient::GetInstance().Cancel(userId);
return result == ERR_OK;
}

View File

@ -23,7 +23,7 @@ ohos_fuzztest("CancelAuthFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/iamaccount/cancelauth_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/iamaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include <string>
#include <vector>
#include "account_iam_client.h"
#include "fuzz_data.h"
using namespace std;
@ -26,7 +27,8 @@ using namespace OHOS::AccountSA;
namespace OHOS {
bool CancelAuthFuzzTest(const uint8_t* data, size_t size)
{
uint64_t contextId = static_cast<uint64_t>(size);
FuzzData fuzzData(data, size);
uint64_t contextId = fuzzData.GetData<uint64_t>();
int32_t result = AccountIAMClient::GetInstance().CancelAuth(contextId);
return result == ERR_OK;
}

View File

@ -23,7 +23,10 @@ ohos_fuzztest("ClearCredentialFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/iamaccount/clearcredential_fuzzer"
include_dirs = [ "${account_iam_interfaces_native_path}/include" ]
include_dirs = [
"${account_iam_interfaces_native_path}/include",
"${os_account_path}/test/fuzztest/iamaccount/common",
]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include <string>
#include <vector>
#include "account_iam_client.h"
#include "fuzz_data.h"
using namespace std;
@ -26,7 +27,8 @@ using namespace OHOS::AccountSA;
namespace OHOS {
bool ClearCredentialFuzzTest(const uint8_t* data, size_t size)
{
int32_t userId = static_cast<int32_t>(size);
FuzzData fuzzData(data, size);
int32_t userId = fuzzData.GetData<int32_t>();
AccountIAMClient::GetInstance().ClearCredential(userId);
return false;
}

View File

@ -23,7 +23,7 @@ ohos_fuzztest("CloseSessionFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/iamaccount/closesession_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/iamaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include <string>
#include <vector>
#include "account_iam_client.h"
#include "fuzz_data.h"
using namespace std;
@ -26,7 +27,8 @@ using namespace OHOS::AccountSA;
namespace OHOS {
bool CloseSessionFuzzTest(const uint8_t* data, size_t size)
{
int32_t userId = static_cast<int32_t>(size);
FuzzData fuzzData(data, size);
int32_t userId = fuzzData.GetData<int32_t>();
int32_t result = AccountIAMClient::GetInstance().CloseSession(userId);
return result == ERR_OK;
}

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 {
namespace {
static constexpr uint32_t BOOL_MODULO_NUM = 2;
}
using namespace std;
class FuzzData {
public:
explicit FuzzData(const uint8_t *data, const size_t size) : pos_(0), data_(data), size_(size) {}
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>() % BOOL_MODULO_NUM) == 0;
}
public:
size_t pos_;
private:
const uint8_t *data_;
const size_t size_;
};
} // namespace OHOS
#endif // FUZZ_DATA_H

View File

@ -23,7 +23,7 @@ ohos_fuzztest("DelCredFuzzTest") {
fuzz_config_file =
"${os_account_path}/test/fuzztest/iamaccount/delcred_fuzzer"
include_dirs = []
include_dirs = [ "${os_account_path}/test/fuzztest/iamaccount/common" ]
cflags = [
"-g",
"-O0",

View File

@ -18,6 +18,7 @@
#include <string>
#include <vector>
#include "account_iam_client.h"
#include "fuzz_data.h"
using namespace std;
using namespace OHOS::AccountSA;
@ -38,9 +39,10 @@ public:
namespace OHOS {
bool DelCredFuzzTest(const uint8_t* data, size_t size)
{
int32_t userId = static_cast<int32_t>(size);
uint64_t credentialId = static_cast<uint64_t>(size);
std::vector<uint8_t> authToken = {static_cast<uint8_t>(size)};
FuzzData fuzzData(data, size);
int32_t userId = fuzzData.GetData<int32_t>();
uint64_t credentialId = fuzzData.GetData<uint64_t>();
std::vector<uint8_t> authToken = {fuzzData.GetData<uint8_t>()};
std::shared_ptr<IDMCallback> callback = make_shared<MockIDMCallback>();
AccountIAMClient::GetInstance().DelCred(userId, credentialId, authToken, callback);
return false;

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