!6269 scene session manager stub fuzz用例补齐

Merge pull request !6269 from yuantianzhu1@huawei.com/fuzz2
This commit is contained in:
openharmony_ci 2024-05-17 09:05:49 +00:00 committed by Gitee
commit 3e1ddf0f97
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
15 changed files with 706 additions and 0 deletions

View File

@ -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("SceneSessionMgrStubAgentFuzzTest") {
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 = [ "scenesessionmgrstubagent_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
":SceneSessionMgrStubAgentFuzzTest",
]
}
###############################################################################

View File

@ -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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -0,0 +1,70 @@
/*
* 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 "scenesessionmgrstubagent_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <parcel.h>
#include <securec.h>
#include <iremote_stub.h>
#include "message_option.h"
#include "message_parcel.h"
#include "marshalling_helper.h"
#include "scene_session_manager.h"
#include "scene_session_manager_stub.h"
#include "scene_session_manager_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(SceneSessionManagerStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
SceneSessionManager::GetInstance().OnRemoteRequest(
static_cast<uint32_t>(ISceneSessionManager::
SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT),
parcel, reply, option);
SceneSessionManager::GetInstance().OnRemoteRequest(
static_cast<uint32_t>(ISceneSessionManager::
SceneSessionManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT),
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;
}

View File

@ -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_STUB_AGENT_FUZZER_H
#define TEST_FUZZTEST_SCENE_SESSION_MANAGER_STUB_AGENT_FUZZER_H
#define FUZZ_PROJECT_NAME "scenesessionmgrstubagent_fuzzer"
#endif

View File

@ -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("SceneSessionMgrStubInfoFuzzTest") {
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 = [ "scenesessionmgrstubinfo_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
":SceneSessionMgrStubInfoFuzzTest",
]
}
###############################################################################

View File

@ -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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -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 "scenesessionmgrstubinfo_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <parcel.h>
#include <securec.h>
#include <iremote_stub.h>
#include "message_option.h"
#include "message_parcel.h"
#include "marshalling_helper.h"
#include "scene_session_manager.h"
#include "scene_session_manager_stub.h"
#include "scene_session_manager_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(SceneSessionManagerStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
SceneSessionManager::GetInstance().OnRemoteRequest(
static_cast<uint32_t>(ISceneSessionManager::
SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_INFO),
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;
}

View File

@ -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_STUB_INFO_FUZZER_H
#define TEST_FUZZTEST_SCENE_SESSION_MANAGER_STUB_INFO_FUZZER_H
#define FUZZ_PROJECT_NAME "scenesessionmgrstubinfo_fuzzer"
#endif

View File

@ -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("SceneSessionMgrStubLabelFuzzTest") {
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 = [ "scenesessionmgrstublabel_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
":SceneSessionMgrStubLabelFuzzTest",
]
}
###############################################################################

View File

@ -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

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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_config>
<fuzztest>
<!-- maximum length of a test input -->
<max_len>1000</max_len>
<!-- maximum total time in seconds to run the fuzzer -->
<max_total_time>300</max_total_time>
<!-- memory usage limit in Mb -->
<rss_limit_mb>4096</rss_limit_mb>
</fuzztest>
</fuzz_config>

View File

@ -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 "scenesessionmgrstublabel_fuzzer.h"
#include <cstddef>
#include <cstdint>
#include <parcel.h>
#include <securec.h>
#include <iremote_stub.h>
#include "message_option.h"
#include "message_parcel.h"
#include "marshalling_helper.h"
#include "scene_session_manager.h"
#include "scene_session_manager_stub.h"
#include "scene_session_manager_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(SceneSessionManagerStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
SceneSessionManager::GetInstance().OnRemoteRequest(
static_cast<uint32_t>(ISceneSessionManager::
SceneSessionManagerMessage::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;
}

View File

@ -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_STUB_LABEL_FUZZER_H
#define TEST_FUZZTEST_SCENE_SESSION_MANAGER_STUB_LABEL_FUZZER_H
#define FUZZ_PROJECT_NAME "scenesessionmgrstublabel_fuzzer"
#endif