diff --git a/test/fuzztest/advancednotificationservice/BUILD.gn b/test/fuzztest/advancednotificationservice/BUILD.gn index d2ce258a4a8ebd87462d755b4f0ab3ce015756d9..544826e8755af8d92fd5ab95d099d2bfd0870973 100644 --- a/test/fuzztest/advancednotificationservice/BUILD.gn +++ b/test/fuzztest/advancednotificationservice/BUILD.gn @@ -18,5 +18,96 @@ group("fuzztest") { deps = [ "servicepublish_fuzzer:ServicePublishFuzzTest", + "servicesetdistributedenabledbybundle_fuzzer:ServiceSetDistributedEnabledByBundleFuzzTest", + "servicesetbadgenumberfordhbybundle_fuzzer:ServiceSetBadgeNumberForDhByBundleFuzzTest", + "servicesetslotflagsasbundle_fuzzer:ServiceSetSlotFlagsAsBundleFuzzTest", + "servicepublishnotificationforindirectproxy_fuzzer:ServicePublishNotificationForIndirectProxyFuzzTest", + "servicegetsyncnotificationenabledwithoutapp_fuzzer:ServiceGetSyncNotificationEnabledWithoutAppFuzzTest", + "servicesubscribe_fuzzer:ServiceSubscribeFuzzTest", + "servicegetnotificationrequestbyhashcode_fuzzer:ServiceGetNotificationRequestByHashCodeFuzzTest", + "serviceregisterpushcallback_fuzzer:ServiceRegisterPushCallbackFuzzTest", + "serviceremovenotification_fuzzer:ServiceRemoveNotificationFuzzTest", + "servicegetslotsbybundle_fuzzer:ServiceGetSlotsByBundleFuzzTest", + "servicepublishasbundle_fuzzer:ServicePublishAsBundleFuzzTest", + "servicecancelall_fuzzer:ServiceCancelAllFuzzTest", + "serviceisdistributedenabledbybundle_fuzzer:ServiceIsDistributedEnabledByBundleFuzzTest", + "servicegetshowbadgeenabledforbundle_fuzzer:ServiceGetShowBadgeEnabledForBundleFuzzTest", + "servicedistributeoperation_fuzzer:ServiceDistributeOperationFuzzTest", + "servicedeleteallbyuser_fuzzer:ServiceDeleteAllByUserFuzzTest", + "serviceenabledistributedbybundle_fuzzer:ServiceEnableDistributedByBundleFuzzTest", + "servicesubscribelocalliveview_fuzzer:ServiceSubscribeLocalLiveViewFuzzTest", + "servicesubscribeself_fuzzer:ServiceSubscribeSelfFuzzTest", + "serviceremovegroupbybundle_fuzzer:ServiceRemoveGroupByBundleFuzzTest", + "serviceadddonotdisturbprofiles_fuzzer:ServiceAddDoNotDisturbProfilesFuzzTest", + "serviceisdistributedenablebybundle_fuzzer:ServiceIsDistributedEnableByBundleFuzzTest", + "serviceissmartreminderenabled_fuzzer:ServiceIsSmartReminderEnabledFuzzTest", + "serviceremovenotifications_fuzzer:ServiceRemoveNotificationsFuzzTest", + "servicepublishforindirectproxywithmaxcapacity_fuzzer:ServicePublishForIndirectProxyWithMaxCapacityFuzzTest", + "serviceissupporttemplate_fuzzer:ServiceIsSupportTemplateFuzzTest", + "servicecanpublishasbundle_fuzzer:ServiceCanPublishAsBundleFuzzTest", + "serviceunsubscribe_fuzzer:ServiceUnsubscribeFuzzTest", + "servicecancelgroup_fuzzer:ServiceCancelGroupFuzzTest", + "servicesetsyncnotificationenabledwithoutapp_fuzzer:ServiceSetSyncNotificationEnabledWithoutAppFuzzTest", + "servicepublishcontinuoustasknotification_fuzzer:ServicePublishContinuousTaskNotificationFuzzTest", + "serviceupdateslots_fuzzer:ServiceUpdateSlotsFuzzTest", + "servicegetslots_fuzzer:ServiceGetSlotsFuzzTest", + "servicegetenabledforbundleslotself_fuzzer:ServiceGetEnabledForBundleSlotSelfFuzzTest", + "servicesetnotificationbadgenum_fuzzer:ServiceSetNotificationBadgeNumFuzzTest", + "serviceremoveallnotifications_fuzzer:ServiceRemoveAllNotificationsFuzzTest", + "servicegetenabledforbundleslot_fuzzer:ServiceGetEnabledForBundleSlotFuzzTest", + "servicesetbadgenumberbybundle_fuzzer:ServiceSetBadgeNumberByBundleFuzzTest", + "servicesethashcoderule_fuzzer:ServiceSetHashCodeRuleFuzzTest", + "serviceisneedsilentindonotdisturbmode_fuzzer:ServiceIsNeedSilentInDoNotDisturbModeFuzzTest", + "servicegetalldistribuedenabledbundles_fuzzer:ServiceGetAllDistribuedEnabledBundlesFuzzTest", + "servicesetnotificationsenabledforspecialbundle_fuzzer:ServiceSetNotificationsEnabledForSpecialBundleFuzzTest", + "servicegetslotbybundle_fuzzer:ServiceGetSlotByBundleFuzzTest", + "servicegetdonotdisturbprofile_fuzzer:ServiceGetDoNotDisturbProfileFuzzTest", + "servicecancelasbundlewithagent_fuzzer:ServiceCancelAsBundleWithAgentFuzzTest", + "servicesetsmartreminderenabled_fuzzer:ServiceSetSmartReminderEnabledFuzzTest", + "serviceisspecialuserallowednotify_fuzzer:ServiceIsSpecialUserAllowedNotifyFuzzTest", + "servicesetbadgenumber_fuzzer:ServiceSetBadgeNumberFuzzTest", + "servicesetnotificationsenabledforbundle_fuzzer:ServiceSetNotificationsEnabledForBundleFuzzTest", + "servicesetadditionconfig_fuzzer:ServiceSetAdditionConfigFuzzTest", + "servicesetdonotdisturbdate_fuzzer:ServiceSetDoNotDisturbDateFuzzTest", + "servicegetslotnumasbundle_fuzzer:ServiceGetSlotNumAsBundleFuzzTest", + "serviceaddslots_fuzzer:ServiceAddSlotsFuzzTest", + "servicegetspecialactivenotifications_fuzzer:ServiceGetSpecialActiveNotificationsFuzzTest", + "servicegetallliveviewenabledbundles_fuzzer:ServiceGetAllLiveViewEnabledBundlesFuzzTest", + "servicesetshowbadgeenabledforbundle_fuzzer:ServiceSetShowBadgeEnabledForBundleFuzzTest", + "servicedisablenotificationfeature_fuzzer:ServiceDisableNotificationFeatureFuzzTest", + "servicecancel_fuzzer:ServiceCancelFuzzTest", + "servicereplydistributeoperation_fuzzer:ServiceReplyDistributeOperationFuzzTest", + "servicegetdonotdisturbdate_fuzzer:ServiceGetDoNotDisturbDateFuzzTest", + "servicesettargetdevicestatus_fuzzer:ServiceSetTargetDeviceStatusFuzzTest", + "servicesetenabledforbundleslot_fuzzer:ServiceSetEnabledForBundleSlotFuzzTest", + "serviceremovedonotdisturbprofiles_fuzzer:ServiceRemoveDoNotDisturbProfilesFuzzTest", + "serviceshelldump_fuzzer:ServiceShellDumpFuzzTest", + "servicegetbundleimportance_fuzzer:ServiceGetBundleImportanceFuzzTest", + "servicegetactivenotifications_fuzzer:ServiceGetActiveNotificationsFuzzTest", + "servicesetnotificationsenabledforallbundles_fuzzer:ServiceSetNotificationsEnabledForAllBundlesFuzzTest", + "servicecanpopenablenotificationdialog_fuzzer:ServiceCanPopEnableNotificationDialogFuzzTest", + "servicecancelcontinuoustasknotification_fuzzer:ServiceCancelContinuousTaskNotificationFuzzTest", + "servicepublishwithmaxcapacity_fuzzer:ServicePublishWithMaxCapacityFuzzTest", + "servicegetdeviceremindtype_fuzzer:ServiceGetDeviceRemindTypeFuzzTest", + "servicedelete_fuzzer:ServiceDeleteFuzzTest", + "servicesetdistributedenabledbyslot_fuzzer:ServiceSetDistributedEnabledBySlotFuzzTest", + "servicesetnotificationsenabledbyuser_fuzzer:ServiceSetNotificationsEnabledByUserFuzzTest", + "servicedeletebybundle_fuzzer:ServiceDeleteByBundleFuzzTest", + "servicegetallnotificationsbyslottype_fuzzer:ServiceGetAllNotificationsBySlotTypeFuzzTest", + "servicepublishasbundlewithmaxcapacity_fuzzer:ServicePublishAsBundleWithMaxCapacityFuzzTest", + "servicegettargetdevicestatus_fuzzer:ServiceGetTargetDeviceStatusFuzzTest", + "servicegetactivenotificationbyfilter_fuzzer:ServiceGetActiveNotificationByFilterFuzzTest", + "servicegetslotbytype_fuzzer:ServiceGetSlotByTypeFuzzTest", + "servicerequestenablenotification_fuzzer:ServiceRequestEnableNotificationFuzzTest", + "servicegetslotflagsasbundle_fuzzer:ServiceGetSlotFlagsAsBundleFuzzTest", + "servicetriggerlocalliveview_fuzzer:ServiceTriggerLocalLiveViewFuzzTest", + "serviceallowusereminder_fuzzer:ServiceAllowUseReminderFuzzTest", + "serviceisspecialbundleallowednotify_fuzzer:ServiceIsSpecialBundleAllowedNotifyFuzzTest", + "serviceremoveslotbytype_fuzzer:ServiceRemoveSlotByTypeFuzzTest", + "servicecancelasbundle_fuzzer:ServiceCancelAsBundleFuzzTest", + "serviceaddslotbytype_fuzzer:ServiceAddSlotByTypeFuzzTest", + "serviceupdatenotificationtimerbyuid_fuzzer:ServiceUpdateNotificationTimerByUidFuzzTest", + "serviceisdistributedenabledbyslot_fuzzer:ServiceIsDistributedEnabledBySlotFuzzTest", + "serviceremovedistributednotifications_fuzzer:ServiceRemoveDistributedNotificationsFuzzTest", ] -} +} \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ed210df3a1908ea515d19a2b2b6e539ee5d15a11 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceAddDoNotDisturbProfilesFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_adddonotdisturbprofiles_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceAddDoNotDisturbProfilesFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/service_adddonotdisturbprofiles_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/service_adddonotdisturbprofiles_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4e21d92e4a57cded9c0c03734df87dfda15289e4 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/service_adddonotdisturbprofiles_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_adddonotdisturbprofiles_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/service_adddonotdisturbprofiles_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/service_adddonotdisturbprofiles_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7ab675b5b7bc00037a680df76750fffb2c24edad --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceadddonotdisturbprofiles_fuzzer/service_adddonotdisturbprofiles_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ADDDONOTDISTURBPROFILES_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ADDDONOTDISTURBPROFILES_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceadddonotdisturbprofiles_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ADDDONOTDISTURBPROFILES_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..02251078bbf425ef060bc74cdf32206f1880f71a --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceAddSlotByTypeFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_addslotbytype_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceAddSlotByTypeFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/service_addslotbytype_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/service_addslotbytype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e9f337907c87bf84f58e8fc8e52d146916937422 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/service_addslotbytype_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_addslotbytype_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/service_addslotbytype_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/service_addslotbytype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..821c09e94ad8074e14d12a3b01a55a43c3abd407 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslotbytype_fuzzer/service_addslotbytype_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ADDSLOTBYTYPE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ADDSLOTBYTYPE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceaddslotbytype_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ADDSLOTBYTYPE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9a2181ced01bd10e1626f7254b14d2c4edf76440 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceAddSlotsFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_addslots_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceAddSlotsFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/service_addslots_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/service_addslots_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c6e81bdc7949f214f9d28dabd4ee0cabb917769e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/service_addslots_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_addslots_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/service_addslots_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/service_addslots_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..61bf0bfad8dde5aee9193027fc1cc5f90bdd77ca --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceaddslots_fuzzer/service_addslots_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ADDSLOTS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ADDSLOTS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceaddslots_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ADDSLOTS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..536829fefdde8522fa3bb7cc54264f9b73090fad --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceAllowUseReminderFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_allowusereminder_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceAllowUseReminderFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/service_allowusereminder_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/service_allowusereminder_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5a8bc01e7fef09b06d56b6690692f0f115386513 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/service_allowusereminder_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_allowusereminder_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/service_allowusereminder_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/service_allowusereminder_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..067be7b7589556498f775ecd831b049a3be06acc --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceallowusereminder_fuzzer/service_allowusereminder_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ALLOWUSEREMINDER_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ALLOWUSEREMINDER_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceallowusereminder_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ALLOWUSEREMINDER_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..23dc1320aa938ae0e1915f49987c049619bd2cc4 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceCancelFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicecancel_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_cancel_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceCancelFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3dace1401ca5763efd1e26264fc382573ba79676 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_cancel_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.h b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..2b4361c1e20484eb7d18f4d494e0d3291de6e66a --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancel_fuzzer/service_cancel_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCEL_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCEL_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicecancel_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCEL_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..624bdfd48616db2c9928ad547694d36cf6e6e620 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceCancelAllFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_cancelall_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceCancelAllFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/service_cancelall_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/service_cancelall_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e3198ba83178431c37753688af73fae127768132 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/service_cancelall_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_cancelall_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/service_cancelall_fuzzer.h b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/service_cancelall_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d2f471d7b303324163fa8236d182f61b201b6c76 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelall_fuzzer/service_cancelall_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELALL_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELALL_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicecancelall_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELALL_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..73b8b0139fb85f1c4a473980885f518050bd6200 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceCancelAsBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_cancelasbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceCancelAsBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/service_cancelasbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/service_cancelasbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ddae103e7da684b956658b77087e41550128b08e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/service_cancelasbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_cancelasbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/service_cancelasbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/service_cancelasbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..16db997cf48b2747171f5d1a28e675cf22547c06 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundle_fuzzer/service_cancelasbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELASBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELASBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicecancelasbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELASBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e59ec270c81a5b0712fcd56102f917eec052a526 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceCancelAsBundleWithAgentFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_cancelasbundlewithagent_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceCancelAsBundleWithAgentFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/service_cancelasbundlewithagent_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/service_cancelasbundlewithagent_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6e1dab8d7686cba5050b72baf4e38317e352b482 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/service_cancelasbundlewithagent_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_cancelasbundlewithagent_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/service_cancelasbundlewithagent_fuzzer.h b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/service_cancelasbundlewithagent_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..557b7a385fd679963cfa575b82ab1b9b61e807eb --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelasbundlewithagent_fuzzer/service_cancelasbundlewithagent_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELASBUNDLEWITHAGENT_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELASBUNDLEWITHAGENT_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicecancelasbundlewithagent_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELASBUNDLEWITHAGENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f429ac0c59e3defcba610573a612f1bba3202d18 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceCancelContinuousTaskNotificationFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_cancelcontinuoustasknotification_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceCancelContinuousTaskNotificationFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f831c24003ada502461dab24ddf78c490f02ec86 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_cancelcontinuoustasknotification_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.h b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..a9d18f38d7a20a205b23919025f1c7d447ff6bfe --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelcontinuoustasknotification_fuzzer/service_cancelcontinuoustasknotification_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELCONTINUOUSTASKNOTIFICATION_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELCONTINUOUSTASKNOTIFICATION_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicecancelcontinuoustasknotification_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELCONTINUOUSTASKNOTIFICATION_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1f48307364940dd99f5ff2f37cfaaa4d9eea42f4 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceCancelGroupFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_cancelgroup_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceCancelGroupFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/service_cancelgroup_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/service_cancelgroup_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9e0e8533274790f4b4981f004d6b3b0789f093a7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/service_cancelgroup_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_cancelgroup_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/service_cancelgroup_fuzzer.h b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/service_cancelgroup_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..03acaa5c938c3d050556facda15b020ea3cdd5b9 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecancelgroup_fuzzer/service_cancelgroup_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELGROUP_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELGROUP_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicecancelgroup_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANCELGROUP_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..40a7779567eb89e8ec53549a2d5dcdd204310f61 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceCanPopEnableNotificationDialogFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_canpopenablenotificationdialog_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceCanPopEnableNotificationDialogFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ee5e5168e8a53e7b7a6aec9503bce3b874995a95 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_canpopenablenotificationdialog_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.h b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..23bc1a6dfe49e24adca7bb7d27de4b43100d89e4 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpopenablenotificationdialog_fuzzer/service_canpopenablenotificationdialog_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANPOPENABLENOTIFICATIONDIALOG_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANPOPENABLENOTIFICATIONDIALOG_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicecanpopenablenotificationdialog_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANPOPENABLENOTIFICATIONDIALOG_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d7a7358ace1f1342d0ca1a88880cf5b7700960f1 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceCanPublishAsBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_canpublishasbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceCanPublishAsBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/service_canpublishasbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/service_canpublishasbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a14eb0e92e8101482b243d2a7adabc7f60c32d62 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/service_canpublishasbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_canpublishasbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/service_canpublishasbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/service_canpublishasbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..ba14dd71f2455a58780be99eb7df0f192b3d6a30 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicecanpublishasbundle_fuzzer/service_canpublishasbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANPUBLISHASBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANPUBLISHASBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicecanpublishasbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_CANPUBLISHASBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b256a5c9b5f4de47fc685b67f545353935396714 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceDeleteFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicedelete_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_delete_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceDeleteFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f20581c84556e20722f789b15cd76a8a43bc39ee --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_delete_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.h b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..b9db3e14514962600815539b37a30e5bae740dfb --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedelete_fuzzer/service_delete_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DELETE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DELETE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicedelete_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DELETE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..01ebce4cb99c7ec28b15c25f6594d044d3fb812e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceDeleteAllByUserFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_deleteallbyuser_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceDeleteAllByUserFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/service_deleteallbyuser_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/service_deleteallbyuser_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..79b8e652af4fdf862cf4b973d96c6cf642fe6378 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/service_deleteallbyuser_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_deleteallbyuser_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/service_deleteallbyuser_fuzzer.h b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/service_deleteallbyuser_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..a5dc6584cc89d4e8560994a1e36938fbbd128198 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeleteallbyuser_fuzzer/service_deleteallbyuser_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DELETEALLBYUSER_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DELETEALLBYUSER_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicedeleteallbyuser_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DELETEALLBYUSER_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c2d8ffb7330c00887122d64de115e7d437f8425f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceDeleteByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_deletebybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceDeleteByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3c1e1beba36f69d16850c12e6d46c6ed4792a2f8 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_deletebybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..3ca9a04191cb1aee77241348c022c9f528b1a6f6 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedeletebybundle_fuzzer/service_deletebybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DELETEBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DELETEBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicedeletebybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DELETEBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5f43ba6fdafc5bcb01e01cf2dabbdc15ad273eed --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceDisableNotificationFeatureFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_disablenotificationfeature_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceDisableNotificationFeatureFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b3c136406cc135c53a97465c933ea9623917d845 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_disablenotificationfeature_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.h b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..b71bcd1866fc85120d24edc268acb8a1c298cd52 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedisablenotificationfeature_fuzzer/service_disablenotificationfeature_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DISABLENOTIFICATIONFEATURE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DISABLENOTIFICATIONFEATURE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicedisablenotificationfeature_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DISABLENOTIFICATIONFEATURE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..26022e66e7271373253f92f095605b230ca5776d --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceDistributeOperationFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_distributeoperation_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceDistributeOperationFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/service_distributeoperation_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/service_distributeoperation_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7e110d46bf23756b8c0d5a51d17f07ae6e3b7f3b --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/service_distributeoperation_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_distributeoperation_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/service_distributeoperation_fuzzer.h b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/service_distributeoperation_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..e908c0eee5fcc43080c1154dc404fd3d6ed4951a --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicedistributeoperation_fuzzer/service_distributeoperation_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DISTRIBUTEOPERATION_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DISTRIBUTEOPERATION_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicedistributeoperation_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_DISTRIBUTEOPERATION_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6df71b4ba589fa091b4196be0dcbd989b942f3ed --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceEnableDistributedByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_enabledistributedbybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceEnableDistributedByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/service_enabledistributedbybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/service_enabledistributedbybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9e8ee7340e5b8a497fe31d2f8b69f42da5681fe8 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/service_enabledistributedbybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_enabledistributedbybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/service_enabledistributedbybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/service_enabledistributedbybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..92ae7416ad5f5cfb30822bac92869d5c699cc10a --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceenabledistributedbybundle_fuzzer/service_enabledistributedbybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ENABLEDISTRIBUTEDBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ENABLEDISTRIBUTEDBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceenabledistributedbybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ENABLEDISTRIBUTEDBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3040820a364052d8e7141934c2d4ad7dd46ab1dd --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetActiveNotificationByFilterFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getactivenotificationbyfilter_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetActiveNotificationByFilterFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/service_getactivenotificationbyfilter_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/service_getactivenotificationbyfilter_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9ddf5e7a2efe39c1d9f67777cdacf98eb553e8b6 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/service_getactivenotificationbyfilter_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getactivenotificationbyfilter_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/service_getactivenotificationbyfilter_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/service_getactivenotificationbyfilter_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..290025e59cda274b98847ef24de39bc6f43e8ba1 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotificationbyfilter_fuzzer/service_getactivenotificationbyfilter_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETACTIVENOTIFICATIONBYFILTER_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETACTIVENOTIFICATIONBYFILTER_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetactivenotificationbyfilter_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETACTIVENOTIFICATIONBYFILTER_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d27b1ff31f634ed6d5e6ab8d883c082893c4e711 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetActiveNotificationsFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getactivenotifications_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetActiveNotificationsFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9ce78257625c57a7d7dbd440415c332314377cf7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getactivenotifications_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..55670f2b0861a3a3ced771de346f45f90a66cd0a --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetactivenotifications_fuzzer/service_getactivenotifications_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETACTIVENOTIFICATIONS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETACTIVENOTIFICATIONS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetactivenotifications_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETACTIVENOTIFICATIONS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3639356052ab4448008774c50e0c7605a1c0261e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetAllDistribuedEnabledBundlesFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getalldistribuedenabledbundles_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetAllDistribuedEnabledBundlesFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/service_getalldistribuedenabledbundles_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/service_getalldistribuedenabledbundles_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..effe2d0445fd862468edb2990a74d59cc8c46459 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/service_getalldistribuedenabledbundles_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getalldistribuedenabledbundles_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/service_getalldistribuedenabledbundles_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/service_getalldistribuedenabledbundles_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..4f3a9665cc37d6b516ec3063be7f5e6d4717edc8 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetalldistribuedenabledbundles_fuzzer/service_getalldistribuedenabledbundles_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETALLDISTRIBUEDENABLEDBUNDLES_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETALLDISTRIBUEDENABLEDBUNDLES_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetalldistribuedenabledbundles_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETALLDISTRIBUEDENABLEDBUNDLES_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..acd8b803869e97119fb90d073dc24286bc2dea95 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetAllLiveViewEnabledBundlesFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getallliveviewenabledbundles_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetAllLiveViewEnabledBundlesFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d3fd0620db86e0ad04a02cf56325e094f44bb248 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getallliveviewenabledbundles_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..6e6d0fefe82911c488565423c3482842b9476d46 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallliveviewenabledbundles_fuzzer/service_getallliveviewenabledbundles_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETALLLIVEVIEWENABLEDBUNDLES_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETALLLIVEVIEWENABLEDBUNDLES_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetallliveviewenabledbundles_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETALLLIVEVIEWENABLEDBUNDLES_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..cf9e61d396b1a11ddfa094a4bd3f6e2d6bd77fee --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetAllNotificationsBySlotTypeFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getallnotificationsbyslottype_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetAllNotificationsBySlotTypeFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..10f2c6df0373150628ac165a9e458be694ac4d02 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getallnotificationsbyslottype_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..0a01b91fcc519929a7cc0c4c7d054a8612e279e3 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetallnotificationsbyslottype_fuzzer/service_getallnotificationsbyslottype_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETALLNOTIFICATIONSBYSLOTTYPE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETALLNOTIFICATIONSBYSLOTTYPE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetallnotificationsbyslottype_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETALLNOTIFICATIONSBYSLOTTYPE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..949a2c8f7013e373e2e64e30aaef23710e5c568d --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetBundleImportanceFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getbundleimportance_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetBundleImportanceFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3718993e6927cced1a647e51d55b26b644c64857 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getbundleimportance_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..a10702949e53332ffd0d0e2d1e302a80886d3cd1 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetbundleimportance_fuzzer/service_getbundleimportance_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETBUNDLEIMPORTANCE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETBUNDLEIMPORTANCE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetbundleimportance_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETBUNDLEIMPORTANCE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f2b4dccf90e415538f2219b01b1cacf55029a6dd --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetDeviceRemindTypeFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getdeviceremindtype_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetDeviceRemindTypeFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2ba549f41d35d1dac6af32a87af0fe1c16097df2 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getdeviceremindtype_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7785bafa82fb9c28676f8e096fda4b363322efa4 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdeviceremindtype_fuzzer/service_getdeviceremindtype_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETDEVICEREMINDTYPE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETDEVICEREMINDTYPE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetdeviceremindtype_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETDEVICEREMINDTYPE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2d85e77377c104ce980d73ddca3a2c156f1ca0be --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetDoNotDisturbDateFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getdonotdisturbdate_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetDoNotDisturbDateFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..275c98fc8c62770c28f48efa423767a7d213dc3e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getdonotdisturbdate_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..35c335ea0ee3e8f69d4a7d0ad668becbdd3e699f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbdate_fuzzer/service_getdonotdisturbdate_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETDONOTDISTURBDATE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETDONOTDISTURBDATE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetdonotdisturbdate_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETDONOTDISTURBDATE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c2cc1201cbdda2e4d6bad5b98864fdc296293731 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetDoNotDisturbProfileFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getdonotdisturbprofile_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetDoNotDisturbProfileFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/service_getdonotdisturbprofile_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/service_getdonotdisturbprofile_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..589fe2098adf1a52c1a2a669a16e927e8585fd50 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/service_getdonotdisturbprofile_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getdonotdisturbprofile_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/service_getdonotdisturbprofile_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/service_getdonotdisturbprofile_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..01b436317e3bd87b401ae1a9d028565e88ac246c --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetdonotdisturbprofile_fuzzer/service_getdonotdisturbprofile_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETDONOTDISTURBPROFILE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETDONOTDISTURBPROFILE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetdonotdisturbprofile_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETDONOTDISTURBPROFILE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1ccb0ea8dbac09476fd0848c0c4b5a1f38a691f9 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetEnabledForBundleSlotFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getenabledforbundleslot_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetEnabledForBundleSlotFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/service_getenabledforbundleslot_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/service_getenabledforbundleslot_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9c1a454e466c666197ac6f51aba366b8feedd5c2 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/service_getenabledforbundleslot_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getenabledforbundleslot_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/service_getenabledforbundleslot_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/service_getenabledforbundleslot_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..f5efd9e60d244a1193eef8b0544fd6923520f90f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslot_fuzzer/service_getenabledforbundleslot_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETENABLEDFORBUNDLESLOT_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETENABLEDFORBUNDLESLOT_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetenabledforbundleslot_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETENABLEDFORBUNDLESLOT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..13eb52445595517b5d3457b810e31182b0d1992f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetEnabledForBundleSlotSelfFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getenabledforbundleslotself_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetEnabledForBundleSlotSelfFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/service_getenabledforbundleslotself_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/service_getenabledforbundleslotself_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e531760e03961247af626fba0533b72b0ed9f6c5 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/service_getenabledforbundleslotself_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getenabledforbundleslotself_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/service_getenabledforbundleslotself_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/service_getenabledforbundleslotself_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..8227b08da4dc4082552991e92f488cbd948e11c8 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetenabledforbundleslotself_fuzzer/service_getenabledforbundleslotself_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETENABLEDFORBUNDLESLOTSELF_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETENABLEDFORBUNDLESLOTSELF_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetenabledforbundleslotself_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETENABLEDFORBUNDLESLOTSELF_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b551cbf1786f5b20b94088ba34635304310c3859 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetNotificationRequestByHashCodeFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getnotificationrequestbyhashcode_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetNotificationRequestByHashCodeFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/service_getnotificationrequestbyhashcode_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/service_getnotificationrequestbyhashcode_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..eb3146dfcabf83bbc0113d45e60d76c9319749b2 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/service_getnotificationrequestbyhashcode_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getnotificationrequestbyhashcode_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/service_getnotificationrequestbyhashcode_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/service_getnotificationrequestbyhashcode_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..3fe498ebe518a3238ddbb0404248942afd7bde4c --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetnotificationrequestbyhashcode_fuzzer/service_getnotificationrequestbyhashcode_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETNOTIFICATIONREQUESTBYHASHCODE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETNOTIFICATIONREQUESTBYHASHCODE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetnotificationrequestbyhashcode_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETNOTIFICATIONREQUESTBYHASHCODE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..60bc4dc1bc936fca1add371a1ba80f129bc086ae --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetShowBadgeEnabledForBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getshowbadgeenabledforbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetShowBadgeEnabledForBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/service_getshowbadgeenabledforbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/service_getshowbadgeenabledforbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..27f21b34b1e121ff6c4e551370983b1433db1313 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/service_getshowbadgeenabledforbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getshowbadgeenabledforbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/service_getshowbadgeenabledforbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/service_getshowbadgeenabledforbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..fc82cd545b7582bf6c24608d943f0781cc73ddeb --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetshowbadgeenabledforbundle_fuzzer/service_getshowbadgeenabledforbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSHOWBADGEENABLEDFORBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSHOWBADGEENABLEDFORBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetshowbadgeenabledforbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSHOWBADGEENABLEDFORBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..655b014c040db33df7ed9b1322007384e5cf4f2c --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetSlotByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getslotbybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetSlotByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/service_getslotbybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/service_getslotbybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..91f472ca6e2faf5aeeefbd112a29435074dbba93 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/service_getslotbybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getslotbybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/service_getslotbybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/service_getslotbybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..9e047f50c12423623ec35f7d3ed3df5c01dc2bd3 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbybundle_fuzzer/service_getslotbybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetslotbybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6d4df5f85b063e835febaaa9ef441ac011045529 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetSlotByTypeFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getslotbytype_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetSlotByTypeFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/service_getslotbytype_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/service_getslotbytype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..78e94faeb9fa856de5b155de38287a1b34f62e71 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/service_getslotbytype_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getslotbytype_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/service_getslotbytype_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/service_getslotbytype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..2d983a905aa6470183bea41ca0d659d1c4ecfcae --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotbytype_fuzzer/service_getslotbytype_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTBYTYPE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTBYTYPE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetslotbytype_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTBYTYPE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d86bd49b44b33dc5b0589959a62c47816c2637fe --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetSlotFlagsAsBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getslotflagsasbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetSlotFlagsAsBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/service_getslotflagsasbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/service_getslotflagsasbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f7678c9b476ac4bf8d3e9bfefba0bcaf2fd0142e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/service_getslotflagsasbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getslotflagsasbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/service_getslotflagsasbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/service_getslotflagsasbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..9e8c906c06988072dee66a5d9d5b145de687b63a --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotflagsasbundle_fuzzer/service_getslotflagsasbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTFLAGSASBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTFLAGSASBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetslotflagsasbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTFLAGSASBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0e5b0ad71a71a136ea56e1d39f1b0f83a0957af1 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetSlotNumAsBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getslotnumasbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetSlotNumAsBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/service_getslotnumasbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/service_getslotnumasbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..413992351f0e5e93c1dbbe2876bfb6e0e2377ac0 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/service_getslotnumasbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getslotnumasbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/service_getslotnumasbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/service_getslotnumasbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..9cfba785fdf3a424d82c99f52b6485c83c67def5 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotnumasbundle_fuzzer/service_getslotnumasbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTNUMASBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTNUMASBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetslotnumasbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTNUMASBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..68eb224ebe477badb7027e2cd8a2cfddff71e865 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetSlotsFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getslots_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetSlotsFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/service_getslots_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/service_getslots_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..27524e6799f35f1fc58fe83b4f7bee8e8c8ee3df --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/service_getslots_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getslots_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/service_getslots_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/service_getslots_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..ef2854289834cd79f73c263b126f284016c093e1 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslots_fuzzer/service_getslots_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetslots_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bf14456f728960f29647125636053877c3052c12 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetSlotsByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getslotsbybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetSlotsByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/service_getslotsbybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/service_getslotsbybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..136a30d5fd41ce05d059f6e3a17d9b31210943d0 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/service_getslotsbybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getslotsbybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/service_getslotsbybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/service_getslotsbybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d919a935638537ba644a54e73928dd9ca907008c --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetslotsbybundle_fuzzer/service_getslotsbybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTSBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTSBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetslotsbybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSLOTSBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a51a260637e11dc12d96c134c7bf78022e0b5574 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetSpecialActiveNotificationsFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getspecialactivenotifications_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetSpecialActiveNotificationsFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ff9661159d7e40677cf346da2761a11f973848e9 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getspecialactivenotifications_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..b8b6dead5970833d2f936cf2aaa045afcad3c225 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetspecialactivenotifications_fuzzer/service_getspecialactivenotifications_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSPECIALACTIVENOTIFICATIONS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSPECIALACTIVENOTIFICATIONS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetspecialactivenotifications_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSPECIALACTIVENOTIFICATIONS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e0f3dc99d2556845c065403d1ee2d8a6712c574e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetSyncNotificationEnabledWithoutAppFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_getsyncnotificationenabledwithoutapp_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetSyncNotificationEnabledWithoutAppFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/service_getsyncnotificationenabledwithoutapp_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/service_getsyncnotificationenabledwithoutapp_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..216c80c33b3031cc49ac88e75555b30c8b6c28e5 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/service_getsyncnotificationenabledwithoutapp_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_getsyncnotificationenabledwithoutapp_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/service_getsyncnotificationenabledwithoutapp_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/service_getsyncnotificationenabledwithoutapp_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..86b0860f8177d572f8d696f4a134d8ec77d4e083 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegetsyncnotificationenabledwithoutapp_fuzzer/service_getsyncnotificationenabledwithoutapp_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSYNCNOTIFICATIONENABLEDWITHOUTAPP_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSYNCNOTIFICATIONENABLEDWITHOUTAPP_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegetsyncnotificationenabledwithoutapp_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETSYNCNOTIFICATIONENABLEDWITHOUTAPP_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5e4ddb64bbd2cf52167ae7bcb4c9e5e0ebaadfe1 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceGetTargetDeviceStatusFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_gettargetdevicestatus_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceGetTargetDeviceStatusFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/service_gettargetdevicestatus_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/service_gettargetdevicestatus_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d0c2626b1a963952eea9593676b9165f80f1c6f4 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/service_gettargetdevicestatus_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_gettargetdevicestatus_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/service_gettargetdevicestatus_fuzzer.h b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/service_gettargetdevicestatus_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..b6d4d4a6263130d58ed12723108863f17c90f8de --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicegettargetdevicestatus_fuzzer/service_gettargetdevicestatus_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETTARGETDEVICESTATUS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETTARGETDEVICESTATUS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicegettargetdevicestatus_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_GETTARGETDEVICESTATUS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a197e67042ca9330fc8e3a9faebb6afbfe271c9b --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceIsDistributedEnableByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_isdistributedenablebybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceIsDistributedEnableByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/service_isdistributedenablebybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/service_isdistributedenablebybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bf25add0163d005dc0b882ec99abba4923384c51 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/service_isdistributedenablebybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_isdistributedenablebybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/service_isdistributedenablebybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/service_isdistributedenablebybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..439fefdd47345575ec7effa903a47f25ae146989 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenablebybundle_fuzzer/service_isdistributedenablebybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISDISTRIBUTEDENABLEBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISDISTRIBUTEDENABLEBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceisdistributedenablebybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISDISTRIBUTEDENABLEBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a11064a52e79dcd910bc876c65546788fd673bca --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceIsDistributedEnabledByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_isdistributedenabledbybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceIsDistributedEnabledByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/service_isdistributedenabledbybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/service_isdistributedenabledbybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..88b9f0068baf692a5b828c513221b9f6aa69b88d --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/service_isdistributedenabledbybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_isdistributedenabledbybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/service_isdistributedenabledbybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/service_isdistributedenabledbybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..c7019f8851c574e4626cb9483393455146481d4f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbybundle_fuzzer/service_isdistributedenabledbybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISDISTRIBUTEDENABLEDBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISDISTRIBUTEDENABLEDBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceisdistributedenabledbybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISDISTRIBUTEDENABLEDBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..11661c0ff0236d62000295d767da6b45965a1611 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceIsDistributedEnabledBySlotFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_isdistributedenabledbyslot_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceIsDistributedEnabledBySlotFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/service_isdistributedenabledbyslot_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/service_isdistributedenabledbyslot_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7bd99e8166bdd9bbf35bca9adf2ff52a0e066eb2 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/service_isdistributedenabledbyslot_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_isdistributedenabledbyslot_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/service_isdistributedenabledbyslot_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/service_isdistributedenabledbyslot_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..c1a5c4f7ec416498835a61f40811508ea9856fd7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisdistributedenabledbyslot_fuzzer/service_isdistributedenabledbyslot_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISDISTRIBUTEDENABLEDBYSLOT_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISDISTRIBUTEDENABLEDBYSLOT_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceisdistributedenabledbyslot_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISDISTRIBUTEDENABLEDBYSLOT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c6e08f653cc4c318c2a4c725b2ee4266d06a0a36 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceIsNeedSilentInDoNotDisturbModeFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_isneedsilentindonotdisturbmode_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceIsNeedSilentInDoNotDisturbModeFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/service_isneedsilentindonotdisturbmode_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/service_isneedsilentindonotdisturbmode_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7dc3a1027674429f2e36c6c935be958e8abcf75b --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/service_isneedsilentindonotdisturbmode_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_isneedsilentindonotdisturbmode_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/service_isneedsilentindonotdisturbmode_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/service_isneedsilentindonotdisturbmode_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..0854e96bca9f778203ed27f6f1504d7bd1307469 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisneedsilentindonotdisturbmode_fuzzer/service_isneedsilentindonotdisturbmode_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISNEEDSILENTINDONOTDISTURBMODE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISNEEDSILENTINDONOTDISTURBMODE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceisneedsilentindonotdisturbmode_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISNEEDSILENTINDONOTDISTURBMODE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..cf18ebb5182c3c51f59236bde9429c07a4e708a8 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceIsSmartReminderEnabledFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_issmartreminderenabled_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceIsSmartReminderEnabledFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/service_issmartreminderenabled_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/service_issmartreminderenabled_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8125f9c2625abb78abb1bd37a4c9070787a60934 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/service_issmartreminderenabled_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_issmartreminderenabled_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/service_issmartreminderenabled_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/service_issmartreminderenabled_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..dbd27885a865227f718bb38c6480340294d4a2ba --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissmartreminderenabled_fuzzer/service_issmartreminderenabled_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSMARTREMINDERENABLED_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSMARTREMINDERENABLED_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceissmartreminderenabled_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSMARTREMINDERENABLED_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..41990c03377553f63daf98b8221bde332c558cb5 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceIsSpecialBundleAllowedNotifyFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_isspecialbundleallowednotify_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceIsSpecialBundleAllowedNotifyFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/service_isspecialbundleallowednotify_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/service_isspecialbundleallowednotify_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..190c6953ad051ee6cb305990235f48d2420a6efa --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/service_isspecialbundleallowednotify_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_isspecialbundleallowednotify_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/service_isspecialbundleallowednotify_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/service_isspecialbundleallowednotify_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..ec805bb4b2c8352b8d8e9be833c06efaf63ff8e1 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialbundleallowednotify_fuzzer/service_isspecialbundleallowednotify_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSPECIALBUNDLEALLOWEDNOTIFY_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSPECIALBUNDLEALLOWEDNOTIFY_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceisspecialbundleallowednotify_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSPECIALBUNDLEALLOWEDNOTIFY_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c9bbe0295486cd2a59c33e12f0630521eb72baf7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceIsSpecialUserAllowedNotifyFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_isspecialuserallowednotify_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceIsSpecialUserAllowedNotifyFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/service_isspecialuserallowednotify_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/service_isspecialuserallowednotify_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ac4bd43453cf9300c0c3753c61adecb1d801814e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/service_isspecialuserallowednotify_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_isspecialuserallowednotify_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/service_isspecialuserallowednotify_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/service_isspecialuserallowednotify_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..bd0aacc60a2a195db7053b361bd1e4f13a1358b5 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceisspecialuserallowednotify_fuzzer/service_isspecialuserallowednotify_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSPECIALUSERALLOWEDNOTIFY_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSPECIALUSERALLOWEDNOTIFY_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceisspecialuserallowednotify_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSPECIALUSERALLOWEDNOTIFY_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..508be9a5272b4713ad3485c9ccd65370344a42cf --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceIsSupportTemplateFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_issupporttemplate_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceIsSupportTemplateFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/service_issupporttemplate_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/service_issupporttemplate_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4624afca3e3702c7114aac4ad6a24032ccd9689b --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/service_issupporttemplate_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_issupporttemplate_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/service_issupporttemplate_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/service_issupporttemplate_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..a462c1e1c4f5a545d76ec10f035a219428e0188f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceissupporttemplate_fuzzer/service_issupporttemplate_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSUPPORTTEMPLATE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSUPPORTTEMPLATE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceissupporttemplate_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_ISSUPPORTTEMPLATE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ba03f55b62c428406f62ac11d135dc48b6bc6b01 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServicePublishAsBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_publishasbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServicePublishAsBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/service_publishasbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/service_publishasbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5554a30432a52726e3a2394b1980f71e5bc08e4e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/service_publishasbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_publishasbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/service_publishasbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/service_publishasbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d8676b1072b0fbd3329e477b5a8401cd2eef36d3 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundle_fuzzer/service_publishasbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHASBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHASBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicepublishasbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHASBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d4c42f64bf1000fe6275a951b832db9e61719594 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServicePublishAsBundleWithMaxCapacityFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_publishasbundlewithmaxcapacity_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServicePublishAsBundleWithMaxCapacityFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..55b275228d0ec58a968f3118383789409123f2db --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_publishasbundlewithmaxcapacity_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.h b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..a608535bd193756bbe50b3d77056251a297222fd --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishasbundlewithmaxcapacity_fuzzer/service_publishasbundlewithmaxcapacity_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHASBUNDLEWITHMAXCAPACITY_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHASBUNDLEWITHMAXCAPACITY_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicepublishasbundlewithmaxcapacity_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHASBUNDLEWITHMAXCAPACITY_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d0cec3ade2d97556c2aae280753c5110a27f6721 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServicePublishContinuousTaskNotificationFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_publishcontinuoustasknotification_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServicePublishContinuousTaskNotificationFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/service_publishcontinuoustasknotification_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/service_publishcontinuoustasknotification_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e6c52125a2fe4e2ae54eac31ef2a257728756e43 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/service_publishcontinuoustasknotification_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_publishcontinuoustasknotification_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/service_publishcontinuoustasknotification_fuzzer.h b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/service_publishcontinuoustasknotification_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..8b1349f85708e2a0a126e76ad6cd5fef0e870672 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishcontinuoustasknotification_fuzzer/service_publishcontinuoustasknotification_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHCONTINUOUSTASKNOTIFICATION_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHCONTINUOUSTASKNOTIFICATION_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicepublishcontinuoustasknotification_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHCONTINUOUSTASKNOTIFICATION_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5d5d800e1475ee54ec00e638edb4291d3b612dbf --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServicePublishForIndirectProxyWithMaxCapacityFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_publishforindirectproxywithmaxcapacity_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServicePublishForIndirectProxyWithMaxCapacityFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/service_publishforindirectproxywithmaxcapacity_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/service_publishforindirectproxywithmaxcapacity_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ab9560a53ff57fe377bc8a6b02e1b7c2831e00e2 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/service_publishforindirectproxywithmaxcapacity_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_publishforindirectproxywithmaxcapacity_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/service_publishforindirectproxywithmaxcapacity_fuzzer.h b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/service_publishforindirectproxywithmaxcapacity_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..c6edfd69d5d610b8c03137496c59ffe93d2b9cf4 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishforindirectproxywithmaxcapacity_fuzzer/service_publishforindirectproxywithmaxcapacity_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHFORINDIRECTPROXYWITHMAXCAPACITY_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHFORINDIRECTPROXYWITHMAXCAPACITY_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicepublishforindirectproxywithmaxcapacity_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHFORINDIRECTPROXYWITHMAXCAPACITY_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5f0000d43280f7704e8f8dd15d09ff2f51164b04 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServicePublishNotificationForIndirectProxyFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_publishnotificationforindirectproxy_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServicePublishNotificationForIndirectProxyFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/service_publishnotificationforindirectproxy_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/service_publishnotificationforindirectproxy_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5aafc6827343f5dcc988d7e93648c0b84bc0c278 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/service_publishnotificationforindirectproxy_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_publishnotificationforindirectproxy_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/service_publishnotificationforindirectproxy_fuzzer.h b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/service_publishnotificationforindirectproxy_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..c10c33458bd557ddb1d164d4258e6c3a4f57b6b9 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishnotificationforindirectproxy_fuzzer/service_publishnotificationforindirectproxy_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHNOTIFICATIONFORINDIRECTPROXY_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHNOTIFICATIONFORINDIRECTPROXY_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicepublishnotificationforindirectproxy_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHNOTIFICATIONFORINDIRECTPROXY_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d29541a659cb4b341bff674ce0be80b46852f261 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServicePublishWithMaxCapacityFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_publishwithmaxcapacity_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServicePublishWithMaxCapacityFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4b02db214ec01c4c7deb3663ca62aaaffccc7ea --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_publishwithmaxcapacity_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.h b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..995266495da9d304dcca6ab2ad51b701d9f90a8b --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicepublishwithmaxcapacity_fuzzer/service_publishwithmaxcapacity_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHWITHMAXCAPACITY_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHWITHMAXCAPACITY_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicepublishwithmaxcapacity_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_PUBLISHWITHMAXCAPACITY_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..04bd2c44138f12e0fb4802f667f49e4237e499fb --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceRegisterPushCallbackFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_registerpushcallback_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceRegisterPushCallbackFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/service_registerpushcallback_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/service_registerpushcallback_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..56f10cddab413098edd7177d66002bfe397cd0f7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/service_registerpushcallback_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_registerpushcallback_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/service_registerpushcallback_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/service_registerpushcallback_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..0b8ee101207cbe88351e816040aa8cef5f3661a1 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceregisterpushcallback_fuzzer/service_registerpushcallback_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REGISTERPUSHCALLBACK_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REGISTERPUSHCALLBACK_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceregisterpushcallback_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REGISTERPUSHCALLBACK_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0ce92734dc53a3655cf132278d04c9680d044c00 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceRemoveAllNotificationsFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_removeallnotifications_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceRemoveAllNotificationsFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/service_removeallnotifications_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/service_removeallnotifications_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e759156ffaf7bd25a79aba77ee0a45bb4adf37b1 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/service_removeallnotifications_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_removeallnotifications_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/service_removeallnotifications_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/service_removeallnotifications_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..566da5cd76f1d23fcfeabfe5ece6e0b1f587662b --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveallnotifications_fuzzer/service_removeallnotifications_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEALLNOTIFICATIONS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEALLNOTIFICATIONS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceremoveallnotifications_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEALLNOTIFICATIONS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b9b1000666dee3c875dabdad9794b3e286f6e356 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceRemoveDistributedNotificationsFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_removedistributednotifications_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceRemoveDistributedNotificationsFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/service_removedistributednotifications_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/service_removedistributednotifications_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9152e6dd54e3803a39c99b7a2b200e81d8bc288c --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/service_removedistributednotifications_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_removedistributednotifications_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/service_removedistributednotifications_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/service_removedistributednotifications_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..aee6e9338205c9348614bf38bc2e8eab37cdf31d --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedistributednotifications_fuzzer/service_removedistributednotifications_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEDISTRIBUTEDNOTIFICATIONS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEDISTRIBUTEDNOTIFICATIONS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceremovedistributednotifications_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEDISTRIBUTEDNOTIFICATIONS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9403bf3746a510829c4b5a94135c8469369c51c6 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceRemoveDoNotDisturbProfilesFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_removedonotdisturbprofiles_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceRemoveDoNotDisturbProfilesFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e8692ec1107efec075c159f6b5245514246a1cd7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_removedonotdisturbprofiles_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7b34246df8d5f2fadc8281821a897a08f500f37d --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovedonotdisturbprofiles_fuzzer/service_removedonotdisturbprofiles_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEDONOTDISTURBPROFILES_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEDONOTDISTURBPROFILES_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceremovedonotdisturbprofiles_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEDONOTDISTURBPROFILES_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a28c4f663400e3721169b190c3643e818259313f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceRemoveGroupByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_removegroupbybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceRemoveGroupByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/service_removegroupbybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/service_removegroupbybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..72aa484a592767734b92d8c54ad3aaf2c5bab824 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/service_removegroupbybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_removegroupbybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/service_removegroupbybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/service_removegroupbybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..53e10ac3ba54e9a2b3e4b385d5214e50fad4d739 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovegroupbybundle_fuzzer/service_removegroupbybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEGROUPBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEGROUPBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceremovegroupbybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVEGROUPBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..19cba67fe665eb97e83112f2c381e931d134c507 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceRemoveNotificationFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_removenotification_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceRemoveNotificationFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/service_removenotification_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/service_removenotification_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c66de57b166d73d11e971011895c3655ee7a4b2e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/service_removenotification_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_removenotification_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/service_removenotification_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/service_removenotification_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..e685394476ecdaa0c18d704198a14d5f00dbc73c --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotification_fuzzer/service_removenotification_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVENOTIFICATION_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVENOTIFICATION_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceremovenotification_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVENOTIFICATION_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3a0e805c773cba30cf9703779546f40b68d7c858 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceRemoveNotificationsFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_removenotifications_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceRemoveNotificationsFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/service_removenotifications_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/service_removenotifications_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..855b2ecac359525f2f68dc4c4215b9c972b42e0a --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/service_removenotifications_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_removenotifications_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/service_removenotifications_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/service_removenotifications_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..1374b9887e0ee591d2d356a64ad17290fb53603c --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremovenotifications_fuzzer/service_removenotifications_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVENOTIFICATIONS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVENOTIFICATIONS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceremovenotifications_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVENOTIFICATIONS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d8fa057dcc92b03a52cd87ad96b96443a49a9cd9 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceRemoveSlotByTypeFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_removeslotbytype_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceRemoveSlotByTypeFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/service_removeslotbytype_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/service_removeslotbytype_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4564b2a6ba169ebefbd3f4444819cc6d8d7251eb --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/service_removeslotbytype_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_removeslotbytype_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/service_removeslotbytype_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/service_removeslotbytype_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..76c4cd3853446b3852afc710d3779ce7bd381436 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceremoveslotbytype_fuzzer/service_removeslotbytype_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVESLOTBYTYPE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVESLOTBYTYPE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceremoveslotbytype_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REMOVESLOTBYTYPE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..84927d33c982b9aab8a81b23ce24345ed6bddf46 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceReplyDistributeOperationFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_replydistributeoperation_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceReplyDistributeOperationFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..63d4ccdf0952236a0af66da9268a07a95bbf0013 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_replydistributeoperation_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.h b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..245cd51a077a6ab7a981bfb0c6a6fb80327040b8 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicereplydistributeoperation_fuzzer/service_replydistributeoperation_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REPLYDISTRIBUTEOPERATION_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REPLYDISTRIBUTEOPERATION_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicereplydistributeoperation_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REPLYDISTRIBUTEOPERATION_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..75931363bdee79849a6beba557e18d44bc5ac171 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceRequestEnableNotificationFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_requestenablenotification_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceRequestEnableNotificationFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/service_requestenablenotification_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/service_requestenablenotification_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..49d9e41e69c3618e223651ae8ab9d6f263fc8300 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/service_requestenablenotification_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_requestenablenotification_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/service_requestenablenotification_fuzzer.h b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/service_requestenablenotification_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d62aac6125f1bf6e02d8caa4c23333245f5ed3e6 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicerequestenablenotification_fuzzer/service_requestenablenotification_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REQUESTENABLENOTIFICATION_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REQUESTENABLENOTIFICATION_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicerequestenablenotification_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_REQUESTENABLENOTIFICATION_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..466c99fc8ff8af34a9d70b2ae34f6d7105cbd669 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetAdditionConfigFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setadditionconfig_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetAdditionConfigFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/service_setadditionconfig_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/service_setadditionconfig_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..81d75e4cd18ee92a03165216ac65f2bb06aa71ec --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/service_setadditionconfig_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setadditionconfig_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/service_setadditionconfig_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/service_setadditionconfig_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..c055c79107ca1e1fb7920668af203a408263ee3e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetadditionconfig_fuzzer/service_setadditionconfig_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETADDITIONCONFIG_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETADDITIONCONFIG_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetadditionconfig_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETADDITIONCONFIG_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3bce683e04db981ef33ccfc96222583bcef1670e --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetBadgeNumberFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setbadgenumber_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetBadgeNumberFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/service_setbadgenumber_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/service_setbadgenumber_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1f6c7e0c0eac1b14d42fd980d61835a4ac4b87fc --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/service_setbadgenumber_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setbadgenumber_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/service_setbadgenumber_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/service_setbadgenumber_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..589c82d03e6f3c8e7572170779a2d13492e23336 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumber_fuzzer/service_setbadgenumber_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETBADGENUMBER_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETBADGENUMBER_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetbadgenumber_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETBADGENUMBER_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..841298385f73845a6ade4566837d941941c728fe --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetBadgeNumberByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setbadgenumberbybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetBadgeNumberByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/service_setbadgenumberbybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/service_setbadgenumberbybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a8124318ca74566662e361176dff9d0295334fa4 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/service_setbadgenumberbybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setbadgenumberbybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/service_setbadgenumberbybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/service_setbadgenumberbybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..1f577f50ab5e8d0abc97cdc7746d632200ec0c52 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberbybundle_fuzzer/service_setbadgenumberbybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETBADGENUMBERBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETBADGENUMBERBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetbadgenumberbybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETBADGENUMBERBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d38ae0caeddcde439ae89a4d08d2c478fea469c2 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetBadgeNumberForDhByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setbadgenumberfordhbybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetBadgeNumberForDhByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/service_setbadgenumberfordhbybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/service_setbadgenumberfordhbybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..df8ad3cc774be663696e5639dbf8a293a8a91122 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/service_setbadgenumberfordhbybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setbadgenumberfordhbybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/service_setbadgenumberfordhbybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/service_setbadgenumberfordhbybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..49bb244eb8f0655a311644ba5ed64a2feb3938ab --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetbadgenumberfordhbybundle_fuzzer/service_setbadgenumberfordhbybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETBADGENUMBERFORDHBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETBADGENUMBERFORDHBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetbadgenumberfordhbybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETBADGENUMBERFORDHBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9c709baf5fec19e31eefc25e7dcc09d4c3492277 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetDistributedEnabledByBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setdistributedenabledbybundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetDistributedEnabledByBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/service_setdistributedenabledbybundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/service_setdistributedenabledbybundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..466d90492a081639f181aa3ddf66be1b949099ed --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/service_setdistributedenabledbybundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setdistributedenabledbybundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/service_setdistributedenabledbybundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/service_setdistributedenabledbybundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..ed6750734b9a9fb724a5e1bf835cced1c2210844 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbybundle_fuzzer/service_setdistributedenabledbybundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETDISTRIBUTEDENABLEDBYBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETDISTRIBUTEDENABLEDBYBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetdistributedenabledbybundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETDISTRIBUTEDENABLEDBYBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..30f40913e3ef4da47c2e53614c06df87acfbf983 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetDistributedEnabledBySlotFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setdistributedenabledbyslot_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetDistributedEnabledBySlotFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8be81f13c4b17068c5ada65fab67bf1e68078336 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setdistributedenabledbyslot_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..bd0928b251eb1e7b87d8ef5d7a74e5b9ce9ce07a --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdistributedenabledbyslot_fuzzer/service_setdistributedenabledbyslot_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETDISTRIBUTEDENABLEDBYSLOT_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETDISTRIBUTEDENABLEDBYSLOT_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetdistributedenabledbyslot_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETDISTRIBUTEDENABLEDBYSLOT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..818fbbb4bef7b82bf48358577a521be1ac39c9e5 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetDoNotDisturbDateFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setdonotdisturbdate_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetDoNotDisturbDateFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/service_setdonotdisturbdate_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/service_setdonotdisturbdate_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..607e56a4ba5e36064b2f10962574ef682eeb9df6 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/service_setdonotdisturbdate_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setdonotdisturbdate_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/service_setdonotdisturbdate_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/service_setdonotdisturbdate_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..1dbb94705c9fe55331721f03e5b56a7c83a72f89 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetdonotdisturbdate_fuzzer/service_setdonotdisturbdate_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETDONOTDISTURBDATE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETDONOTDISTURBDATE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetdonotdisturbdate_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETDONOTDISTURBDATE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6ca90b71934560085621c5d9921d3cdd6fa5f939 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetEnabledForBundleSlotFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setenabledforbundleslot_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetEnabledForBundleSlotFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2d69fed755988add6d55ea3b5de11eb4a5a27321 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setenabledforbundleslot_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..3b6c3ee449ab02a053c45bb983ec0bbbbcd18b1f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetenabledforbundleslot_fuzzer/service_setenabledforbundleslot_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETENABLEDFORBUNDLESLOT_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETENABLEDFORBUNDLESLOT_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetenabledforbundleslot_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETENABLEDFORBUNDLESLOT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..76e29e78fecde07adf7c2818eda6390c61637038 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetHashCodeRuleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_sethashcoderule_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetHashCodeRuleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/service_sethashcoderule_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/service_sethashcoderule_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f072f76d931e40f2ccddb7d23b38eea05cd3f825 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/service_sethashcoderule_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_sethashcoderule_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/service_sethashcoderule_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/service_sethashcoderule_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7f44085f2443b8443435f0810557728088aaec40 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesethashcoderule_fuzzer/service_sethashcoderule_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETHASHCODERULE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETHASHCODERULE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesethashcoderule_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETHASHCODERULE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ca8b2675e166378ecde0387ba2ad19d8ccd53ce3 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetNotificationBadgeNumFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setnotificationbadgenum_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetNotificationBadgeNumFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/service_setnotificationbadgenum_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/service_setnotificationbadgenum_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9dab544e4270e44c79c5bcb77fb8d8310e128b72 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/service_setnotificationbadgenum_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setnotificationbadgenum_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/service_setnotificationbadgenum_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/service_setnotificationbadgenum_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..b617aa2c5dffe888203d8cc3099abdb6b1534b64 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationbadgenum_fuzzer/service_setnotificationbadgenum_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONBADGENUM_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONBADGENUM_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetnotificationbadgenum_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONBADGENUM_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a00b1a2511ae3d253eb1db26156824e52671968d --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetNotificationsEnabledByUserFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setnotificationsenabledbyuser_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetNotificationsEnabledByUserFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0f8c4f830395c2b977090097800aa6f214b47eb5 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setnotificationsenabledbyuser_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..eb613826288ba585861f170609675d7f2b22f982 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledbyuser_fuzzer/service_setnotificationsenabledbyuser_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDBYUSER_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDBYUSER_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetnotificationsenabledbyuser_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDBYUSER_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e1edcca891747460ae430d1c969736df3e7975a9 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetNotificationsEnabledForAllBundlesFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setnotificationsenabledforallbundles_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetNotificationsEnabledForAllBundlesFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4feac67ec5072a41e50259139f5300141ec481f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setnotificationsenabledforallbundles_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..6d708e6563c0e179012483575ed01629d862d418 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforallbundles_fuzzer/service_setnotificationsenabledforallbundles_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDFORALLBUNDLES_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDFORALLBUNDLES_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetnotificationsenabledforallbundles_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDFORALLBUNDLES_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..957b93fb385a0cc6fe6c9f1f3c4ff7990b2c0847 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetNotificationsEnabledForBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setnotificationsenabledforbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetNotificationsEnabledForBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/service_setnotificationsenabledforbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/service_setnotificationsenabledforbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e7b0cd253d2b12ec4c193684eafcefd3be90e141 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/service_setnotificationsenabledforbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setnotificationsenabledforbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/service_setnotificationsenabledforbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/service_setnotificationsenabledforbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7c836ece2fa79c582a087c005aa5ecbfbf477dd4 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforbundle_fuzzer/service_setnotificationsenabledforbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDFORBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDFORBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetnotificationsenabledforbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDFORBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..62fc87c33240227a45b334ee88a953939ccfb4b2 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetNotificationsEnabledForSpecialBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setnotificationsenabledforspecialbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetNotificationsEnabledForSpecialBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/service_setnotificationsenabledforspecialbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/service_setnotificationsenabledforspecialbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cd56aa1b509c36e9a98e2c139569ecc502957203 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/service_setnotificationsenabledforspecialbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setnotificationsenabledforspecialbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/service_setnotificationsenabledforspecialbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/service_setnotificationsenabledforspecialbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..244621683b7e4533bafa119067aeb80d2cb35876 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetnotificationsenabledforspecialbundle_fuzzer/service_setnotificationsenabledforspecialbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDFORSPECIALBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDFORSPECIALBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetnotificationsenabledforspecialbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETNOTIFICATIONSENABLEDFORSPECIALBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7af08c1c193bbd8af9b321f2712b5b8c9bb61ee2 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetShowBadgeEnabledForBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setshowbadgeenabledforbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetShowBadgeEnabledForBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3c1f6ccd66aa8dd22070c2b94f5e6a68cc1d4f8f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setshowbadgeenabledforbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..b13bf4ea8f715330f31a1448ed4e0b9548967d32 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetshowbadgeenabledforbundle_fuzzer/service_setshowbadgeenabledforbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSHOWBADGEENABLEDFORBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSHOWBADGEENABLEDFORBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetshowbadgeenabledforbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSHOWBADGEENABLEDFORBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..cbb32fcb3c5284d5dedd5a0964134fca933c2fd8 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetSlotFlagsAsBundleFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setslotflagsasbundle_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetSlotFlagsAsBundleFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/service_setslotflagsasbundle_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/service_setslotflagsasbundle_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dbf0f5a5632ce8340340e9a57b368f8c026eb27d --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/service_setslotflagsasbundle_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setslotflagsasbundle_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/service_setslotflagsasbundle_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/service_setslotflagsasbundle_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..3925e0f52f8efb8069659eb975bd5c1ffced2abd --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetslotflagsasbundle_fuzzer/service_setslotflagsasbundle_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSLOTFLAGSASBUNDLE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSLOTFLAGSASBUNDLE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetslotflagsasbundle_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSLOTFLAGSASBUNDLE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c5c8ecb9036d3ca3939ba80bb01d54e764354d44 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetSmartReminderEnabledFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setsmartreminderenabled_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetSmartReminderEnabledFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/service_setsmartreminderenabled_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/service_setsmartreminderenabled_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..84d14dac41d4f4eddca8e4711685534bc61777a5 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/service_setsmartreminderenabled_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setsmartreminderenabled_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/service_setsmartreminderenabled_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/service_setsmartreminderenabled_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..6264607e9b7cba1540cbe53646be6625c81b70a7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsmartreminderenabled_fuzzer/service_setsmartreminderenabled_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSMARTREMINDERENABLED_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSMARTREMINDERENABLED_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetsmartreminderenabled_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSMARTREMINDERENABLED_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6fa00072c0998e75962156237c77f6f64eeefece --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetSyncNotificationEnabledWithoutAppFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_setsyncnotificationenabledwithoutapp_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetSyncNotificationEnabledWithoutAppFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/service_setsyncnotificationenabledwithoutapp_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/service_setsyncnotificationenabledwithoutapp_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..461f370a08803bbeaf8ffb57099b3460715f0f8b --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/service_setsyncnotificationenabledwithoutapp_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_setsyncnotificationenabledwithoutapp_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/service_setsyncnotificationenabledwithoutapp_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/service_setsyncnotificationenabledwithoutapp_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..9807b345b4db1f8f344f158729f74ab10cc266b5 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesetsyncnotificationenabledwithoutapp_fuzzer/service_setsyncnotificationenabledwithoutapp_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSYNCNOTIFICATIONENABLEDWITHOUTAPP_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSYNCNOTIFICATIONENABLEDWITHOUTAPP_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesetsyncnotificationenabledwithoutapp_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETSYNCNOTIFICATIONENABLEDWITHOUTAPP_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..04bbfc444bf4eedcbd0f147ff752214a618a7771 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSetTargetDeviceStatusFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_settargetdevicestatus_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSetTargetDeviceStatusFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0fdfc728ab6dd22c667ec8b9eeeafa30d32658de --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_settargetdevicestatus_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..4ceabc666b086cba1690af9e858d1fb187fa3745 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesettargetdevicestatus_fuzzer/service_settargetdevicestatus_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETTARGETDEVICESTATUS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETTARGETDEVICESTATUS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesettargetdevicestatus_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SETTARGETDEVICESTATUS_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..a33ad5f995986a7d2d63946bc6814fe30ec3ea17 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceShellDumpFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_shelldump_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceShellDumpFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..02c33df2739e58ed55f88d1830ceec2043efe388 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_shelldump_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..f9e7f9544679c071c7e4e9b5050ddaf0ec866e92 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceshelldump_fuzzer/service_shelldump_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SHELLDUMP_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SHELLDUMP_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceshelldump_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SHELLDUMP_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bf65cdae4f94ae43fd3c60c999bc8de88ebec1b7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSubscribeFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_subscribe_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSubscribeFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/service_subscribe_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/service_subscribe_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..991515ae66b16dccd3827a3a582a01d06012ca89 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/service_subscribe_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_subscribe_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/service_subscribe_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/service_subscribe_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d377576560b4cda1e36165c0c0569c3a023f2f44 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribe_fuzzer/service_subscribe_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SUBSCRIBE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SUBSCRIBE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesubscribe_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SUBSCRIBE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6bb68e6eadc1a99508197bbbd1aeebd4576c79b7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSubscribeLocalLiveViewFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_subscribelocalliveview_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSubscribeLocalLiveViewFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/service_subscribelocalliveview_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/service_subscribelocalliveview_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e6da395d5996db0a2afdb86d826ca424569fb0c8 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/service_subscribelocalliveview_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_subscribelocalliveview_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/service_subscribelocalliveview_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/service_subscribelocalliveview_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..73e3903bfc83f735e784c4afeca005e205955190 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribelocalliveview_fuzzer/service_subscribelocalliveview_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SUBSCRIBELOCALLIVEVIEW_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SUBSCRIBELOCALLIVEVIEW_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesubscribelocalliveview_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SUBSCRIBELOCALLIVEVIEW_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fecde78faf3488637dd2473d3e3789db07741f8c --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceSubscribeSelfFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_subscribeself_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceSubscribeSelfFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/service_subscribeself_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/service_subscribeself_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3b6f9baeeb62eef237972235608ea07814e0018f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/service_subscribeself_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_subscribeself_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/service_subscribeself_fuzzer.h b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/service_subscribeself_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..f6b29a302d7006b2ab04ecdeebf23179fc1cae33 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicesubscribeself_fuzzer/service_subscribeself_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SUBSCRIBESELF_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SUBSCRIBESELF_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicesubscribeself_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_SUBSCRIBESELF_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..49a137a088f4012b5469f3ed4cfd25ebae768969 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceTriggerLocalLiveViewFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_triggerlocalliveview_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceTriggerLocalLiveViewFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/service_triggerlocalliveview_fuzzer.cpp b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/service_triggerlocalliveview_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f2271c6a8ae4548c776d667a72ff53b46bdcb658 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/service_triggerlocalliveview_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_triggerlocalliveview_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/service_triggerlocalliveview_fuzzer.h b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/service_triggerlocalliveview_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..30095113ed16a62db5464a2a7bb52b7d8d73f9ec --- /dev/null +++ b/test/fuzztest/advancednotificationservice/servicetriggerlocalliveview_fuzzer/service_triggerlocalliveview_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_TRIGGERLOCALLIVEVIEW_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_TRIGGERLOCALLIVEVIEW_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationservicetriggerlocalliveview_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_TRIGGERLOCALLIVEVIEW_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..762d860f8571d31372aa15b9f424eeacc2920452 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceUnsubscribeFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_unsubscribe_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceUnsubscribeFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/service_unsubscribe_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/service_unsubscribe_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f9ed56c048d08a661008f20c029004c73431e796 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/service_unsubscribe_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_unsubscribe_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/service_unsubscribe_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/service_unsubscribe_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..d85e77f89da80293ff6ecd89098965661aa801b7 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceunsubscribe_fuzzer/service_unsubscribe_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_UNSUBSCRIBE_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_UNSUBSCRIBE_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceunsubscribe_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_UNSUBSCRIBE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1b855d7c5d23e68b9eee1168d402b01086f98cd3 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceUpdateNotificationTimerByUidFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_updatenotificationtimerbyuid_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceUpdateNotificationTimerByUidFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/service_updatenotificationtimerbyuid_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/service_updatenotificationtimerbyuid_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2658091199567f9aa8949132d3089b0ae85de74f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/service_updatenotificationtimerbyuid_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_updatenotificationtimerbyuid_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/service_updatenotificationtimerbyuid_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/service_updatenotificationtimerbyuid_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..15a2024218206aa1944d8fcab8844220c19e9f5c --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdatenotificationtimerbyuid_fuzzer/service_updatenotificationtimerbyuid_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_UPDATENOTIFICATIONTIMERBYUID_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_UPDATENOTIFICATIONTIMERBYUID_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceupdatenotificationtimerbyuid_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_UPDATENOTIFICATIONTIMERBYUID_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/BUILD.gn b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b56ee9d99d4adc15255ef66c5e85fb1244b0446b --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/BUILD.gn @@ -0,0 +1,152 @@ +# 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("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") + +##############################fuzztest########################################## +ohos_fuzztest("ServiceUpdateSlotsFuzzTest") { + module_out_path = service_fuzz_test_path + fuzz_config_file = + "${component_path}/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer" + include_dirs = [ "${services_path}/ans/include" ] + cflags = [ + "-fno-math-errno", + "-fno-unroll-loops", + "-fmerge-all-constants", + "-fno-ident", + "-Oz", + "-flto", + "-ffunction-sections", + "-fdata-sections", + ] + sources = [ "service_updateslots_fuzzer.cpp" ] + defines = [] + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_mock_object", + "${frameworks_module_ans_path}:ans_innerkits", + "${services_path}/ans:ans_service_sources" + ] + if (is_double_framework) { + cflags += [ "-DCONFIG_DUAL_FRAMEWORK" ] + } + + if (distributed_notification_supported) { + defines += [ "DISTRIBUTED_NOTIFICATION_SUPPORTED" ] + deps += [ "${services_path}/distributed:libans_distributed" ] + include_dirs += [ "${services_path}/distributed/include" ] + } + + if (notification_smart_reminder_supported) { + defines += [ "NOTIFICATION_SMART_REMINDER_SUPPORTED" ] + } + + external_deps = [ + "ability_base:configuration", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:appkit_native", + "ability_runtime:dataobs_manager", + "ability_runtime:extension_manager", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "access_token:libtokenid_sdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "config_policy:configpolicy_util", + "data_share:datashare_common", + "data_share:datashare_consumer", + "data_share:datashare_permission", + "device_manager:devicemanagersdk", + "ffrt:libffrt", + "hilog:libhilog", + "i18n:intl_util", + "image_framework:image_native", + "init:libbegetutil", + "kv_store:distributeddata_inner", + "openssl:libcrypto_shared", + "os_account:os_account_innerkits", + "relational_store:native_rdb", + "resource_management:global_resmgr", + "time_service:time_client", + ] + external_deps += component_external_deps + + if (device_usage) { + external_deps += [ "device_usage_statistics:usagestatsinner" ] + defines += [ "DEVICE_USAGE_STATISTICS_ENABLE" ] + } + + if (hisysevent_usage) { + cflags += [ "-DHAS_HISYSEVENT_PART" ] + external_deps += [ "hisysevent:libhisysevent" ] + } + + if (standby_enable) { + external_deps += [ "device_standby:standby_innerkits" ] + defines += [ "DEVICE_STANDBY_ENABLE" ] + } + + if (player_framework) { + external_deps += [ "player_framework:media_client" ] + defines += [ "PLAYER_FRAMEWORK_ENABLE" ] + } + + if (ans_hitrace_usage) { + external_deps += [ "hitrace:hitrace_meter" ] + defines += [ "HITRACE_METER_ENABLE" ] + } + + if (ans_config_policy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLICY_ENABLE" ] + } + + if (screenlock_mgr_enable) { + external_deps += [ "screenlock_mgr:screenlock_client" ] + defines += [ "SCREENLOCK_MGR_ENABLE" ] + } + + if (distributed_notification_service_feature_additional_control || + distributed_notification_service_feature_privileged_message) { + defines += [ "ENABLE_ANS_EXT_WRAPPER" ] + } + + if (distributed_notification_service_feature_additional_control) { + defines += [ "ENABLE_ANS_ADDITIONAL_CONTROL" ] + } + + if (distributed_notification_service_feature_summary) { + defines += [ "ENABLE_ANS_AGGREGATION" ] + } + + if (telephony_cust) { + defines += [ "ENABLE_ANS_TELEPHONY_CUST_WRAPPER" ] + } + + if (distributed_notification_service_feature_disable_fa_model) { + defines += [ "ANS_DISABLE_FA_MODEL" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":ServiceUpdateSlotsFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/corpus/init b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..d9719cafab50ed61d354cfa865b56390a0df320f --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +FUZZ \ No newline at end of file diff --git a/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/project.xml b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..226522bd2ad3eaf2db4f710f1924d82d2912c235 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 10000 + + 300 + + 4096 + + diff --git a/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/service_updateslots_fuzzer.cpp b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/service_updateslots_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..098266716973c62b3b97b506c865e15b1ba6c6ec --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/service_updateslots_fuzzer.cpp @@ -0,0 +1,38 @@ +/* + * 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 "service_updateslots_fuzzer.h" + +#include +#include "advanced_notification_service.h" +#include "ans_permission_def.h" +#include "mock_notification_request.h" + +namespace OHOS { +namespace Notification { + bool DoSomethingInterestingWithMyAPI(FuzzedDataProvider *fuzzData) + { + return true; + } +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + FuzzedDataProvider fdp(data, size); + OHOS::Notification::DoSomethingInterestingWithMyAPI(&fdp); + return 0; +} diff --git a/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/service_updateslots_fuzzer.h b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/service_updateslots_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..44dca2a47c6b9ba34d99fe9ae32a0a5a8a882117 --- /dev/null +++ b/test/fuzztest/advancednotificationservice/serviceupdateslots_fuzzer/service_updateslots_fuzzer.h @@ -0,0 +1,24 @@ +/* + * 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 TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_UPDATESLOTS_FUZZER_H +#define TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_UPDATESLOTS_FUZZER_H + +#include "fuzz_common_base.h" +#include + +#define FUZZ_PROJECT_NAME "advancednotificationserviceupdateslots_fuzzer" + +#endif // TEST_FUZZTEST_ADVANCEDNOTIFICATIONSERVICE_FUZZER_SERVICE_UPDATESLOTS_FUZZER_H \ No newline at end of file