!15570 fuzz用例补充

Merge pull request !15570 from liuzongze/master
This commit is contained in:
openharmony_ci
2025-07-15 13:45:31 +00:00
committed by Gitee
36 changed files with 1589 additions and 0 deletions
+7
View File
@@ -138,6 +138,7 @@ group("fuzztest") {
"abilitystubaddfreeinstallobserver_fuzzer:fuzztest",
"abilitystubaddwindowinfodone_fuzzer:fuzztest",
"abilitystubattachabilitythread_fuzzer:fuzztest",
"abilitystubattachappdebug_fuzzer:fuzztest",
"abilitystubcallrequestdone_fuzzer:fuzztest",
"abilitystubcalluiabilitybyscb_fuzzer:fuzztest",
"abilitystubcancelwantsender_fuzzer:fuzztest",
@@ -160,6 +161,7 @@ group("fuzztest") {
"abilitystubcontinuemissionofbundlename_fuzzer:fuzztest",
"abilitystubdelegatordoabilitybackground_fuzzer:fuzztest",
"abilitystubdelegatordoabilityforeground_fuzzer:fuzztest",
"abilitystubdetachappdebug_fuzzer:fuzztest",
"abilitystubdisconnectability_fuzzer:fuzztest",
"abilitystubdisconnectabilitydone_fuzzer:fuzztest",
"abilitystubdoabilitybackground_fuzzer:fuzztest",
@@ -167,6 +169,8 @@ group("fuzztest") {
"abilitystubdumpabilityinfodone_fuzzer:fuzztest",
"abilitystubdumpstate_fuzzer:fuzztest",
"abilitystubdumpsysstate_fuzzer:fuzztest",
"abilitystubexecuteinsightintentdone_fuzzer:fuzztest",
"abilitystubexecuteintent_fuzzer:fuzztest",
"abilitystubfinishusertest_fuzzer:fuzztest",
"abilitystubforceexitapp_fuzzer:fuzztest",
"abilitystubfreeinstallabilityfromremote_fuzzer:fuzztest",
@@ -200,6 +204,7 @@ group("fuzztest") {
"abilitystubisrunninginstabilitytest_fuzzer:fuzztest",
"abilitystubkillprocess_fuzzer:fuzztest",
"abilitystubliststackinfodone_fuzzer:fuzztest",
"abilitystublogoutuser_fuzzer:fuzztest",
"abilitystublockmissionforcleanup_fuzzer:fuzztest",
"abilitystubluckmissiondone_fuzzer:fuzztest",
"abilitystubmaximizemultiwindowdone_fuzzer:fuzztest",
@@ -224,6 +229,7 @@ group("fuzztest") {
"abilitystubprepareterminateability_fuzzer:fuzztest",
"abilitystubquerymissionvaild_fuzzer:fuzztest",
"abilitystubrecordappexitreason_fuzzer:fuzztest",
"abilitystubregisterappdebuglistener_fuzzer:fuzztest",
"abilitystubregistercancellistener_fuzzer:fuzztest",
"abilitystubregistercollaborator_fuzzer:fuzztest",
"abilitystubregisterconnectionobserver_fuzzer:fuzztest",
@@ -274,6 +280,7 @@ group("fuzztest") {
"abilitystubuninstallapp_fuzzer:fuzztest",
"abilitystubunlockmissionforcleanup_fuzzer:fuzztest",
"abilitystubunluckmissiondone_fuzzer:fuzztest",
"abilitystubunregisterappdebuglistener_fuzzer:fuzztest",
"abilitystubunregistercancellistener_fuzzer:fuzztest",
"abilitystubunregistercollaborator_fuzzer:fuzztest",
"abilitystubunregisterconnectionobserver_fuzzer:fuzztest",
@@ -0,0 +1,76 @@
# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubAttachAppDebugFuzzTest") {
module_out_path = fuzz_test_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubattachappdebug_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitystubattachappdebug_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"hisysevent:libhisysevent",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityStubAttachAppDebugFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2025 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 "abilitystubattachappdebug_fuzzer.h"
#include <cstddef>
#include <cstdint>
#define private public
#include "ability_manager_service.h"
#undef private
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::ATTACH_APP_DEBUG);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_ =
std::make_shared<SubManagersHelper>(nullptr, nullptr);
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_->currentUIAbilityManager_ =
std::make_shared<UIAbilityLifecycleManager>();
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBATTACHAPPDEBUG_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBATTACHAPPDEBUG_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitystubattachappdebug_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBATTACHAPPDEBUG_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,76 @@
# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubDetachAppDebugFuzzTest") {
module_out_path = fuzz_test_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubdetachappdebug_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitystubdetachappdebug_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"hisysevent:libhisysevent",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityStubDetachAppDebugFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2025 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 "abilitystubdetachappdebug_fuzzer.h"
#include <cstddef>
#include <cstdint>
#define private public
#include "ability_manager_service.h"
#undef private
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::DETACH_APP_DEBUG);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_ =
std::make_shared<SubManagersHelper>(nullptr, nullptr);
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_->currentUIAbilityManager_ =
std::make_shared<UIAbilityLifecycleManager>();
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBDETACHAPPDEBUG_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBDETACHAPPDEBUG_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitystubdetachappdebug_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBDETACHAPPDEBUG_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,76 @@
# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubExecuteInsightIntentDoneFuzzTest") {
module_out_path = fuzz_test_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubexecuteinsightintentdone_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitystubexecuteinsightintentdone_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"hisysevent:libhisysevent",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityStubExecuteInsightIntentDoneFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2025 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 "abilitystubexecuteinsightintentdone_fuzzer.h"
#include <cstddef>
#include <cstdint>
#define private public
#include "ability_manager_service.h"
#undef private
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::EXECUTE_INSIGHT_INTENT_DONE);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_ =
std::make_shared<SubManagersHelper>(nullptr, nullptr);
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_->currentUIAbilityManager_ =
std::make_shared<UIAbilityLifecycleManager>();
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBEXECUTEINSIGHTINTENTDONE_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBEXECUTEINSIGHTINTENTDONE_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitystubexecuteinsightintentdone_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBEXECUTEINSIGHTINTENTDONE_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,76 @@
# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubExecuteIntentFuzzTest") {
module_out_path = fuzz_test_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubexecuteintent_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitystubexecuteintent_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"hisysevent:libhisysevent",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityStubExecuteIntentFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2025 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 "abilitystubexecuteintent_fuzzer.h"
#include <cstddef>
#include <cstdint>
#define private public
#include "ability_manager_service.h"
#undef private
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::EXECUTE_INTENT);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_ =
std::make_shared<SubManagersHelper>(nullptr, nullptr);
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_->currentUIAbilityManager_ =
std::make_shared<UIAbilityLifecycleManager>();
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBEXECUTEINTENT_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBEXECUTEINTENT_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitystubexecuteintent_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBEXECUTEINTENT_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,76 @@
# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubLogoutUserFuzzTest") {
module_out_path = fuzz_test_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystublogoutuser_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitystublogoutuser_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"hisysevent:libhisysevent",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityStubLogoutUserFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2025 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 "abilitystublogoutuser_fuzzer.h"
#include <cstddef>
#include <cstdint>
#define private public
#include "ability_manager_service.h"
#undef private
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::LOGOUT_USER);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_ =
std::make_shared<SubManagersHelper>(nullptr, nullptr);
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_->currentUIAbilityManager_ =
std::make_shared<UIAbilityLifecycleManager>();
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBLOGOUTUSER_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBLOGOUTUSER_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitystublogoutuser_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBLOGOUTUSER_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,76 @@
# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubRegisterAppDebugListenerFuzzTest") {
module_out_path = fuzz_test_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubregisterappdebuglistener_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitystubregisterappdebuglistener_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"hisysevent:libhisysevent",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityStubRegisterAppDebugListenerFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2025 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 "abilitystubregisterappdebuglistener_fuzzer.h"
#include <cstddef>
#include <cstdint>
#define private public
#include "ability_manager_service.h"
#undef private
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_APP_DEBUG_LISTENER);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_ =
std::make_shared<SubManagersHelper>(nullptr, nullptr);
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_->currentUIAbilityManager_ =
std::make_shared<UIAbilityLifecycleManager>();
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBREGISTERAPPDEBUGLISTENER_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBREGISTERAPPDEBUGLISTENER_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitystubregisterappdebuglistener_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBREGISTERAPPDEBUGLISTENER_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2025 Huawei Device Co., Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<fuzz_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>
@@ -0,0 +1,76 @@
# Copyright (c) 2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#####################hydra-fuzz###################
import("//build/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
import("//foundation/ability/ability_runtime/ability_runtime.gni")
##############################fuzztest##########################################
ohos_fuzztest("AbilityStubUnRegisterAppDebugListenerFuzzTest") {
module_out_path = fuzz_test_output_path
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilitystubunregisterappdebuglistener_fuzzer"
include_dirs = [ "${ability_runtime_innerkits_path}/ability_manager/include" ]
cflags = [
"-g",
"-O0",
"-Wno-unused-variable",
"-fno-omit-frame-pointer",
]
sources = [ "abilitystubunregisterappdebuglistener_fuzzer.cpp" ]
configs = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config" ]
deps = [
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
"${ability_runtime_native_path}/ability/native:abilitykit_native",
"${ability_runtime_services_path}/abilitymgr:abilityms",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"eventhandler:libeventhandler",
"ffrt:libffrt",
"hilog:libhilog",
"hisysevent:libhisysevent",
"ipc:ipc_core",
"napi:ace_napi",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
if (ability_runtime_graphics) {
external_deps += [
"input:libmmi-client",
"window_manager:libwm",
]
}
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
deps += [
# deps file
":AbilityStubUnRegisterAppDebugListenerFuzzTest",
]
}
###############################################################################
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2025 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 "abilitystubunregisterappdebuglistener_fuzzer.h"
#include <cstddef>
#include <cstdint>
#define private public
#include "ability_manager_service.h"
#undef private
#include "message_parcel.h"
#include "securec.h"
using namespace OHOS::AAFwk;
namespace OHOS {
namespace {
constexpr size_t U32_AT_SIZE = 4;
}
const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager";
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
{
uint32_t code = static_cast<uint32_t>(AbilityManagerInterfaceCode::UNREGISTER_APP_DEBUG_LISTENER);
MessageParcel parcel;
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
MessageParcel reply;
MessageOption option;
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_ =
std::make_shared<SubManagersHelper>(nullptr, nullptr);
DelayedSingleton<AbilityManagerService>::GetInstance()->subManagersHelper_->currentUIAbilityManager_ =
std::make_shared<UIAbilityLifecycleManager>();
DelayedSingleton<AbilityManagerService>::GetInstance()->OnRemoteRequest(code, parcel, reply, option);
return true;
}
}
/* Fuzzer entry point */
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
/* Run your code on data */
if (data == nullptr) {
std::cout << "invalid data" << std::endl;
return 0;
}
/* Validate the length of size */
if (size < OHOS::U32_AT_SIZE) {
return 0;
}
char* ch = static_cast<char*>(malloc(size + 1));
if (ch == nullptr) {
std::cout << "malloc failed." << std::endl;
return 0;
}
(void)memset_s(ch, size + 1, 0x00, size + 1);
if (memcpy_s(ch, size, data, size) != EOK) {
std::cout << "copy failed." << std::endl;
free(ch);
ch = nullptr;
return 0;
}
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
free(ch);
ch = nullptr;
return 0;
}
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2025 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 FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBUNREGISTERAPPDEBUGLISTENER_FUZZER_H
#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBUNREGISTERAPPDEBUGLISTENER_FUZZER_H
#define FUZZ_PROJECT_NAME "abilitystubunregisterappdebuglistener_fuzzer"
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYSTUBUNREGISTERAPPDEBUGLISTENER_FUZZER_H
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
FUZZ
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2025 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>