diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 04ea19424bb36da9b0ae092b06be9badb2e04a4d..e5a90d58d84abfac38efb314f70858a101a69f73 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -306,6 +306,12 @@ group("fuzztest") { "deeplinkreserveconfig_fuzzer:fuzztest", "delegatordoabilityforeground_fuzzer:fuzztest", "dialogsessioninfo_fuzzer:fuzztest", + "dialogsessionmanager_fuzzer:fuzztest", + "dialogsessionmanagerfirst_fuzzer:fuzztest", + "dialogsessionmanagersecond_fuzzer:fuzztest", + "dialogsessionmanagerthird_fuzzer:fuzztest", + "dialogsessionmanagerfourth_fuzzer:fuzztest", + "dialogsessionmanagerfifth_fuzzer:fuzztest", "disposedobserver_fuzzer:fuzztest", "doabilitybackground_fuzzer:fuzztest", "doabilityforeground_fuzzer:fuzztest", diff --git a/test/fuzztest/ability_fuzz_util.h b/test/fuzztest/ability_fuzz_util.h index 07a226cddc76b7f849a950795686a8d26839caf1..4e1eb877acc2e49eca25fb8c42bdb6a1e330fa12 100644 --- a/test/fuzztest/ability_fuzz_util.h +++ b/test/fuzztest/ability_fuzz_util.h @@ -218,6 +218,279 @@ void GetRandomKeepAliveAppInfo(FuzzedDataProvider& fdp, AppInfo& info) info.instanceKey = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); info.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); } + +void GetRandomAppqfInfo(FuzzedDataProvider& fdp, AppqfInfo& deployedAppqfInfo) +{ + deployedAppqfInfo.type = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + deployedAppqfInfo.versionCode = fdp.ConsumeIntegral(); + deployedAppqfInfo.versionName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + deployedAppqfInfo.cpuAbi = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + deployedAppqfInfo.nativeLibraryPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + std::vector hqfInfos; +} + +void GetRandomDeployingAppqfInfo(FuzzedDataProvider& fdp, AppqfInfo& deployingAppqfInfo) +{ + deployingAppqfInfo.type = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + deployingAppqfInfo.versionCode = fdp.ConsumeIntegral(); + deployingAppqfInfo.versionName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + deployingAppqfInfo.cpuAbi = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + deployingAppqfInfo.nativeLibraryPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + std::vector hqfInfos; +} + +void GetRandomAppQuickFix(FuzzedDataProvider& fdp, AppQuickFix& appQuickFix) +{ + appQuickFix.versionCode = fdp.ConsumeIntegral(); + appQuickFix.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appQuickFix.versionName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + GetRandomAppqfInfo(fdp, appQuickFix.deployedAppqfInfo); + GetRandomDeployingAppqfInfo(fdp, appQuickFix.deployingAppqfInfo); +} + +void GetRandomResourceInfo(FuzzedDataProvider& fdp, Resource& labelResource) +{ + labelResource.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + labelResource.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + labelResource.id = fdp.ConsumeIntegral(); +} + +void GetRandomApplicationInfo(FuzzedDataProvider& fdp, ApplicationInfo& appInfo) +{ + appInfo.name = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.versionCode = fdp.ConsumeIntegral(); + appInfo.versionName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.minCompatibleVersionCode = fdp.ConsumeIntegral(); + appInfo.apiCompatibleVersion = fdp.ConsumeIntegral(); + appInfo.apiTargetVersion = fdp.ConsumeIntegral(); + appInfo.crowdtestDeadline = fdp.ConsumeIntegral(); + appInfo.iconPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.iconId = fdp.ConsumeIntegral(); + GetRandomResourceInfo(fdp, appInfo.labelResource); + appInfo.label = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.labelId = fdp.ConsumeIntegral(); + GetRandomResourceInfo(fdp, appInfo.labelResource); + appInfo.description = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.descriptionId = fdp.ConsumeIntegral(); + GetRandomResourceInfo(fdp, appInfo.labelResource); + appInfo.keepAlive = fdp.ConsumeBool(); + appInfo.removable = fdp.ConsumeBool(); + appInfo.singleton = fdp.ConsumeBool(); + appInfo.userDataClearable = fdp.ConsumeBool(); + appInfo.allowAppRunWhenDeviceFirstLocked = fdp.ConsumeBool(); + appInfo.accessible = fdp.ConsumeBool(); + appInfo.runningResourcesApply = fdp.ConsumeBool(); + appInfo.associatedWakeUp = fdp.ConsumeBool(); + appInfo.hideDesktopIcon = fdp.ConsumeBool(); + appInfo.formVisibleNotify = fdp.ConsumeBool(); + appInfo.installedForAllUser = fdp.ConsumeBool(); + appInfo.allowEnableNotification = fdp.ConsumeBool(); + appInfo.allowMultiProcess = fdp.ConsumeBool(); + appInfo.gwpAsanEnabled = fdp.ConsumeBool(); + appInfo.hasPlugin = fdp.ConsumeBool(); + appInfo.allowCommonEvent = GenerateStringArray(fdp); + appInfo.assetAccessGroups = GenerateStringArray(fdp); + appInfo.isSystemApp = fdp.ConsumeBool(); + appInfo.isLauncherApp = fdp.ConsumeBool(); + appInfo.isFreeInstallApp = fdp.ConsumeBool(); + appInfo.asanEnabled = fdp.ConsumeBool(); + appInfo.asanLogPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.codePath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.dataDir = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.dataBaseDir = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.cacheDir = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.entryDir = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.apiReleaseType = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.debug = fdp.ConsumeBool(); + appInfo.deviceId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.distributedNotificationEnabled = fdp.ConsumeBool(); + appInfo.entityType = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.process = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.supportedModes = fdp.ConsumeIntegral(); + appInfo.vendor = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.appPrivilegeLevel = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.appDistributionType = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.appProvisionType = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.accessTokenId = fdp.ConsumeIntegral(); + appInfo.applicationReservedFlag = fdp.ConsumeIntegral(); + appInfo.accessTokenIdEx = fdp.ConsumeIntegral(); + appInfo.enabled = fdp.ConsumeBool(); + appInfo.appIndex = fdp.ConsumeIntegral(); + appInfo.uid = fdp.ConsumeIntegral(); + appInfo.maxChildProcess = fdp.ConsumeIntegral(); + appInfo.nativeLibraryPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.cpuAbi = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.arkNativeFilePath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.arkNativeFileAbi = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.permissions = GenerateStringArray(fdp); + appInfo.moduleSourceDirs = GenerateStringArray(fdp); + appInfo.targetBundleList = GenerateStringArray(fdp); + appInfo.fingerprint = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + GetRandomAppQuickFix(fdp, appInfo.appQuickFix); + appInfo.icon = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.flags = fdp.ConsumeIntegral(); + appInfo.entryModuleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.isCompressNativeLibs = fdp.ConsumeBool(); + appInfo.signatureKey = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.multiProjects = fdp.ConsumeBool(); + appInfo.tsanEnabled = fdp.ConsumeBool(); + appInfo.hwasanEnabled = fdp.ConsumeBool(); + appInfo.ubsanEnabled = fdp.ConsumeBool(); + appInfo.cloudFileSyncEnabled = fdp.ConsumeBool(); + appInfo.needAppDetail = fdp.ConsumeBool(); + appInfo.appDetailAbilityLibraryPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.targetBundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.targetPriority = fdp.ConsumeIntegral(); + appInfo.overlayState = fdp.ConsumeIntegral(); + appInfo.bundleType = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + appInfo.compileSdkVersion = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.compileSdkType = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.organization = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.installSource = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + appInfo.configuration = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); +} + +void GetRandomStartWindowResourceInfo(FuzzedDataProvider& fdp, StartWindowResource& startWindowResource) +{ + startWindowResource.startWindowAppIconId = fdp.ConsumeIntegral(); + startWindowResource.startWindowIllustrationId = fdp.ConsumeIntegral(); + startWindowResource.startWindowBrandingImageId = fdp.ConsumeIntegral(); + startWindowResource.startWindowBackgroundColorId = fdp.ConsumeIntegral(); + startWindowResource.startWindowBackgroundImageId = fdp.ConsumeIntegral(); + startWindowResource.startWindowBackgroundImageFit = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); +} + +void GetRandomAbilityInfo(FuzzedDataProvider& fdp, AbilityInfo& abilityInfo) +{ + abilityInfo.name = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.label = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.description = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.iconPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.labelId = fdp.ConsumeIntegral(); + abilityInfo.descriptionId = fdp.ConsumeIntegral(); + abilityInfo.iconId = fdp.ConsumeIntegral(); + abilityInfo.theme = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.visible = fdp.ConsumeBool(); + abilityInfo.kind = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.type = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + abilityInfo.extensionAbilityType = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + abilityInfo.orientation = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + abilityInfo.launchMode = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + abilityInfo.srcPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.srcLanguage = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.permissions = GenerateStringArray(fdp); + abilityInfo.process = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.deviceTypes = GenerateStringArray(fdp); + abilityInfo.deviceCapabilities = GenerateStringArray(fdp); + abilityInfo.uri = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.targetAbility = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.isLauncherAbility = fdp.ConsumeBool(); + abilityInfo.isNativeAbility = fdp.ConsumeBool(); + abilityInfo.enabled = fdp.ConsumeBool(); + abilityInfo.supportPipMode = fdp.ConsumeBool(); + abilityInfo.formEnabled = fdp.ConsumeBool(); + abilityInfo.removeMissionAfterTerminate = fdp.ConsumeBool(); + abilityInfo.readPermission = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.writePermission = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.configChanges = GenerateStringArray(fdp); + abilityInfo.formEntity = fdp.ConsumeIntegral(); + abilityInfo.minFormHeight = fdp.ConsumeIntegral(); + abilityInfo.defaultFormHeight = fdp.ConsumeIntegral(); + abilityInfo.minFormWidth = fdp.ConsumeIntegral(); + abilityInfo.defaultFormWidth = fdp.ConsumeIntegral(); + abilityInfo.backgroundModes = fdp.ConsumeIntegral(); + abilityInfo.package = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.applicationName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.codePath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.resourcePath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.hapPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.srcEntrance = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.isModuleJson = fdp.ConsumeBool(); + abilityInfo.isStageBasedModel = fdp.ConsumeBool(); + abilityInfo.continuable = fdp.ConsumeBool(); + abilityInfo.priority = fdp.ConsumeIntegral(); + abilityInfo.startWindow = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.startWindowIcon = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.startWindowIconId = fdp.ConsumeIntegral(); + abilityInfo.startWindowBackground = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.startWindowBackgroundId = fdp.ConsumeIntegral(); + abilityInfo.preferMultiWindowOrientation = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.excludeFromMissions = fdp.ConsumeBool(); + abilityInfo.unclearableMission = fdp.ConsumeBool(); + abilityInfo.excludeFromDock = fdp.ConsumeBool(); + abilityInfo.recoverable = fdp.ConsumeBool(); + abilityInfo.isolationProcess = fdp.ConsumeBool(); + abilityInfo.linkType = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + abilityInfo.orientationId = fdp.ConsumeIntegral(); + abilityInfo.startWindowId = fdp.ConsumeIntegral(); + abilityInfo.appIndex = fdp.ConsumeIntegral(); + abilityInfo.continueType = GenerateStringArray(fdp); + abilityInfo.maxWindowRatio = fdp.ConsumeIntegral(); + abilityInfo.minWindowRatio = fdp.ConsumeIntegral(); + abilityInfo.maxWindowWidth = fdp.ConsumeIntegral(); + abilityInfo.minWindowWidth = fdp.ConsumeIntegral(); + abilityInfo.maxWindowHeight = fdp.ConsumeIntegral(); + abilityInfo.minWindowHeight = fdp.ConsumeIntegral(); + GetRandomStartWindowResourceInfo(fdp, abilityInfo.startWindowResource); + abilityInfo.compileMode = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + abilityInfo.originalBundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.appName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.privacyUrl = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.privacyName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.downloadUrl = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.versionName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.className = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.originalClassName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.uriPermissionMode = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.uriPermissionPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.packageSize = fdp.ConsumeIntegral(); + abilityInfo.multiUserShared = fdp.ConsumeBool(); + abilityInfo.grantPermission = fdp.ConsumeBool(); + abilityInfo.directLaunch = fdp.ConsumeBool(); + abilityInfo.subType = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + abilityInfo.libPath = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.deviceId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + abilityInfo.installTime = fdp.ConsumeIntegral(); + abilityInfo.supportExtNames = GenerateStringArray(fdp); + abilityInfo.supportMimeTypes = GenerateStringArray(fdp); +} + +void GetRandomAbilityRequestInfo(FuzzedDataProvider& fdp, AbilityRequest& info) +{ + info.restart = fdp.ConsumeBool(); + info.startRecent = fdp.ConsumeBool(); + info.uriReservedFlag = fdp.ConsumeBool(); + info.isFromIcon = fdp.ConsumeBool(); + info.isShellCall = fdp.ConsumeBool(); + info.isQueryERMS = fdp.ConsumeBool(); + info.isEmbeddedAllowed = fdp.ConsumeBool(); + info.callSpecifiedFlagTimeout = fdp.ConsumeBool(); + info.hideStartWindow = fdp.ConsumeBool(); + info.restartCount = fdp.ConsumeIntegral(); + info.uid = fdp.ConsumeIntegral(); + info.collaboratorType = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + info.callerTokenRecordId = fdp.ConsumeIntegral(); + info.userId = fdp.ConsumeIntegral(); + info.callerAccessTokenId = fdp.ConsumeIntegral(); + info.specifyTokenId = fdp.ConsumeIntegral(); + info.callerUid = fdp.ConsumeIntegral(); + info.requestCode = fdp.ConsumeIntegral(); + info.callType = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + info.restartTime = fdp.ConsumeIntegral(); + info.extensionType = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + info.extensionProcessMode = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + info.specifiedFlag = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.customProcess = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.reservedBundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.appId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.startTime = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + Want want; + GetRandomAbilityInfo(fdp, info.abilityInfo); + GetRandomApplicationInfo(fdp, info.appInfo); +} } // namespace AbilityFuzzUtil } // namespace AppExecFwk } // namespace OHOS diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..50f440f4369dcf47ca2a83b494ef4e5ae788efcf --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/BUILD.gn @@ -0,0 +1,102 @@ +# Copyright (c) 2024-2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("DialogSessionManagerFifthFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/dialogsessionmanagerfifth_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_path}/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/start_ability_utils.cpp", + "dialogsessionmanagerfifth_fuzzer.cpp", + ] + + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:app_util", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "libjpeg-turbo:turbojpeg", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libmodal_system_ui_extension_client", + "window_manager:libwsutils", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":DialogSessionManagerFifthFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/corpus/init b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..6198079a28e860189d4294f6598f8ac6804c0dff --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5f9b07dc08dbd923e8628de6d30f0ec271580ca2 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dialogsessionmanagerfifth_fuzzer.h" +#include +#include +#include +#define private public +#include "dialog_session_manager.h" +#undef private +#include "ability_record.h" +#include "dialog_session_manager.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace {} // namespace + +bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) +{ + sptr dilogSessionInfo; + std::shared_ptr dialogCallerInfo; + std::string dialogSessionId; + FuzzedDataProvider fdp(data, size); + dialogSessionId = fdp.ConsumeRandomLengthString(); + std::shared_ptr dialogSessionManager = std::make_shared(); + if (dialogSessionManager == nullptr) { + return false; + } + dialogSessionManager->SetDialogSessionInfo(dialogSessionId, dilogSessionInfo, dialogCallerInfo); + return true; +} +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.h b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..28ba0484885ec25e70edc7ef9b55d014bbdbe2a6 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_FIFTH_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_FIFTH_FUZZER_H + +#define FUZZ_PROJECT_NAME "dialogsessionmanagerfifth_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/project.xml b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..47ed3b82d67452f92b45b5c0a91f595fcfcc69e4 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfirst_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2fec4d5687c08418b133249217a563b493d12c93 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/BUILD.gn @@ -0,0 +1,102 @@ +# Copyright (c) 2024-2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("DialogSessionManagerFirstFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/dialogsessionmanagerfirst_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_path}/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/start_ability_utils.cpp", + "dialogsessionmanagerfirst_fuzzer.cpp", + ] + + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:app_util", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "libjpeg-turbo:turbojpeg", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libmodal_system_ui_extension_client", + "window_manager:libwsutils", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":DialogSessionManagerFirstFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/dialogsessionmanagerfirst_fuzzer/corpus/init b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..6198079a28e860189d4294f6598f8ac6804c0dff --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfirst_fuzzer/dialogsessionmanagerfirst_fuzzer.cpp b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/dialogsessionmanagerfirst_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8b302b2c3d6b717ae42c960cbd3e8686f123764a --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/dialogsessionmanagerfirst_fuzzer.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dialogsessionmanagerfirst_fuzzer.h" +#include +#include +#include +#define private public +#include "dialog_session_manager.h" +#undef private +#include "ability_record.h" +#include "dialog_session_manager.h" +#include "../ability_fuzz_util.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { + constexpr size_t CODE_TWO = 2; +} // namespace + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) +{ + AbilityRequest info; + SelectorType type; + sptr callerToken = GetFuzzAbilityToken(); + std::string dialogSessionId; + FuzzedDataProvider fdp(data, size); + bool isSCBCall = fdp.ConsumeBool(); + int32_t userId = fdp.ConsumeIntegral(); + dialogSessionId = fdp.ConsumeRandomLengthString(); + bool needGrantUriPermission = fdp.ConsumeBool(); + type = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + AbilityFuzzUtil::GetRandomAbilityRequestInfo(fdp, info); + std::shared_ptr dialogSessionManager = std::make_shared(); + if (dialogSessionManager == nullptr) { + return false; + } + dialogSessionManager->SetQueryERMSInfo(dialogSessionId, info); + dialogSessionManager->UpdateExtensionWantWithDialogCallerInfo(info, callerToken, isSCBCall); + dialogSessionManager->OnlySetDialogCallerInfo(info, userId, type, dialogSessionId, needGrantUriPermission); + return true; +} +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfirst_fuzzer/dialogsessionmanagerfirst_fuzzer.h b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/dialogsessionmanagerfirst_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..df24110260af07370b742ce5bb0c968fef715b99 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/dialogsessionmanagerfirst_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_FIRST_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_FIRST_FUZZER_H + +#define FUZZ_PROJECT_NAME "dialogsessionmanagerfirst_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfirst_fuzzer/project.xml b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..47ed3b82d67452f92b45b5c0a91f595fcfcc69e4 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfirst_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..46394966ce7622d5a84cec7eb503a4afbdd177ab --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn @@ -0,0 +1,103 @@ +# Copyright (c) 2024-2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("DialogSessionManagerFourthFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/dialogsessionmanagerfourth_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_services_path}/abilitymgr/src/query_erms_manager.cpp", + "${ability_runtime_path}/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/start_ability_utils.cpp", + "dialogsessionmanagerfourth_fuzzer.cpp", + ] + + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:app_util", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "libjpeg-turbo:turbojpeg", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libmodal_system_ui_extension_client", + "window_manager:libwsutils", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":DialogSessionManagerFourthFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/corpus/init b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..6198079a28e860189d4294f6598f8ac6804c0dff --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.cpp b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..900a2538bc7a6f29ae45f0d2bba21bc55c6072b0 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dialogsessionmanagerfourth_fuzzer.h" +#include +#include +#include +#define private public +#include "dialog_session_manager.h" +#undef private + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace {} // namespace + +bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) +{ + std::string dialogSessionId; + FuzzedDataProvider fdp(data, size); + dialogSessionId = fdp.ConsumeRandomLengthString(); + bool isAllowed = fdp.ConsumeBool(); + Want want; + std::shared_ptr dialogSessionManager = std::make_shared(); + if (dialogSessionManager == nullptr) { + return false; + } + dialogSessionManager->NotifyAbilityRequestFailure(dialogSessionId, want); + dialogSessionManager->SendDialogResult(want, dialogSessionId, isAllowed); + return true; +} +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.h b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..98ae49645ad2ec193e13289c786398f51d003867 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_FOURTH_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_FOURTH_FUZZER_H + +#define FUZZ_PROJECT_NAME "dialogsessionmanagerfourth_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/project.xml b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..47ed3b82d67452f92b45b5c0a91f595fcfcc69e4 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagersecond_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanagersecond_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0801d3b464d99812f57a86009847b5197ebcf244 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagersecond_fuzzer/BUILD.gn @@ -0,0 +1,103 @@ +# Copyright (c) 2024-2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("DialogSessionManagerSecondFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/dialogsessionmanagersecond_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_services_path}/abilitymgr/src/query_erms_manager.cpp", + "${ability_runtime_path}/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/start_ability_utils.cpp", + "dialogsessionmanagersecond_fuzzer.cpp", + ] + + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:app_util", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "libjpeg-turbo:turbojpeg", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libmodal_system_ui_extension_client", + "window_manager:libwsutils", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":DialogSessionManagerSecondFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/dialogsessionmanagersecond_fuzzer/corpus/init b/test/fuzztest/dialogsessionmanagersecond_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..6198079a28e860189d4294f6598f8ac6804c0dff --- /dev/null +++ b/test/fuzztest/dialogsessionmanagersecond_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagersecond_fuzzer/dialogsessionmanagersecond_fuzzer.cpp b/test/fuzztest/dialogsessionmanagersecond_fuzzer/dialogsessionmanagersecond_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e3fdfb61673fe6d920340afa0aa468529c380a7b --- /dev/null +++ b/test/fuzztest/dialogsessionmanagersecond_fuzzer/dialogsessionmanagersecond_fuzzer.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dialogsessionmanagersecond_fuzzer.h" +#include +#include +#include +#define private public +#include "dialog_session_manager.h" +#undef private + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace {} // namespace + +bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) +{ + std::string dialogSessionId; + FuzzedDataProvider fdp(data, size); + dialogSessionId = fdp.ConsumeRandomLengthString(); + bool isAllowed = fdp.ConsumeBool(); + std::shared_ptr dialogSessionManager = std::make_shared(); + if (dialogSessionManager == nullptr) { + return false; + } + dialogSessionManager->NotifyQueryERMSFinished(dialogSessionId, isAllowed); + dialogSessionManager->GetDialogSessionInfo(dialogSessionId); + dialogSessionManager->GetDialogCallerInfo(dialogSessionId); + dialogSessionManager->GetStartupSessionInfo(dialogSessionId); + dialogSessionManager->ClearDialogContext(dialogSessionId); + dialogSessionManager->ClearAllDialogContexts(); + return true; +} +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagersecond_fuzzer/dialogsessionmanagersecond_fuzzer.h b/test/fuzztest/dialogsessionmanagersecond_fuzzer/dialogsessionmanagersecond_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..60a7ce76e6358028b7738c8ad2b59a5e082383bf --- /dev/null +++ b/test/fuzztest/dialogsessionmanagersecond_fuzzer/dialogsessionmanagersecond_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_SECOND_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_SECOND_FUZZER_H + +#define FUZZ_PROJECT_NAME "dialogsessionmanagersecond_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagersecond_fuzzer/project.xml b/test/fuzztest/dialogsessionmanagersecond_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..47ed3b82d67452f92b45b5c0a91f595fcfcc69e4 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagersecond_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + + \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerthird_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanagerthird_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4b6337959fcd1039208d2ebeeea4a8b5a295c722 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerthird_fuzzer/BUILD.gn @@ -0,0 +1,102 @@ +# Copyright (c) 2024-2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("DialogSessionManagerThirdFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/dialogsessionmanagerthird_fuzzer" + include_dirs = [ + "${ability_runtime_innerkits_path}/ability_manager/include", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include", + ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_path}/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp", + "${ability_runtime_services_path}/abilitymgr/src/utils/start_ability_utils.cpp", + "dialogsessionmanagerthird_fuzzer.cpp", + ] + + configs = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:app_util", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "ipc:ipc_core", + "libjpeg-turbo:turbojpeg", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + "window_manager:libmodal_system_ui_extension_client", + "window_manager:libwsutils", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } + + if (ability_runtime_graphics) { + external_deps += [ "window_manager:libwm" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":DialogSessionManagerThirdFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/dialogsessionmanagerthird_fuzzer/corpus/init b/test/fuzztest/dialogsessionmanagerthird_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..6198079a28e860189d4294f6598f8ac6804c0dff --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerthird_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.cpp b/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..146672e08db67e671ee37ae72da442eb9086e5e0 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dialogsessionmanagerthird_fuzzer.h" +#include +#include +#include +#define private public +#include "dialog_session_manager.h" +#undef private +#include "ability_record.h" +#include "../ability_fuzz_util.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace {} // namespace + +bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) +{ + AbilityRequest info; + std::vector targetAbilityInfos; + FuzzedDataProvider fdp(data, size); + AbilityFuzzUtil::GetRandomAbilityRequestInfo(fdp, info); + std::shared_ptr dialogSessionManager = std::make_shared(); + if (dialogSessionManager == nullptr) { + return false; + } + dialogSessionManager->GenerateJumpTargetAbilityInfos(info, targetAbilityInfos); + return true; +} +} // namespace OHOS + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + /* Run your code on data */ + + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.h b/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..a8328771d16e0940d6aec61473ddae08d2c4a013 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_THIRD_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGER_THIRD_FUZZER_H + +#define FUZZ_PROJECT_NAME "dialogsessionmanagerthird_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/dialogsessionmanagerthird_fuzzer/project.xml b/test/fuzztest/dialogsessionmanagerthird_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..47ed3b82d67452f92b45b5c0a91f595fcfcc69e4 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerthird_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + + \ No newline at end of file