mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-27 17:01:21 +00:00
删除对应的无用fuzz用例
Signed-off-by: cy7717 <chenyu301@huawei.com>
This commit is contained in:
parent
38c60de8f4
commit
6eecf0b0ef
@ -25,10 +25,7 @@ group("fuzztest") {
|
||||
"inputmethod_fuzzer:fuzztest",
|
||||
"inputmethodability_fuzzer:fuzztest",
|
||||
"inputmethodcontroller_fuzzer:fuzztest",
|
||||
"inputmethodsetting_fuzzer:fuzztest",
|
||||
"perusersession_fuzzer:fuzztest",
|
||||
"perusersetting_fuzzer:fuzztest",
|
||||
"platformcallbackstub_fuzzer:fuzztest",
|
||||
"systemabilitystub_fuzzer:fuzztest",
|
||||
]
|
||||
}
|
||||
|
@ -68,18 +68,6 @@ void TextOnInputReady()
|
||||
mClient->onInputReady(iface);
|
||||
}
|
||||
|
||||
void TestOnInputReleased(int32_t fuzzedInt32)
|
||||
{
|
||||
sptr<InputClientStub> mClient = new InputClientStub();
|
||||
mClient->onInputReleased(fuzzedInt32);
|
||||
}
|
||||
|
||||
void TestSetDisplayMode(int32_t fuzzedInt32)
|
||||
{
|
||||
sptr<InputClientStub> mClient = new InputClientStub();
|
||||
mClient->setDisplayMode(fuzzedInt32);
|
||||
}
|
||||
|
||||
void TestOnSwitchInput()
|
||||
{
|
||||
sptr<InputClientStub> mClient = new InputClientStub();
|
||||
@ -97,12 +85,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
return 0;
|
||||
}
|
||||
/* Run your code on data */
|
||||
auto fuzzedInt32 = static_cast<int32_t>(size);
|
||||
|
||||
OHOS::FuzzInputClientStub(data, size);
|
||||
OHOS::TextOnInputReady();
|
||||
OHOS::TestOnInputReleased(fuzzedInt32);
|
||||
OHOS::TestSetDisplayMode(fuzzedInt32);
|
||||
OHOS::TestOnSwitchInput();
|
||||
return 0;
|
||||
}
|
@ -19,14 +19,12 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "global.h"
|
||||
#include "i_platform_callback.h"
|
||||
#include "input_client_stub.h"
|
||||
#include "input_method_controller.h"
|
||||
#include "keyboard_event.h"
|
||||
#include "message_handler.h"
|
||||
#include "message_parcel.h"
|
||||
#include "para_handle.h"
|
||||
#include "platform.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace OHOS::MiscServices;
|
||||
@ -51,41 +49,11 @@ bool FuzzParaHandle(const uint8_t *rawData, size_t size)
|
||||
ParaHandle::SetDefaultIme(userId, imeName);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FuzzPlatform(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
int32_t data = static_cast<int32_t>(*rawData);
|
||||
std::vector<InputMethodInfo *> *properties = {};
|
||||
InputMethodInfo *inputMethodProperty = new InputMethodInfo();
|
||||
InputMethodSetting *inputMethodSetting = new InputMethodSetting();
|
||||
std::u16string packageName = Str8ToStr16(std::string(rawData, rawData + size));
|
||||
std::u16string intention = Str8ToStr16(std::string(rawData, rawData + size));
|
||||
|
||||
MiscServices::Platform::Instance()->BindInputMethodService(data, packageName, intention);
|
||||
MiscServices::Platform::Instance()->UnbindInputMethodService(data, packageName);
|
||||
MiscServices::Platform::Instance()->CreateWindowToken(data, data, packageName);
|
||||
MiscServices::Platform::Instance()->DestroyWindowToken(data, packageName);
|
||||
MiscServices::Platform::Instance()->ListInputMethod(data, properties);
|
||||
MiscServices::Platform::Instance()->GetInputMethodProperty(data, packageName, inputMethodProperty);
|
||||
MiscServices::Platform::Instance()->GetInputMethodSetting(data, inputMethodSetting);
|
||||
MiscServices::Platform::Instance()->SetInputMethodSetting(data, *inputMethodSetting);
|
||||
MiscServices::Platform::Instance()->CheckPhysicalKeyboard();
|
||||
MiscServices::Platform::Instance()->IsValidWindow(data, data, data);
|
||||
MiscServices::Platform::Instance()->IsWindowFocused(data, data, data);
|
||||
|
||||
delete inputMethodProperty;
|
||||
inputMethodProperty = nullptr;
|
||||
delete inputMethodSetting;
|
||||
inputMethodSetting = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::FuzzParaHandle(data, size);
|
||||
OHOS::FuzzPlatform(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//base/inputmethod/imf/inputmethod.gni")
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("InputMethodSettingFuzzTest") {
|
||||
module_out_path = "inputmethod/inputmethod"
|
||||
|
||||
fuzz_config_file =
|
||||
"//base/inputmethod/imf/test/fuzztest/inputmethodsetting_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//base/inputmethod/imf/services/include",
|
||||
"//foundation/ability/ability_runtime/interfaces/inner_api/app_manager/include/appmgr",
|
||||
"//foundation/ability/ability_runtime/services/abilitymgr/include",
|
||||
"//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager/include/",
|
||||
"//third_party/jsoncpp/include/",
|
||||
"//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_core/include/bundlemgr",
|
||||
"//foundation/multimedia/image_framework/interfaces/innerkits/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "inputmethodsetting_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_services_path}/abilitymgr:abilityms",
|
||||
"//base/inputmethod/imf/frameworks/inputmethod_controller:inputmethod_client",
|
||||
"//base/inputmethod/imf/services:inputmethod_service",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [
|
||||
# deps file
|
||||
":InputMethodSettingFuzzTest",
|
||||
]
|
||||
}
|
||||
###############################################################################
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "inputmethodsetting_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "global.h"
|
||||
#include "input_method_controller.h"
|
||||
#include "input_method_setting.h"
|
||||
#include "input_method_system_ability.h"
|
||||
#include "message_parcel.h"
|
||||
#include "peruser_session.h"
|
||||
#include "peruser_setting.h"
|
||||
|
||||
using namespace OHOS::MiscServices;
|
||||
namespace OHOS {
|
||||
class TextListener : public OnTextChangedListener {
|
||||
public:
|
||||
TextListener() {}
|
||||
~TextListener() {}
|
||||
void InsertText(const std::u16string &text) {}
|
||||
void DeleteBackward(int32_t length) {}
|
||||
void SetKeyboardStatus(bool status) {}
|
||||
void DeleteForward(int32_t length) {}
|
||||
void SendKeyEventFromInputMethod(const KeyEvent &event) {}
|
||||
void SendKeyboardInfo(const KeyboardInfo &status) {}
|
||||
void MoveCursor(const Direction direction) {}
|
||||
};
|
||||
bool FuzzInputMethodSetting(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
sptr<InputMethodController> imc = InputMethodController::GetInstance();
|
||||
sptr<OnTextChangedListener> textListener = new TextListener();
|
||||
imc->Attach(textListener);
|
||||
|
||||
constexpr int32_t MAIN_USER_ID = 100;
|
||||
PerUserSetting *setting = new (std::nothrow) PerUserSetting(MAIN_USER_ID);
|
||||
if (setting == nullptr) {
|
||||
return true;
|
||||
}
|
||||
InputMethodSetting *methodSetting = setting->GetInputMethodSetting();
|
||||
if (methodSetting == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
InputMethodSetting setting_ = *methodSetting;
|
||||
std::u16string imeId = Str8ToStr16(std::string(rawData, rawData + size));
|
||||
std::vector<int32_t> types;
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
types.push_back(static_cast<int32_t>(*rawData));
|
||||
}
|
||||
setting_.GetCurrentInputMethod();
|
||||
setting_.SetCurrentInputMethod(imeId);
|
||||
setting_.GetEnabledInputMethodList();
|
||||
setting_.AddEnabledInputMethod(imeId, types);
|
||||
setting_.RemoveEnabledInputMethod(imeId);
|
||||
setting_.GetEnabledKeyboardTypes(imeId);
|
||||
setting_.GetCurrentKeyboardType();
|
||||
setting_.SetCurrentKeyboardType(static_cast<int32_t>(*rawData));
|
||||
setting_.GetCurrentSysKeyboardType();
|
||||
setting_.SetCurrentSysKeyboardType(static_cast<int32_t>(*rawData));
|
||||
setting_.FindKey(imeId);
|
||||
setting_.ClearData();
|
||||
|
||||
delete setting;
|
||||
setting = nullptr;
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
OHOS::FuzzInputMethodSetting(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_INPUTMETHODSETTING_FUZZER_INPUTMETHODSETTING_FUZZER_H
|
||||
#define TEST_FUZZTEST_INPUTMETHODSETTING_FUZZER_INPUTMETHODSETTING_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "inputmethodsetting_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_INPUTMETHODSETTING_FUZZER_INPUTMETHODSETTING_FUZZER_H
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -33,7 +33,6 @@
|
||||
#include "iremote_broker.h"
|
||||
#include "message_parcel.h"
|
||||
#include "peruser_session.h"
|
||||
#include "peruser_setting.h"
|
||||
|
||||
using namespace OHOS::MiscServices;
|
||||
namespace OHOS {
|
||||
@ -65,11 +64,9 @@ bool FuzzPerUserSession(const uint8_t *rawData, size_t size)
|
||||
sptr<IInputMethodAgent> agent = new InputMethodAgentProxy(object);
|
||||
InputMethodInfo *ime = new InputMethodInfo();
|
||||
|
||||
userSessions->OnPackageRemoved(packageName);
|
||||
userSessions->OnShowKeyboardSelf();
|
||||
userSessions->OnInputMethodSwitched(property, subProperty);
|
||||
userSessions->GetCurrentSubProperty();
|
||||
userSessions->StartInputService();
|
||||
userSessions->SetCurrentSubProperty(subProperty);
|
||||
userSessions->StopInputService(str);
|
||||
userSessions->JoinWorkThread();
|
||||
@ -77,9 +74,6 @@ bool FuzzPerUserSession(const uint8_t *rawData, size_t size)
|
||||
userSessions->OnStartInput(client, isShowKeyboard);
|
||||
userSessions->OnStopInput(client);
|
||||
userSessions->OnReleaseInput(client);
|
||||
userSessions->SetCurrentIme(ime);
|
||||
userSessions->SetSecurityIme(ime);
|
||||
userSessions->ResetIme(ime, ime);
|
||||
userSessions->OnSetCoreAndAgent(core, agent);
|
||||
|
||||
delete ime;
|
||||
|
@ -1,73 +0,0 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//base/inputmethod/imf/inputmethod.gni")
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("PerUserSettingFuzzTest") {
|
||||
module_out_path = "inputmethod/inputmethod"
|
||||
|
||||
fuzz_config_file =
|
||||
"//base/inputmethod/imf/test/fuzztest/perusersetting_fuzzer"
|
||||
|
||||
include_dirs = [
|
||||
"//base/inputmethod/imf/services/include",
|
||||
"//base/inputmethod/imf/frameworks/inputmethod_controller/include",
|
||||
"//base/inputmethod/imf/services/include",
|
||||
"//foundation/ability/ability_runtime/services/abilitymgr/include",
|
||||
"//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager/include",
|
||||
"//third_party/jsoncpp/include",
|
||||
"//foundation/ability/ability_runtime/interfaces/inner_api/app_manager/include/appmgr",
|
||||
"//foundation/multimedia/image_framework/interfaces/innerkits/include",
|
||||
]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "perusersetting_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"//base/inputmethod/imf/frameworks/inputmethod_ability:inputmethod_ability",
|
||||
"//base/inputmethod/imf/frameworks/inputmethod_controller:inputmethod_client",
|
||||
"//base/inputmethod/imf/services:inputmethod_service",
|
||||
"//foundation/ability/ability_runtime/services/abilitymgr:abilityms",
|
||||
"//foundation/arkui/napi:ace_napi",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [
|
||||
# deps file
|
||||
":PerUserSettingFuzzTest",
|
||||
]
|
||||
}
|
||||
###############################################################################
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "perusersetting_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string_ex.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "input_method_agent_stub.h"
|
||||
#include "input_method_info.h"
|
||||
#include "message_parcel.h"
|
||||
#include "peruser_setting.h"
|
||||
|
||||
using namespace OHOS::MiscServices;
|
||||
namespace OHOS {
|
||||
constexpr size_t THRESHOLD = 10;
|
||||
|
||||
uint32_t ConvertToUint32(const uint8_t *ptr)
|
||||
{
|
||||
if (ptr == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t bigVar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
|
||||
return bigVar;
|
||||
}
|
||||
bool FuzzPerUserSetting(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
std::string str(reinterpret_cast<const char *>(rawData), size);
|
||||
std::u16string imeId = Str8ToStr16(str);
|
||||
std::u16string packageName = Str8ToStr16(str);
|
||||
std::u16string key = Str8ToStr16(str);
|
||||
std::u16string value = Str8ToStr16(str);
|
||||
bool isSecurityIme = true;
|
||||
constexpr int32_t MAIN_USER_ID = 100;
|
||||
|
||||
std::shared_ptr<PerUserSetting> userSetting = std::make_shared<PerUserSetting>(MAIN_USER_ID);
|
||||
|
||||
userSetting->Initialize();
|
||||
userSetting->GetUserState();
|
||||
userSetting->GetCurrentInputMethod();
|
||||
userSetting->GetSecurityInputMethod();
|
||||
userSetting->GetNextInputMethod();
|
||||
userSetting->GetInputMethodSetting();
|
||||
userSetting->GetInputMethodProperty(imeId);
|
||||
userSetting->OnPackageAdded(packageName, isSecurityIme);
|
||||
userSetting->OnPackageRemoved(packageName, isSecurityIme);
|
||||
userSetting->OnSettingChanged(key, value);
|
||||
userSetting->OnAdvanceToNext();
|
||||
userSetting->OnUserLocked();
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (size < OHOS::THRESHOLD) {
|
||||
return 0;
|
||||
}
|
||||
/* Run your code on data */
|
||||
OHOS::FuzzPerUserSetting(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_PERUSERSETTING_FUZZER_AGENTSTUB_FUZZER_H
|
||||
#define TEST_FUZZTEST_PERUSERSETTING_FUZZER_AGENTSTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "perusersetting_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_PERUSERSETTING_FUZZER_AGENTSTUB_FUZZER_H
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -1,60 +0,0 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//base/inputmethod/imf/inputmethod.gni")
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("PlatformCallbackStubFuzzTest") {
|
||||
module_out_path = "inputmethod/inputmethod"
|
||||
|
||||
fuzz_config_file =
|
||||
"//base/inputmethod/imf/test/fuzztest/platformcallbackstub_fuzzer"
|
||||
|
||||
include_dirs = [ "//base/inputmethod/imf/services/include" ]
|
||||
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "platformcallbackstub_fuzzer.cpp" ]
|
||||
|
||||
deps = [
|
||||
"//base/inputmethod/imf/services:inputmethod_service",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_core:ipc_core",
|
||||
"//foundation/communication/ipc/interfaces/innerkits/ipc_single:ipc_single",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [
|
||||
# deps file
|
||||
":PlatformCallbackStubFuzzTest",
|
||||
]
|
||||
}
|
||||
###############################################################################
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "platformcallbackstub_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "global.h"
|
||||
#include "message_parcel.h"
|
||||
#include "platform_callback_stub.h"
|
||||
|
||||
using namespace OHOS::MiscServices;
|
||||
namespace OHOS {
|
||||
constexpr size_t THRESHOLD = 10;
|
||||
constexpr int32_t OFFSET = 4;
|
||||
const std::u16string PLATFORM_INTERFACE_TOKEN = u"ohos.miscservices.inputmethod.IPlatformCallback";
|
||||
|
||||
uint32_t ConvertToUint32(const uint8_t *ptr)
|
||||
{
|
||||
if (ptr == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t bigVar = (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | (ptr[3]);
|
||||
return bigVar;
|
||||
}
|
||||
bool FuzzPlatformCallbackStub(const uint8_t *rawData, size_t size)
|
||||
{
|
||||
uint32_t code = ConvertToUint32(rawData);
|
||||
rawData = rawData + OFFSET;
|
||||
size = size - OFFSET;
|
||||
|
||||
MessageParcel data;
|
||||
data.WriteInterfaceToken(PLATFORM_INTERFACE_TOKEN);
|
||||
data.WriteBuffer(rawData, size);
|
||||
data.RewindRead(0);
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
sptr<PlatformCallbackStub> cb = new PlatformCallbackStub();
|
||||
cb->OnRemoteRequest(code, data, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace OHOS
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
if (size < OHOS::THRESHOLD) {
|
||||
return 0;
|
||||
}
|
||||
/* Run your code on data */
|
||||
OHOS::FuzzPlatformCallbackStub(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEST_FUZZTEST_PLATFORMCALLBACKSTUB_FUZZER_PLATFORMCALLBACKSTUB_FUZZER_H
|
||||
#define TEST_FUZZTEST_PLATFORMCALLBACKSTUB_FUZZER_PLATFORMCALLBACKSTUB_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "platformcallbackstub_fuzzer"
|
||||
|
||||
#endif // TEST_FUZZTEST_PLATFORMCALLBACKSTUB_FUZZER_PLATFORMCALLBACKSTUB_FUZZER_H
|
@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
Loading…
Reference in New Issue
Block a user