diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 189721e789c112387267c050b4e59b1212bcc76b..7baf100ee12d7e55a953891bfc698259d6b7ca31 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -327,6 +327,10 @@ group("fuzztest") { "getwantsender_fuzzer:fuzztest", "handledlpapp_fuzzer:fuzztest", "insightintentexecutecallbackstub_fuzzer:fuzztest", + "insightintentexecuteparamfirst_fuzzer:fuzztest", + "insightintentexecuteparamfourth_fuzzer:fuzztest", + "insightintentexecuteparamsecond_fuzzer:fuzztest", + "insightintentexecuteparamthird_fuzzer:fuzztest", "isramconstraineddevice_fuzzer:fuzztest", "jsabilityautostartupmanager_fuzzer:fuzztest", "keepaliveprocessmanagereighteenth_fuzzer:fuzztest", diff --git a/test/fuzztest/ability_fuzz_util.h b/test/fuzztest/ability_fuzz_util.h index e39e4612458e9e0e24061abbe3d96e8af5eedeb5..d308be4536e492038f0dcfc96c3537cc17c801fb 100644 --- a/test/fuzztest/ability_fuzz_util.h +++ b/test/fuzztest/ability_fuzz_util.h @@ -47,6 +47,27 @@ std::vector GenerateStringArray(FuzzedDataProvider& fdp, size_t arr return result; } +void GetRandomInsightIntentExecuteParam(FuzzedDataProvider& fdp, InsightIntentExecuteParam& info) +{ + info.executeMode_ = fdp.ConsumeIntegral(); + info.displayId_ = fdp.ConsumeIntegral(); + info.flags_ = fdp.ConsumeIntegral(); + info.insightIntentId_ = fdp.ConsumeIntegral(); + info.bundleName_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.moduleName_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.abilityName_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.insightIntentName_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.uris_ = GenerateStringArray(fdp); + info.decoratorType_ = fdp.ConsumeIntegral(); + info.srcEntrance_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.className_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.methodName_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.methodParams_ = GenerateStringArray(fdp); + info.pagePath_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.navigationId_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); + info.navDestinationName_ = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); +} + void GenerateSignatureInfo(FuzzedDataProvider& fdp, SignatureInfo &signatureInfo) { signatureInfo.appId = fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH); diff --git a/test/fuzztest/insightintentexecuteparamfirst_fuzzer/BUILD.gn b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c2fb5628a5ce53928fcc8b19f2134b585aea376d --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/BUILD.gn @@ -0,0 +1,86 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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("InsightIntentExecuteParamFirstFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/insightintentexecuteparamfirst_fuzzer" + + include_dirs = [ "${ability_runtime_innerkits_path}/wantagent/include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "insightintentexecuteparamfirst_fuzzer.cpp" ] + + configs = [ + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "access_token:libaccesstoken_sdk", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "init:libbeget_proxy", + "ipc:ipc_core", + "napi:ace_napi", + "relational_store:native_appdatafwk", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":InsightIntentExecuteParamFirstFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/insightintentexecuteparamfirst_fuzzer/corpus/init b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/insightintentexecuteparamfirst_fuzzer/insightintentexecuteparamfirst_fuzzer.cpp b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/insightintentexecuteparamfirst_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..215e4988db9330093ff8022488c944e6ea5239b2 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/insightintentexecuteparamfirst_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "insightintentexecuteparamfirst_fuzzer.h" + +#include +#include +#include + +#include "insight_intent_execute_param.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr size_t STRING_MAX_LENGTH = 128; +} +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + InsightIntentExecuteParam executeParam; + Parcel parcel; + FuzzedDataProvider fdp(data, size); + parcel.WriteString(fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH)); + executeParam.ReadFromParcel(parcel); + + return true; +} +} + +/* 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/insightintentexecuteparamfirst_fuzzer/insightintentexecuteparamfirst_fuzzer.h b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/insightintentexecuteparamfirst_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..5ba9f33e2604bac310bb29a0b5049fee58a2267a --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/insightintentexecuteparamfirst_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_INSIGHTINTENTEXECUTEPARAM_FIRST_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_INSIGHTINTENTEXECUTEPARAM_FIRST_FUZZER_H + +#define FUZZ_PROJECT_NAME "insightintentexecuteparamfirst_fuzzer" + +#endif diff --git a/test/fuzztest/insightintentexecuteparamfirst_fuzzer/project.xml b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4a9e5e0e8a11651fe5994c426bebaa63a1c7a980 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfirst_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + + diff --git a/test/fuzztest/insightintentexecuteparamfourth_fuzzer/BUILD.gn b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..06b83605e4dcfc9c632d26e8d05c66f8e63f6d4f --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/BUILD.gn @@ -0,0 +1,86 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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("InsightIntentExecuteParamFourthFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/insightintentexecuteparamfourth_fuzzer" + + include_dirs = [ "${ability_runtime_innerkits_path}/wantagent/include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "insightintentexecuteparamfourth_fuzzer.cpp" ] + + configs = [ + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "access_token:libaccesstoken_sdk", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "init:libbeget_proxy", + "ipc:ipc_core", + "napi:ace_napi", + "relational_store:native_appdatafwk", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":InsightIntentExecuteParamFourthFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/insightintentexecuteparamfourth_fuzzer/corpus/init b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/insightintentexecuteparamfourth_fuzzer/insightintentexecuteparamfourth_fuzzer.cpp b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/insightintentexecuteparamfourth_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4fe68daf5bb4b9b8aeace2633c6b4010a2a15779 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/insightintentexecuteparamfourth_fuzzer.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "insightintentexecuteparamfourth_fuzzer.h" + +#include +#include +#include + +#include "insight_intent_execute_param.h" +#include "int_wrapper.h" +#include "string_wrapper.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr size_t STRING_MAX_LENGTH = 128; +} +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + InsightIntentExecuteParam executeParam; + WantParams wantParams; + WantParams insightIntentParam; + FuzzedDataProvider fdp(data, size); + wantParams.SetParam(fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH), 0); + insightIntentParam.SetParam(fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH), + String::Box(fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH))); + insightIntentParam.SetParam(fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH), + Integer::Box(fdp.ConsumeIntegral())); + executeParam.UpdateInsightIntentCallerInfo(wantParams, insightIntentParam); + + return true; +} +} + +/* 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/insightintentexecuteparamfourth_fuzzer/insightintentexecuteparamfourth_fuzzer.h b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/insightintentexecuteparamfourth_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..9b74955e21fedc9a5202d09ab1592665f825e224 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/insightintentexecuteparamfourth_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_INSIGHTINTENTEXECUTEPARAM_FOURTH_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_INSIGHTINTENTEXECUTEPARAM_FOURTH_FUZZER_H + +#define FUZZ_PROJECT_NAME "insightintentexecuteparamfourth_fuzzer" + +#endif diff --git a/test/fuzztest/insightintentexecuteparamfourth_fuzzer/project.xml b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4a9e5e0e8a11651fe5994c426bebaa63a1c7a980 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamfourth_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + + diff --git a/test/fuzztest/insightintentexecuteparamsecond_fuzzer/BUILD.gn b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0f839d13df6809ef0aa99a5448bb6331c920de7e --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/BUILD.gn @@ -0,0 +1,86 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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("InsightIntentExecuteParamSecondFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/insightintentexecuteparamsecond_fuzzer" + + include_dirs = [ "${ability_runtime_innerkits_path}/wantagent/include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "insightintentexecuteparamsecond_fuzzer.cpp" ] + + configs = [ + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "access_token:libaccesstoken_sdk", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "init:libbeget_proxy", + "ipc:ipc_core", + "napi:ace_napi", + "relational_store:native_appdatafwk", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":InsightIntentExecuteParamSecondFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/insightintentexecuteparamsecond_fuzzer/corpus/init b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/insightintentexecuteparamsecond_fuzzer/insightintentexecuteparamsecond_fuzzer.cpp b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/insightintentexecuteparamsecond_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2879682d61529f903422438ce299b7f6d72dd6c9 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/insightintentexecuteparamsecond_fuzzer.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "insightintentexecuteparamsecond_fuzzer.h" + +#include +#include +#include + +#include "insight_intent_execute_param.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr size_t STRING_MAX_LENGTH = 128; +} +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + InsightIntentExecuteParam executeParam; + Parcel parcel; + Want want; + FuzzedDataProvider fdp(data, size); + parcel.WriteString(fdp.ConsumeRandomLengthString(STRING_MAX_LENGTH)); + executeParam.Marshalling(parcel); + executeParam.Unmarshalling(parcel); + executeParam.IsInsightIntentExecute(want); + executeParam.IsInsightIntentPage(want); + executeParam.RemoveInsightIntent(want); + + return true; +} +} + +/* 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/insightintentexecuteparamsecond_fuzzer/insightintentexecuteparamsecond_fuzzer.h b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/insightintentexecuteparamsecond_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..633aa53cac915fbd10eebcc59fb5a9e70585074e --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/insightintentexecuteparamsecond_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_INSIGHTINTENTEXECUTEPARAM_SECOND_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_INSIGHTINTENTEXECUTEPARAM_SECOND_FUZZER_H + +#define FUZZ_PROJECT_NAME "insightintentexecuteparamsecond_fuzzer" + +#endif diff --git a/test/fuzztest/insightintentexecuteparamsecond_fuzzer/project.xml b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4a9e5e0e8a11651fe5994c426bebaa63a1c7a980 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamsecond_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + + diff --git a/test/fuzztest/insightintentexecuteparamthird_fuzzer/BUILD.gn b/test/fuzztest/insightintentexecuteparamthird_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8be87bd4dda6b6b65726ffc61e116b8350270b62 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamthird_fuzzer/BUILD.gn @@ -0,0 +1,86 @@ +# Copyright (c) 2025 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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("InsightIntentExecuteParamThirdFuzzTest") { + module_out_path = module_output_path + + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/insightintentexecuteparamthird_fuzzer" + + include_dirs = [ "${ability_runtime_innerkits_path}/wantagent/include" ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + + sources = [ "insightintentexecuteparamthird_fuzzer.cpp" ] + + configs = [ + "${ability_runtime_services_path}/abilitymgr:abilityms_config", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager_public_config", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "access_token:libaccesstoken_sdk", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "hilog:libhilog", + "hisysevent:libhisysevent", + "init:libbeget_proxy", + "ipc:ipc_core", + "napi:ace_napi", + "relational_store:native_appdatafwk", + "relational_store:native_dataability", + "relational_store:native_rdb", + "safwk:system_ability_fwk", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":InsightIntentExecuteParamThirdFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/insightintentexecuteparamthird_fuzzer/corpus/init b/test/fuzztest/insightintentexecuteparamthird_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..7ade8a0faafeaedba7241e7d4a97b8e1f9691932 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamthird_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/insightintentexecuteparamthird_fuzzer/insightintentexecuteparamthird_fuzzer.cpp b/test/fuzztest/insightintentexecuteparamthird_fuzzer/insightintentexecuteparamthird_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ff6bbc883581a5a319e066c3508f2ec75f29b90e --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamthird_fuzzer/insightintentexecuteparamthird_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 "insightintentexecuteparamthird_fuzzer.h" + +#include +#include +#include + +#include "insight_intent_execute_param.h" +#include "insight_intent_utils.h" +#include "../ability_fuzz_util.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + InsightIntentExecuteParam executeParam; + Want want; + InsightIntentExecuteParam param; + FuzzedDataProvider fdp(data, size); + AbilityFuzzUtil::GetRandomInsightIntentExecuteParam(fdp, param); + executeParam.GenerateFromWant(want, param); + + return true; +} +} + +/* 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/insightintentexecuteparamthird_fuzzer/insightintentexecuteparamthird_fuzzer.h b/test/fuzztest/insightintentexecuteparamthird_fuzzer/insightintentexecuteparamthird_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..232c691d154309ba084c2801597fc58a41d720c5 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamthird_fuzzer/insightintentexecuteparamthird_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_INSIGHTINTENTEXECUTEPARAM_THIRD_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_INSIGHTINTENTEXECUTEPARAM_THIRD_FUZZER_H + +#define FUZZ_PROJECT_NAME "insightintentexecuteparamthird_fuzzer" + +#endif diff --git a/test/fuzztest/insightintentexecuteparamthird_fuzzer/project.xml b/test/fuzztest/insightintentexecuteparamthird_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..4a9e5e0e8a11651fe5994c426bebaa63a1c7a980 --- /dev/null +++ b/test/fuzztest/insightintentexecuteparamthird_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 600 + + 4096 + +