From 30e958064f43299fb17f14031e9b76f678619852 Mon Sep 17 00:00:00 2001 From: "yuantianzhu1@huawei.com" Date: Tue, 7 May 2024 17:06:06 +0800 Subject: [PATCH] add scene_session_manager_lite fuzz testcase Signed-off-by: yuantianzhu1@huawei.com --- .../scenesessionmgrlstubicon_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../corpus/init | 14 +++ .../project.xml | 25 ++++ .../scenesessionmgrlstubicon_fuzzer.cpp | 66 +++++++++++ .../scenesessionmgrlstubicon_fuzzer.h | 21 ++++ .../scenesessionmgrlstublabel_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../corpus/init | 14 +++ .../project.xml | 25 ++++ .../scenesessionmgrlstublabel_fuzzer.cpp | 66 +++++++++++ .../scenesessionmgrlstublabel_fuzzer.h | 21 ++++ .../scenesessionmgrlstubtoken_fuzzer/BUILD.gn | 108 ++++++++++++++++++ .../corpus/init | 14 +++ .../project.xml | 25 ++++ .../scenesessionmgrlstubtoken_fuzzer.cpp | 66 +++++++++++ .../scenesessionmgrlstubtoken_fuzzer.h | 21 ++++ 15 files changed, 702 insertions(+) create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/BUILD.gn create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/corpus/init create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/project.xml create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/scenesessionmgrlstubicon_fuzzer.cpp create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/scenesessionmgrlstubicon_fuzzer.h create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/BUILD.gn create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/corpus/init create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/project.xml create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/scenesessionmgrlstublabel_fuzzer.cpp create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/scenesessionmgrlstublabel_fuzzer.h create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/BUILD.gn create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/corpus/init create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/project.xml create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/scenesessionmgrlstubtoken_fuzzer.cpp create mode 100644 test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/scenesessionmgrlstubtoken_fuzzer.h diff --git a/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/BUILD.gn b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/BUILD.gn new file mode 100644 index 0000000000..b65284e528 --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../../windowmanager_aafwk.gni") + +module_output_path = "window_manager/window_manager" + +##############################fuzztest########################################## +ohos_fuzztest("SceneSessionMgrLStubIconFuzzTest") { + fuzz_config_file = "." + module_out_path = module_output_path + + include_dirs = [ + "${window_base_path}/window_scene", + "${window_base_path}/window_scene/session_manager/include", + "${window_base_path}/window_scene/session_manager/include/zidl", + "../", + + # for session_manager + "${window_base_path}/wmserver/include", + "${window_base_path}/wmserver/include/zidl", + + # for window_manager + "${window_base_path}/utils/include", + "${window_base_path}/wm/include", + "${window_base_path}/wm/include/zidl", + ] + cflags = [ + "-g", + "-O0", + "-fno-omit-frame-pointer", + ] + sources = [ "scenesessionmgrlstubicon_fuzzer.cpp" ] + deps = [ + "${window_base_path}/dm:libdm", + "${window_base_path}/utils:libwmutil", + "${window_base_path}/utils:libwmutil_base", + "${window_base_path}/window_scene/common:window_scene_common", + "${window_base_path}/window_scene/intention_event/service:intention_event_anr_manager", + "${window_base_path}/window_scene/screen_session_manager:screen_session_manager_client", + "${window_base_path}/window_scene/session:scene_session", + "${window_base_path}/window_scene/session:screen_session", + "${window_base_path}/window_scene/session_manager:scene_session_manager", + ] + public_external_deps = [ + "ability_runtime:session_handler", + "accessibility:accessibility_common", + "graphic_2d:window_animation", + "input:libmmi-client", + "input:libmmi-util", + ] + external_deps = [ + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "ability_runtime:ability_context_native", + "ability_runtime:ability_deps_wrapper", + "ability_runtime:ability_manager", + "ability_runtime:ability_start_setting", + "ability_runtime:app_manager", + "ability_runtime:mission_info", + "ability_runtime:session_handler", + "ace_engine:ace_uicontent", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "config_policy:configpolicy_util", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hitrace:hitrace_meter", + "image_framework:image_native", + "init:libbegetutil", + "input:libmmi-client", + "ipc:ipc_single", + "libxml2:libxml2", + "napi:ace_napi", + "resource_management:global_resmgr", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":SceneSessionMgrLStubIconFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/corpus/init b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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/window_scene/scenesessionmgrlstubicon_fuzzer/project.xml b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/scenesessionmgrlstubicon_fuzzer.cpp b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/scenesessionmgrlstubicon_fuzzer.cpp new file mode 100644 index 0000000000..c3e8d8cc0b --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/scenesessionmgrlstubicon_fuzzer.cpp @@ -0,0 +1,66 @@ +/* + * 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 "scenesessionmgrlstubicon_fuzzer.h" + +#include +#include +#include +#include + +#include +#include "message_option.h" +#include "message_parcel.h" +#include "marshalling_helper.h" +#include "scene_session_manager_lite.h" +#include "scene_session_manager_lite_stub.h" +#include "scene_session_manager_lite_interface.h" + +using namespace OHOS::Rosen; + +namespace OHOS { +namespace { +constexpr size_t DATA_MIN_SIZE = 2; +} + +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < DATA_MIN_SIZE) { + return false; + } + + MessageParcel parcel; + MessageParcel reply; + MessageOption option; + + parcel.WriteInterfaceToken(SceneSessionManagerLiteStub::GetDescriptor()); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + + SceneSessionManagerLite::GetInstance().OnRemoteRequest( + static_cast(ISceneSessionManagerLite:: + SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_ICON), + parcel, reply, option); + 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/window_scene/scenesessionmgrlstubicon_fuzzer/scenesessionmgrlstubicon_fuzzer.h b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/scenesessionmgrlstubicon_fuzzer.h new file mode 100644 index 0000000000..c055a07b16 --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubicon_fuzzer/scenesessionmgrlstubicon_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 TEST_FUZZTEST_SCENE_SESSION_MANAGER_LITE_STUB_ICON_FUZZER_H +#define TEST_FUZZTEST_SCENE_SESSION_MANAGER_LITE_STUB_ICON_FUZZER_H + +#define FUZZ_PROJECT_NAME "scenesessionmgrlstubicon_fuzzer" + +#endif diff --git a/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/BUILD.gn b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/BUILD.gn new file mode 100644 index 0000000000..38b74792af --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../../windowmanager_aafwk.gni") + +module_output_path = "window_manager/window_manager" + +##############################fuzztest########################################## +ohos_fuzztest("SceneSessionMgrLStubLabelFuzzTest") { + fuzz_config_file = "." + module_out_path = module_output_path + + include_dirs = [ + "${window_base_path}/window_scene", + "${window_base_path}/window_scene/session_manager/include", + "${window_base_path}/window_scene/session_manager/include/zidl", + "../", + + # for session_manager + "${window_base_path}/wmserver/include", + "${window_base_path}/wmserver/include/zidl", + + # for window_manager + "${window_base_path}/utils/include", + "${window_base_path}/wm/include", + "${window_base_path}/wm/include/zidl", + ] + cflags = [ + "-g", + "-O0", + "-fno-omit-frame-pointer", + ] + sources = [ "scenesessionmgrlstublabel_fuzzer.cpp" ] + deps = [ + "${window_base_path}/dm:libdm", + "${window_base_path}/utils:libwmutil", + "${window_base_path}/utils:libwmutil_base", + "${window_base_path}/window_scene/common:window_scene_common", + "${window_base_path}/window_scene/intention_event/service:intention_event_anr_manager", + "${window_base_path}/window_scene/screen_session_manager:screen_session_manager_client", + "${window_base_path}/window_scene/session:scene_session", + "${window_base_path}/window_scene/session:screen_session", + "${window_base_path}/window_scene/session_manager:scene_session_manager", + ] + public_external_deps = [ + "ability_runtime:session_handler", + "accessibility:accessibility_common", + "graphic_2d:window_animation", + "input:libmmi-client", + "input:libmmi-util", + ] + external_deps = [ + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "ability_runtime:ability_context_native", + "ability_runtime:ability_deps_wrapper", + "ability_runtime:ability_manager", + "ability_runtime:ability_start_setting", + "ability_runtime:app_manager", + "ability_runtime:mission_info", + "ability_runtime:session_handler", + "ace_engine:ace_uicontent", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "config_policy:configpolicy_util", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hitrace:hitrace_meter", + "image_framework:image_native", + "init:libbegetutil", + "input:libmmi-client", + "ipc:ipc_single", + "libxml2:libxml2", + "napi:ace_napi", + "resource_management:global_resmgr", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":SceneSessionMgrLStubLabelFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/corpus/init b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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/window_scene/scenesessionmgrlstublabel_fuzzer/project.xml b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/scenesessionmgrlstublabel_fuzzer.cpp b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/scenesessionmgrlstublabel_fuzzer.cpp new file mode 100644 index 0000000000..fe9b175a7c --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/scenesessionmgrlstublabel_fuzzer.cpp @@ -0,0 +1,66 @@ +/* + * 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 "scenesessionmgrlstublabel_fuzzer.h" + +#include +#include +#include +#include + +#include +#include "message_option.h" +#include "message_parcel.h" +#include "marshalling_helper.h" +#include "scene_session_manager_lite.h" +#include "scene_session_manager_lite_stub.h" +#include "scene_session_manager_lite_interface.h" + +using namespace OHOS::Rosen; + +namespace OHOS { +namespace { +constexpr size_t DATA_MIN_SIZE = 2; +} + +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < DATA_MIN_SIZE) { + return false; + } + + MessageParcel parcel; + MessageParcel reply; + MessageOption option; + + parcel.WriteInterfaceToken(SceneSessionManagerLiteStub::GetDescriptor()); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + + SceneSessionManagerLite::GetInstance().OnRemoteRequest( + static_cast(ISceneSessionManagerLite:: + SceneSessionManagerLiteMessage::TRANS_ID_SET_SESSION_LABEL), + parcel, reply, option); + 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/window_scene/scenesessionmgrlstublabel_fuzzer/scenesessionmgrlstublabel_fuzzer.h b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/scenesessionmgrlstublabel_fuzzer.h new file mode 100644 index 0000000000..501fbbd206 --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstublabel_fuzzer/scenesessionmgrlstublabel_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 TEST_FUZZTEST_SCENE_SESSION_MANAGER_LITE_STUB_LABEL_FUZZER_H +#define TEST_FUZZTEST_SCENE_SESSION_MANAGER_LITE_STUB_LABEL_FUZZER_H + +#define FUZZ_PROJECT_NAME "scenesessionmgrlstublabel_fuzzer" + +#endif diff --git a/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/BUILD.gn b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/BUILD.gn new file mode 100644 index 0000000000..c70ab43a69 --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/BUILD.gn @@ -0,0 +1,108 @@ +# 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. + +import("//build/config/features.gni") +import("//build/test.gni") +import("../../../../windowmanager_aafwk.gni") + +module_output_path = "window_manager/window_manager" + +##############################fuzztest########################################## +ohos_fuzztest("SceneSessionMgrLStubTokenFuzzTest") { + fuzz_config_file = "." + module_out_path = module_output_path + + include_dirs = [ + "${window_base_path}/window_scene", + "${window_base_path}/window_scene/session_manager/include", + "${window_base_path}/window_scene/session_manager/include/zidl", + "../", + + # for session_manager + "${window_base_path}/wmserver/include", + "${window_base_path}/wmserver/include/zidl", + + # for window_manager + "${window_base_path}/utils/include", + "${window_base_path}/wm/include", + "${window_base_path}/wm/include/zidl", + ] + cflags = [ + "-g", + "-O0", + "-fno-omit-frame-pointer", + ] + sources = [ "scenesessionmgrlstubtoken_fuzzer.cpp" ] + deps = [ + "${window_base_path}/dm:libdm", + "${window_base_path}/utils:libwmutil", + "${window_base_path}/utils:libwmutil_base", + "${window_base_path}/window_scene/common:window_scene_common", + "${window_base_path}/window_scene/intention_event/service:intention_event_anr_manager", + "${window_base_path}/window_scene/screen_session_manager:screen_session_manager_client", + "${window_base_path}/window_scene/session:scene_session", + "${window_base_path}/window_scene/session:screen_session", + "${window_base_path}/window_scene/session_manager:scene_session_manager", + ] + public_external_deps = [ + "ability_runtime:session_handler", + "accessibility:accessibility_common", + "graphic_2d:window_animation", + "input:libmmi-client", + "input:libmmi-util", + ] + external_deps = [ + "ability_base:configuration", + "ability_base:session_info", + "ability_base:want", + "ability_runtime:ability_context_native", + "ability_runtime:ability_deps_wrapper", + "ability_runtime:ability_manager", + "ability_runtime:ability_start_setting", + "ability_runtime:app_manager", + "ability_runtime:mission_info", + "ability_runtime:session_handler", + "ace_engine:ace_uicontent", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "config_policy:configpolicy_util", + "dsoftbus:softbus_client", + "eventhandler:libeventhandler", + "ffrt:libffrt", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hitrace:hitrace_meter", + "image_framework:image_native", + "init:libbegetutil", + "input:libmmi-client", + "ipc:ipc_single", + "libxml2:libxml2", + "napi:ace_napi", + "resource_management:global_resmgr", + "samgr:samgr_proxy", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":SceneSessionMgrLStubTokenFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/corpus/init b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/corpus/init new file mode 100644 index 0000000000..e7c3fecd8d --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# 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/window_scene/scenesessionmgrlstubtoken_fuzzer/project.xml b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/scenesessionmgrlstubtoken_fuzzer.cpp b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/scenesessionmgrlstubtoken_fuzzer.cpp new file mode 100644 index 0000000000..23e55d02a1 --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/scenesessionmgrlstubtoken_fuzzer.cpp @@ -0,0 +1,66 @@ +/* + * 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 "scenesessionmgrlstubtoken_fuzzer.h" + +#include +#include +#include +#include + +#include +#include "message_option.h" +#include "message_parcel.h" +#include "marshalling_helper.h" +#include "scene_session_manager_lite.h" +#include "scene_session_manager_lite_stub.h" +#include "scene_session_manager_lite_interface.h" + +using namespace OHOS::Rosen; + +namespace OHOS { +namespace { +constexpr size_t DATA_MIN_SIZE = 2; +} + +bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) +{ + if (data == nullptr || size < DATA_MIN_SIZE) { + return false; + } + + MessageParcel parcel; + MessageParcel reply; + MessageOption option; + + parcel.WriteInterfaceToken(SceneSessionManagerLiteStub::GetDescriptor()); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + + SceneSessionManagerLite::GetInstance().OnRemoteRequest( + static_cast(ISceneSessionManagerLite:: + SceneSessionManagerLiteMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN), + parcel, reply, option); + 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/window_scene/scenesessionmgrlstubtoken_fuzzer/scenesessionmgrlstubtoken_fuzzer.h b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/scenesessionmgrlstubtoken_fuzzer.h new file mode 100644 index 0000000000..ed63ea861b --- /dev/null +++ b/test/fuzztest/window_scene/scenesessionmgrlstubtoken_fuzzer/scenesessionmgrlstubtoken_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 TEST_FUZZTEST_SCENE_SESSION_MANAGER_LITE_STUB_TOKEN_FUZZER_H +#define TEST_FUZZTEST_SCENE_SESSION_MANAGER_LITE_STUB_TOKEN_FUZZER_H + +#define FUZZ_PROJECT_NAME "scenesessionmgrlstubtoken_fuzzer" + +#endif