From e913be5be7999e03d35ee89d18c50a64e1b54018 Mon Sep 17 00:00:00 2001 From: yanhuan Date: Mon, 30 Jun 2025 11:34:24 +0800 Subject: [PATCH 1/3] =?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 | 12 +- test/fuzztest/ability_fuzz_util.h | 300 ++++++++++++++++++ .../dialogsessionmanagerfifth_fuzzer/BUILD.gn | 102 ++++++ .../corpus/init | 16 + .../dialogsessionmanagerfifth_fuzzer.cpp | 57 ++++ .../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 | 102 ++++++ .../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 ++ 27 files changed, 1429 insertions(+), 6 deletions(-) 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 04ea19424bb..73a70d91b48 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -194,7 +194,6 @@ group("fuzztest") { "abilitystubluckmissiondone_fuzzer:fuzztest", "abilitystubmaximizemultiwindowdone_fuzzer:fuzztest", "abilitystubminimizeability_fuzzer:fuzztest", - "abilitystubminimizeabilitydone_fuzzer:fuzztest", "abilitystubminimizemultiwindowdone_fuzzer:fuzztest", "abilitystubminimizeuiabilitybyscb_fuzzer:fuzztest", "abilitystubminimizeuiextensionability_fuzzer:fuzztest", @@ -236,7 +235,6 @@ group("fuzztest") { "abilitystubsetmissioninfodone_fuzzer:fuzztest", "abilitystubsetmissionlabel_fuzzer:fuzztest", "abilitystubsetrootscenesession_fuzzer:fuzztest", - "abilitystubsetsessionlockedstate_fuzzer:fuzztest", "abilitystubsetsessionmanagerservice_fuzzer:fuzztest", "abilitystubsharedatadone_fuzzer:fuzztest", "abilitystubstartability_fuzzer:fuzztest", @@ -260,7 +258,6 @@ group("fuzztest") { "abilitystubstopuser_fuzzer:fuzztest", "abilitystubterminateability_fuzzer:fuzztest", "abilitystubterminateuiextensionability_fuzzer:fuzztest", - "abilitystubtomoveabilitytobackground_fuzzer:fuzztest", "abilitystubuninstallapp_fuzzer:fuzztest", "abilitystubunlockmissionforcleanup_fuzzer:fuzztest", "abilitystubunluckmissiondone_fuzzer:fuzztest", @@ -306,6 +303,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", @@ -330,8 +333,6 @@ group("fuzztest") { "getwantsender_fuzzer:fuzztest", "handledlpapp_fuzzer:fuzztest", "insightintentexecutecallbackstub_fuzzer:fuzztest", - "insightintentexecutemanagerfirst_fuzzer:fuzztest", - "insightintentexecutemanagersecond_fuzzer:fuzztest", "insightintentexecuteparamfirst_fuzzer:fuzztest", "insightintentexecuteparamfourth_fuzzer:fuzztest", "insightintentexecuteparamsecond_fuzzer:fuzztest", @@ -427,7 +428,6 @@ group("fuzztest") { "startsyncremotemissions_fuzzer:fuzztest", "startuser_fuzzer:fuzztest", "startusertestprocess_fuzzer:fuzztest", - "statusbardelegatemanagerfirst_fuzzer:fuzztest", "stopserviceability_fuzzer:fuzztest", "stopserviceextensionability_fuzzer:fuzztest", "stopsyncremotemissions_fuzzer:fuzztest", diff --git a/test/fuzztest/ability_fuzz_util.h b/test/fuzztest/ability_fuzz_util.h index 07a226cddc7..88ccc0a0bd4 100644 --- a/test/fuzztest/ability_fuzz_util.h +++ b/test/fuzztest/ability_fuzz_util.h @@ -26,6 +26,8 @@ #include "bundle_user_info.h" #include "extract_insight_intent_profile.h" #include "keep_alive_process_manager.h" +#include "want.h" +#include "want_params_wrapper.h" namespace OHOS { namespace AppExecFwk { @@ -218,6 +220,304 @@ 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); +} + +void GetRandomDialogAbilityInfo(FuzzedDataProvider& fdp, DialogAbilityInfo& targetAbilityInfos) +{ + targetAbilityInfos.visible = fdp.ConsumeBool(); + targetAbilityInfos.bundleIconId = fdp.ConsumeIntegral(); + targetAbilityInfos.bundleLabelId = fdp.ConsumeIntegral(); + targetAbilityInfos.abilityIconId = fdp.ConsumeIntegral(); + targetAbilityInfos.abilityLabelId = fdp.ConsumeIntegral(); + targetAbilityInfos.appIndex = fdp.ConsumeIntegral(); + targetAbilityInfos.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + targetAbilityInfos.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + targetAbilityInfos.abilityName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); +} + +void GetRandomDialogCallerInfo(FuzzedDataProvider& fdp, DialogCallerInfo& dialogCallerInfo) +{ + dialogCallerInfo.userId = fdp.ConsumeIntegral(); + dialogCallerInfo.requestCode = fdp.ConsumeIntegral(); + sptr callerToken; + Want targetWant; + dialogCallerInfo.type = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); + // SelectorType type = SelectorType::WITHOUT_SELECTOR; + dialogCallerInfo.needGrantUriPermission = fdp.ConsumeBool(); +} + } // 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 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..e9d8bb0366c --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_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 "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 {} // namespace + +bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) +{ + DialogSessionInfo dilogSessionInfo; + DialogCallerInfo callerInfo; + std::string dialogSessionId; + FuzzedDataProvider fdp(data, size); + dialogSessionId = fdp.ConsumeRandomLengthString(); + AbilityFuzzUtil::GetRandomDialogCallerInfo(fdp, callerInfo); + std::shared_ptr dialogSessionManager = std::make_shared(); + if (dialogSessionManager == nullptr) { + return false; + } + dialogSessionManager->SetDialogSessionInfo(dialogSessionId, dilogSessionInfo, callerInfo); + 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..7ee0c163e18 --- /dev/null +++ b/test/fuzztest/dialogsessionmanagerfourth_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("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_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..3e47a596030 --- /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 "dialogsessionmanagerthird_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..b9027bff6f5 --- /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; + DialogAbilityInfo 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 2c0ea25727edfa42a7ace554b0fbc81b25d8038d Mon Sep 17 00:00:00 2001 From: yanhuan Date: Mon, 30 Jun 2025 17:47:40 +0800 Subject: [PATCH 2/3] =?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 | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 73a70d91b48..e5a90d58d84 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -194,6 +194,7 @@ group("fuzztest") { "abilitystubluckmissiondone_fuzzer:fuzztest", "abilitystubmaximizemultiwindowdone_fuzzer:fuzztest", "abilitystubminimizeability_fuzzer:fuzztest", + "abilitystubminimizeabilitydone_fuzzer:fuzztest", "abilitystubminimizemultiwindowdone_fuzzer:fuzztest", "abilitystubminimizeuiabilitybyscb_fuzzer:fuzztest", "abilitystubminimizeuiextensionability_fuzzer:fuzztest", @@ -235,6 +236,7 @@ group("fuzztest") { "abilitystubsetmissioninfodone_fuzzer:fuzztest", "abilitystubsetmissionlabel_fuzzer:fuzztest", "abilitystubsetrootscenesession_fuzzer:fuzztest", + "abilitystubsetsessionlockedstate_fuzzer:fuzztest", "abilitystubsetsessionmanagerservice_fuzzer:fuzztest", "abilitystubsharedatadone_fuzzer:fuzztest", "abilitystubstartability_fuzzer:fuzztest", @@ -258,6 +260,7 @@ group("fuzztest") { "abilitystubstopuser_fuzzer:fuzztest", "abilitystubterminateability_fuzzer:fuzztest", "abilitystubterminateuiextensionability_fuzzer:fuzztest", + "abilitystubtomoveabilitytobackground_fuzzer:fuzztest", "abilitystubuninstallapp_fuzzer:fuzztest", "abilitystubunlockmissionforcleanup_fuzzer:fuzztest", "abilitystubunluckmissiondone_fuzzer:fuzztest", @@ -333,6 +336,8 @@ group("fuzztest") { "getwantsender_fuzzer:fuzztest", "handledlpapp_fuzzer:fuzztest", "insightintentexecutecallbackstub_fuzzer:fuzztest", + "insightintentexecutemanagerfirst_fuzzer:fuzztest", + "insightintentexecutemanagersecond_fuzzer:fuzztest", "insightintentexecuteparamfirst_fuzzer:fuzztest", "insightintentexecuteparamfourth_fuzzer:fuzztest", "insightintentexecuteparamsecond_fuzzer:fuzztest", @@ -428,6 +433,7 @@ group("fuzztest") { "startsyncremotemissions_fuzzer:fuzztest", "startuser_fuzzer:fuzztest", "startusertestprocess_fuzzer:fuzztest", + "statusbardelegatemanagerfirst_fuzzer:fuzztest", "stopserviceability_fuzzer:fuzztest", "stopserviceextensionability_fuzzer:fuzztest", "stopsyncremotemissions_fuzzer:fuzztest", diff --git a/test/fuzztest/ability_fuzz_util.h b/test/fuzztest/ability_fuzz_util.h index 88ccc0a0bd4..2a842567564 100644 --- a/test/fuzztest/ability_fuzz_util.h +++ b/test/fuzztest/ability_fuzz_util.h @@ -26,8 +26,6 @@ #include "bundle_user_info.h" #include "extract_insight_intent_profile.h" #include "keep_alive_process_manager.h" -#include "want.h" -#include "want_params_wrapper.h" namespace OHOS { namespace AppExecFwk { @@ -517,7 +515,6 @@ void GetRandomDialogCallerInfo(FuzzedDataProvider& fdp, DialogCallerInfo& dialog // SelectorType type = SelectorType::WITHOUT_SELECTOR; dialogCallerInfo.needGrantUriPermission = fdp.ConsumeBool(); } - } // namespace AbilityFuzzUtil } // namespace AppExecFwk } // namespace OHOS -- Gitee From 7003fd5c8fecd3eaac955d452e0c9274836970e7 Mon Sep 17 00:00:00 2001 From: yanhuan Date: Mon, 30 Jun 2025 20:59:34 +0800 Subject: [PATCH 3/3] =?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 | 24 ------------------- .../dialogsessionmanagerfifth_fuzzer.cpp | 10 ++++---- .../BUILD.gn | 1 + .../dialogsessionmanagerfourth_fuzzer.cpp | 2 +- .../dialogsessionmanagerthird_fuzzer.cpp | 2 +- 5 files changed, 7 insertions(+), 32 deletions(-) diff --git a/test/fuzztest/ability_fuzz_util.h b/test/fuzztest/ability_fuzz_util.h index 2a842567564..4e1eb877acc 100644 --- a/test/fuzztest/ability_fuzz_util.h +++ b/test/fuzztest/ability_fuzz_util.h @@ -491,30 +491,6 @@ void GetRandomAbilityRequestInfo(FuzzedDataProvider& fdp, AbilityRequest& info) GetRandomAbilityInfo(fdp, info.abilityInfo); GetRandomApplicationInfo(fdp, info.appInfo); } - -void GetRandomDialogAbilityInfo(FuzzedDataProvider& fdp, DialogAbilityInfo& targetAbilityInfos) -{ - targetAbilityInfos.visible = fdp.ConsumeBool(); - targetAbilityInfos.bundleIconId = fdp.ConsumeIntegral(); - targetAbilityInfos.bundleLabelId = fdp.ConsumeIntegral(); - targetAbilityInfos.abilityIconId = fdp.ConsumeIntegral(); - targetAbilityInfos.abilityLabelId = fdp.ConsumeIntegral(); - targetAbilityInfos.appIndex = fdp.ConsumeIntegral(); - targetAbilityInfos.bundleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); - targetAbilityInfos.moduleName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); - targetAbilityInfos.abilityName = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); -} - -void GetRandomDialogCallerInfo(FuzzedDataProvider& fdp, DialogCallerInfo& dialogCallerInfo) -{ - dialogCallerInfo.userId = fdp.ConsumeIntegral(); - dialogCallerInfo.requestCode = fdp.ConsumeIntegral(); - sptr callerToken; - Want targetWant; - dialogCallerInfo.type = static_cast(fdp.ConsumeIntegralInRange(0, CODE_TWO)); - // SelectorType type = SelectorType::WITHOUT_SELECTOR; - dialogCallerInfo.needGrantUriPermission = fdp.ConsumeBool(); -} } // namespace AbilityFuzzUtil } // namespace AppExecFwk } // namespace OHOS diff --git a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp index e9d8bb0366c..5f9b07dc08d 100644 --- a/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp +++ b/test/fuzztest/dialogsessionmanagerfifth_fuzzer/dialogsessionmanagerfifth_fuzzer.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "dialogsessionmanagerfirst_fuzzer.h" +#include "dialogsessionmanagerfifth_fuzzer.h" #include #include #include @@ -22,7 +22,6 @@ #undef private #include "ability_record.h" #include "dialog_session_manager.h" -#include "../ability_fuzz_util.h" using namespace OHOS::AAFwk; using namespace OHOS::AppExecFwk; @@ -32,17 +31,16 @@ namespace {} // namespace bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) { - DialogSessionInfo dilogSessionInfo; - DialogCallerInfo callerInfo; + sptr dilogSessionInfo; + std::shared_ptr dialogCallerInfo; std::string dialogSessionId; FuzzedDataProvider fdp(data, size); dialogSessionId = fdp.ConsumeRandomLengthString(); - AbilityFuzzUtil::GetRandomDialogCallerInfo(fdp, callerInfo); std::shared_ptr dialogSessionManager = std::make_shared(); if (dialogSessionManager == nullptr) { return false; } - dialogSessionManager->SetDialogSessionInfo(dialogSessionId, dilogSessionInfo, callerInfo); + dialogSessionManager->SetDialogSessionInfo(dialogSessionId, dilogSessionInfo, dialogCallerInfo); return true; } } // namespace OHOS diff --git a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn index 7ee0c163e18..46394966ce7 100644 --- a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn +++ b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ 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/utils/start_ability_utils.cpp", "dialogsessionmanagerfourth_fuzzer.cpp", diff --git a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.cpp b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.cpp index 3e47a596030..900a2538bc7 100644 --- a/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.cpp +++ b/test/fuzztest/dialogsessionmanagerfourth_fuzzer/dialogsessionmanagerfourth_fuzzer.cpp @@ -13,7 +13,7 @@ * limitations under the License. */ -#include "dialogsessionmanagerthird_fuzzer.h" +#include "dialogsessionmanagerfourth_fuzzer.h" #include #include #include diff --git a/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.cpp b/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.cpp index b9027bff6f5..146672e08db 100644 --- a/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.cpp +++ b/test/fuzztest/dialogsessionmanagerthird_fuzzer/dialogsessionmanagerthird_fuzzer.cpp @@ -32,7 +32,7 @@ namespace {} // namespace bool DoSomethingInterestingWithMyAPI(const uint8_t *data, size_t size) { AbilityRequest info; - DialogAbilityInfo targetAbilityInfos; + std::vector targetAbilityInfos; FuzzedDataProvider fdp(data, size); AbilityFuzzUtil::GetRandomAbilityRequestInfo(fdp, info); std::shared_ptr dialogSessionManager = std::make_shared(); -- Gitee