From b1679af02162ef64bdd09661b5c18de3c86b6439 Mon Sep 17 00:00:00 2001 From: yanhuan Date: Tue, 1 Jul 2025 09:41:40 +0800 Subject: [PATCH 1/4] =?UTF-8?q?dialogsessionmanager=20fuzz=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanhuan --- test/fuzztest/BUILD.gn | 6 + test/fuzztest/ability_fuzz_util.h | 273 ++++++++++++++++++ .../dialogsessionmanager_fuzzer/BUILD.gn | 1 + .../dialogsessionmanagerfifth_fuzzer/BUILD.gn | 102 +++++++ .../corpus/init | 16 + .../dialogsessionmanagerfifth_fuzzer.cpp | 55 ++++ .../dialogsessionmanagerfifth_fuzzer.h | 21 ++ .../project.xml | 25 ++ .../dialogsessionmanagerfirst_fuzzer/BUILD.gn | 102 +++++++ .../corpus/init | 16 + .../dialogsessionmanagerfirst_fuzzer.cpp | 80 +++++ .../dialogsessionmanagerfirst_fuzzer.h | 21 ++ .../project.xml | 25 ++ .../BUILD.gn | 103 +++++++ .../corpus/init | 16 + .../dialogsessionmanagerfourth_fuzzer.cpp | 54 ++++ .../dialogsessionmanagerfourth_fuzzer.h | 21 ++ .../project.xml | 25 ++ .../BUILD.gn | 103 +++++++ .../corpus/init | 16 + .../dialogsessionmanagersecond_fuzzer.cpp | 57 ++++ .../dialogsessionmanagersecond_fuzzer.h | 21 ++ .../project.xml | 25 ++ .../dialogsessionmanagerthird_fuzzer/BUILD.gn | 102 +++++++ .../corpus/init | 16 + .../dialogsessionmanagerthird_fuzzer.cpp | 54 ++++ .../dialogsessionmanagerthird_fuzzer.h | 21 ++ .../project.xml | 25 ++ 28 files changed, 1402 insertions(+) create mode 100644 test/fuzztest/dialogsessionmanagerfifth_fuzzer/BUILD.gn create mode 100644 test/fuzztest/dialogsessionmanagerfifth_fuzzer/corpus/init create mode 100644 test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp create mode 100644 test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.h create mode 100644 test/fuzztest/dialogsessionmanagerfifth_fuzzer/project.xml create mode 100644 test/fuzztest/dialogsessionmanagerfirst_fuzzer/BUILD.gn create mode 100644 test/fuzztest/dialogsessionmanagerfirst_fuzzer/corpus/init create mode 100644 test/fuzztest/dialogsessionmanagerfirst_fuzzer/dialogsessionmanagerfirst_fuzzer.cpp create mode 100644 test/fuzztest/dialogsessionmanagerfirst_fuzzer/dialogsessionmanagerfirst_fuzzer.h create mode 100644 test/fuzztest/dialogsessionmanagerfirst_fuzzer/project.xml create mode 100644 test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn create mode 100644 test/fuzztest/dialogsessionmanagerfourth_fuzzer/corpus/init create mode 100644 test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.cpp create mode 100644 test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.h create mode 100644 test/fuzztest/dialogsessionmanagerfourth_fuzzer/project.xml create mode 100644 test/fuzztest/dialogsessionmanagersecond_fuzzer/BUILD.gn create mode 100644 test/fuzztest/dialogsessionmanagersecond_fuzzer/corpus/init create mode 100644 test/fuzztest/dialogsessionmanagersecond_fuzzer/dialogsessionmanagersecond_fuzzer.cpp create mode 100644 test/fuzztest/dialogsessionmanagersecond_fuzzer/dialogsessionmanagersecond_fuzzer.h create mode 100644 test/fuzztest/dialogsessionmanagersecond_fuzzer/project.xml create mode 100644 test/fuzztest/dialogsessionmanagerthird_fuzzer/BUILD.gn create mode 100644 test/fuzztest/dialogsessionmanagerthird_fuzzer/corpus/init create mode 100644 test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.cpp create mode 100644 test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.h create mode 100644 test/fuzztest/dialogsessionmanagerthird_fuzzer/project.xml diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 006c2d698b0..e00486f4c15 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -312,6 +312,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 c69475acf34..25bcc2afc5f 100644 --- a/test/fuzztest/ability_fuzz_util.h +++ b/test/fuzztest/ability_fuzz_util.h @@ -274,6 +274,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/dialogsessionmanager_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanager_fuzzer/BUILD.gn index 140b43951c3..e08de4620fd 100644 --- a/test/fuzztest/dialogsessionmanager_fuzzer/BUILD.gn +++ b/test/fuzztest/dialogsessionmanager_fuzzer/BUILD.gn @@ -70,6 +70,7 @@ ohos_fuzztest("DialogSessionManagerFuzzTest") { "common_event_service:cesfwk_innerkits", "ffrt:libffrt", "hilog:libhilog", + "hisysevent:libhisysevent", "hitrace:hitrace_meter", "ipc:ipc_core", "libjpeg-turbo:turbojpeg", diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/BUILD.gn new file mode 100644 index 00000000000..50f440f4369 --- /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 00000000000..6198079a28e --- /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 00000000000..5f9b07dc08d --- /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 00000000000..28ba0484885 --- /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 00000000000..47ed3b82d67 --- /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 00000000000..2fec4d5687c --- /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 00000000000..6198079a28e --- /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 00000000000..8b302b2c3d6 --- /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 00000000000..df24110260a --- /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 00000000000..47ed3b82d67 --- /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 00000000000..46394966ce7 --- /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 00000000000..6198079a28e --- /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 00000000000..900a2538bc7 --- /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 00000000000..98ae49645ad --- /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 00000000000..47ed3b82d67 --- /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 00000000000..0801d3b464d --- /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 00000000000..6198079a28e --- /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 00000000000..e3fdfb61673 --- /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 00000000000..60a7ce76e63 --- /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 00000000000..47ed3b82d67 --- /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 00000000000..4b6337959fc --- /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 00000000000..6198079a28e --- /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 00000000000..146672e08db --- /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 00000000000..a8328771d16 --- /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 00000000000..47ed3b82d67 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerthird_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + + \ No newline at end of file -- Gitee From bba9a837755256a3ac9ef9436d25cea4c0da8f36 Mon Sep 17 00:00:00 2001 From: yanhuan Date: Tue, 1 Jul 2025 11:48:56 +0800 Subject: [PATCH 2/4] =?UTF-8?q?dialogsessionmanager=20fuzz=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanhuan --- .../dialogsessionmanager_fuzzer.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/fuzztest/dialogsessionmanager_fuzzer/dialogsessionmanager_fuzzer.cpp b/test/fuzztest/dialogsessionmanager_fuzzer/dialogsessionmanager_fuzzer.cpp index 4ea228b711c..32579b47c24 100644 --- a/test/fuzztest/dialogsessionmanager_fuzzer/dialogsessionmanager_fuzzer.cpp +++ b/test/fuzztest/dialogsessionmanager_fuzzer/dialogsessionmanager_fuzzer.cpp @@ -89,10 +89,20 @@ bool DoSomethingInterestingWithMyAPI(const char *data, size_t size) DialogAbilityInfo callerAbilityInfo; dialogSessionManager->GenerateCallerAbilityInfo(abilityRequest, callerAbilityInfo); dialogSessionManager->GenerateSelectorTargetAbilityInfos(dialogAppInfos, targetAbilityInfos); - dialogSessionManager->GenerateDialogCallerInfo(abilityRequest, int32Param, dialogCallerInfo, isSelector); - dialogSessionManager->NotifySCBToRecoveryAfterInterception(dialogSessionId, abilityRequest); + SelectorType type = SelectorType::WITHOUT_SELECTOR; + dialogSessionManager->GenerateDialogSessionRecordCommon(abilityRequest, int32Param, wantParams, + dialogAppInfos, type, isSelector); + type = SelectorType::IMPLICIT_START_SELECTOR; + dialogSessionManager->GenerateDialogSessionRecordCommon(abilityRequest, int32Param, wantParams, + dialogAppInfos, type, isSelector); + type = SelectorType::APP_CLONE_SELECTOR; dialogSessionManager->GenerateDialogSessionRecordCommon(abilityRequest, int32Param, wantParams, - dialogAppInfos, isSelector); + dialogAppInfos, type, isSelector); + type = SelectorType::INTERCEPTOR_SELECTOR; + dialogSessionManager->GenerateDialogSessionRecordCommon(abilityRequest, int32Param, wantParams, + dialogAppInfos, type, isSelector); + dialogSessionManager->GenerateDialogCallerInfo(abilityRequest, int32Param, dialogCallerInfo, type, isSelector); + dialogSessionManager->NotifySCBToRecoveryAfterInterception(dialogSessionId, abilityRequest); dialogSessionManager->CreateJumpModalDialog(abilityRequest, int32Param, want); dialogSessionManager->CreateImplicitSelectorModalDialog(abilityRequest, want, int32Param, dialogAppInfos); dialogSessionManager->CreateCloneSelectorModalDialog(abilityRequest, want, int32Param, dialogAppInfos, -- Gitee From 47b29c0a1dbc8e87adbd912890c326f0514d2c85 Mon Sep 17 00:00:00 2001 From: yanhuan Date: Tue, 1 Jul 2025 15:04:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?dialogsessionmanager=20fuzz=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanhuan --- test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn | 6 +++++- test/fuzztest/dialogsessionmanagersecond_fuzzer/BUILD.gn | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn index 46394966ce7..6f9eea3245d 100644 --- a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn +++ b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn @@ -36,8 +36,12 @@ ohos_fuzztest("DialogSessionManagerFourthFuzzTest") { "-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/query_erms_manager.cpp", + "${ability_runtime_path}/services/abilitymgr/src/query_erms_observer_manager.cpp", + "${ability_runtime_path}/services/common/src/task_handler_wrap.cpp", + "${ability_runtime_path}/services/common/src/queue_task_handler_wrap.cpp", + "${ability_runtime_path}/services/common/src/ffrt_task_handler_wrap.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/start_ability_utils.cpp", "dialogsessionmanagerfourth_fuzzer.cpp", ] diff --git a/test/fuzztest/dialogsessionmanagersecond_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanagersecond_fuzzer/BUILD.gn index 0801d3b464d..fa51707607f 100644 --- a/test/fuzztest/dialogsessionmanagersecond_fuzzer/BUILD.gn +++ b/test/fuzztest/dialogsessionmanagersecond_fuzzer/BUILD.gn @@ -36,8 +36,12 @@ ohos_fuzztest("DialogSessionManagerSecondFuzzTest") { "-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/query_erms_manager.cpp", + "${ability_runtime_path}/services/abilitymgr/src/query_erms_observer_manager.cpp", + "${ability_runtime_path}/services/common/src/task_handler_wrap.cpp", + "${ability_runtime_path}/services/common/src/queue_task_handler_wrap.cpp", + "${ability_runtime_path}/services/common/src/ffrt_task_handler_wrap.cpp", "${ability_runtime_services_path}/abilitymgr/src/utils/start_ability_utils.cpp", "dialogsessionmanagersecond_fuzzer.cpp", ] -- Gitee From 0dfdad67578161db867077e21165c952e43048d2 Mon Sep 17 00:00:00 2001 From: yanhuan Date: Tue, 1 Jul 2025 17:14:57 +0800 Subject: [PATCH 4/4] =?UTF-8?q?dialogsessionmanager=20fuzz=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yanhuan --- test/fuzztest/ability_fuzz_util.h | 99 +------------------ .../corpus/init | 2 +- .../dialogsessionmanagerfifth_fuzzer.cpp | 2 +- .../dialogsessionmanagerfifth_fuzzer.h | 2 +- .../project.xml | 2 +- .../corpus/init | 2 +- .../dialogsessionmanagerfirst_fuzzer.cpp | 2 +- .../dialogsessionmanagerfirst_fuzzer.h | 2 +- .../project.xml | 2 +- .../corpus/init | 2 +- .../dialogsessionmanagerfourth_fuzzer.cpp | 2 +- .../dialogsessionmanagerfourth_fuzzer.h | 2 +- .../project.xml | 2 +- .../corpus/init | 2 +- .../dialogsessionmanagersecond_fuzzer.cpp | 2 +- .../dialogsessionmanagersecond_fuzzer.h | 2 +- .../project.xml | 2 +- .../corpus/init | 2 +- .../dialogsessionmanagerthird_fuzzer.cpp | 2 +- .../dialogsessionmanagerthird_fuzzer.h | 2 +- .../project.xml | 2 +- 21 files changed, 21 insertions(+), 118 deletions(-) diff --git a/test/fuzztest/ability_fuzz_util.h b/test/fuzztest/ability_fuzz_util.h index 25bcc2afc5f..862ee6f3488 100644 --- a/test/fuzztest/ability_fuzz_util.h +++ b/test/fuzztest/ability_fuzz_util.h @@ -274,6 +274,7 @@ 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)); @@ -416,104 +417,6 @@ void GetRandomStartWindowResourceInfo(FuzzedDataProvider& fdp, StartWindowResour 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(); diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/corpus/init b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/corpus/init index 6198079a28e..7ade8a0faaf 100644 --- a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/corpus/init +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/corpus/init @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp index 5f9b07dc08d..8537246bbf1 100644 --- a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.h b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.h index 28ba0484885..7d08cba4d86 100644 --- a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.h +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024 Huawei Device Co., Ltd. + * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/project.xml b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/project.xml index 47ed3b82d67..e72711e004d 100644 --- a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/project.xml +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/project.xml @@ -1,5 +1,5 @@ -