!6108 window manager agent stub fuzz补齐

Merge pull request !6108 from wangjian10/master
This commit is contained in:
openharmony_ci 2024-05-10 01:18:42 +00:00 committed by Gitee
commit 0010235cde
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
42 changed files with 1624 additions and 0 deletions

View File

@ -17,6 +17,9 @@ group("fuzztest") {
deps = [
"scenesessionmanager_fuzzer:fuzztest",
"screensessionmanager_fuzzer:fuzztest",
"screensessionmgrstubagent_fuzzer:fuzztest",
"screensessionmgrstubstate_fuzzer:fuzztest",
"screensessionmgrstubwake_fuzzer:fuzztest",
"sessioninterface_fuzzer:fuzztest",
]
}

View File

@ -0,0 +1,64 @@
# 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("ScreenSessionMgrStubAgentFuzzTest") {
fuzz_config_file = "."
module_out_path = module_output_path
include_dirs = [
"${window_base_path}/window_scene/session_manager/include",
"${window_base_path}/wmserver/include",
"../",
]
cflags = [
"-g",
"-O0",
"-fno-omit-frame-pointer",
]
sources = [ "screensessionmgrstubagent_fuzzer.cpp" ]
deps = [
"${window_base_path}/dm:libdm",
"${window_base_path}/utils:libwmutil",
"${window_base_path}/window_scene/common:window_scene_common",
"${window_base_path}/window_scene/session_manager:screen_session_manager",
"${window_base_path}/window_scene/session_manager:session_manager",
]
external_deps = [
"ability_base:session_info",
"ability_base:want",
"ability_runtime:ability_manager",
"ability_runtime:mission_info",
"c_utils:utils",
"ffrt:libffrt",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_single",
"samgr:samgr_proxy",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
}
###############################################################################

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,78 @@
/*
* 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 <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 "display_manager_interface.h"
#include "screen_session_manager_stub.h"
#include "screensessionmgrstubagent_fuzzer.h"
using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
size_t GetObject(T &object, const uint8_t *data, size_t size)
{
size_t objectSize = sizeof(object);
if (objectSize > size) {
return 0;
}
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
}
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(ScreenSessionManagerStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<ScreenSessionManagerStub> screenStub = std::make_shared<ScreenSessionManagerStub>();
screenStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_REGISTER_DISPLAY_MANAGER_AGENT),
parcel, reply, option);
screenStub->OnRemoteRequest(
static_cast<uint32_t>(
Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_UNREGISTER_DISPLAY_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_SCREEN_SESSION_MANAGER_STUB_AGENT_FUZZER_H
#define TEST_FUZZTEST_SCREEN_SESSION_MANAGER_STUB_AGENT_FUZZER_H
#define FUZZ_PROJECT_NAME "screensessionmgrstubagent_fuzzer"
#endif

View File

@ -0,0 +1,64 @@
# 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("ScreenSessionMgrStubStateFuzzTest") {
fuzz_config_file = "."
module_out_path = module_output_path
include_dirs = [
"${window_base_path}/window_scene/session_manager/include",
"${window_base_path}/wmserver/include",
"../",
]
cflags = [
"-g",
"-O0",
"-fno-omit-frame-pointer",
]
sources = [ "screensessionmgrstubstate_fuzzer.cpp" ]
deps = [
"${window_base_path}/dm:libdm",
"${window_base_path}/utils:libwmutil",
"${window_base_path}/window_scene/common:window_scene_common",
"${window_base_path}/window_scene/session_manager:screen_session_manager",
"${window_base_path}/window_scene/session_manager:session_manager",
]
external_deps = [
"ability_base:session_info",
"ability_base:want",
"ability_runtime:ability_manager",
"ability_runtime:mission_info",
"c_utils:utils",
"ffrt:libffrt",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_single",
"samgr:samgr_proxy",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
}
###############################################################################

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,74 @@
/*
* 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 <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 "display_manager_interface.h"
#include "screen_session_manager_stub.h"
#include "screensessionmgrstubstate_fuzzer.h"
using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
size_t GetObject(T &object, const uint8_t *data, size_t size)
{
size_t objectSize = sizeof(object);
if (objectSize > size) {
return 0;
}
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
}
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(ScreenSessionManagerStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<ScreenSessionManagerStub> screenStub = std::make_shared<ScreenSessionManagerStub>();
screenStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE),
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_SCREEN_SESSION_MANAGER_STUB_STATE_FUZZER_H
#define TEST_FUZZTEST_SCREEN_SESSION_MANAGER_STUB_STATE_FUZZER_H
#define FUZZ_PROJECT_NAME "screensessionmgrstubstate_fuzzer"
#endif

View File

@ -0,0 +1,64 @@
# 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("ScreenSessionMgrStubWakeFuzzTest") {
fuzz_config_file = "."
module_out_path = module_output_path
include_dirs = [
"${window_base_path}/window_scene/session_manager/include",
"${window_base_path}/wmserver/include",
"../",
]
cflags = [
"-g",
"-O0",
"-fno-omit-frame-pointer",
]
sources = [ "screensessionmgrstubwakeup_fuzzer.cpp" ]
deps = [
"${window_base_path}/dm:libdm",
"${window_base_path}/utils:libwmutil",
"${window_base_path}/window_scene/common:window_scene_common",
"${window_base_path}/window_scene/session_manager:screen_session_manager",
"${window_base_path}/window_scene/session_manager:session_manager",
]
external_deps = [
"ability_base:session_info",
"ability_base:want",
"ability_runtime:ability_manager",
"ability_runtime:mission_info",
"c_utils:utils",
"ffrt:libffrt",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_single",
"samgr:samgr_proxy",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
}
###############################################################################

View File

@ -0,0 +1,14 @@
# Copyright (c) 20224 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,77 @@
/*
* 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 <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 "display_manager_interface.h"
#include "screen_session_manager_stub.h"
#include "screensessionmgrstubwakeup_fuzzer.h"
using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
size_t GetObject(T &object, const uint8_t *data, size_t size)
{
size_t objectSize = sizeof(object);
if (objectSize > size) {
return 0;
}
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
}
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(ScreenSessionManagerStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<ScreenSessionManagerStub> screenStub = std::make_shared<ScreenSessionManagerStub>();
screenStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN),
parcel, reply, option);
screenStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IDisplayManager::DisplayManagerMessage::TRANS_ID_WAKE_UP_END),
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_SCREEN_SESSION_MANAGER_STUB_WAKEUP_FUZZER_H
#define TEST_FUZZTEST_SCREEN_SESSION_MANAGER_STUB_WAKEUP_FUZZER_H
#define FUZZ_PROJECT_NAME "screensessionmgrstubwakeup_fuzzer"
#endif

View File

@ -20,6 +20,11 @@ group("fuzztest") {
"windowagent_fuzzer:fuzztest",
"windowipc_fuzzer:fuzztest",
"windowmanager_fuzzer:fuzztest",
"windowmanageragentstubbar_fuzzer:fuzztest",
"windowmanageragentstubfoucs_fuzzer:fuzztest",
"windowmanageragentstubstate_fuzzer:fuzztest",
"windowmanageragentstubstatus_fuzzer:fuzztest",
"windowmanageragentstubtype_fuzzer:fuzztest",
"windowscene_fuzzer:fuzztest",
"windowutilmath_fuzzer:fuzztest",
]

View File

@ -0,0 +1,71 @@
# 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("WindowManagerAgentStubBarFuzzTest") {
fuzz_config_file = "."
module_out_path = module_output_path
include_dirs = [
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
configs = [
"../..:configs_cc_ld",
"../../../../resources/config/build:coverage_flags",
"../../../../resources/config/build:testcase_flags",
]
sources = [ "windowmanageragentstubbar_fuzzer.cpp" ]
deps = [
"../../../..//utils:libwmutil",
"../../../..//wm:libwm",
]
external_deps = [
"c_utils:utils",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_single",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
}
###############################################################################

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,72 @@
/*
* 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 <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 "window_manager_agent.h"
#include "windowmanageragentstubbar_fuzzer.h"
using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
size_t GetObject(T &object, const uint8_t *data, size_t size)
{
size_t objectSize = sizeof(object);
if (objectSize > size) {
return 0;
}
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
}
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(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_SYSTEM_BAR_PROPS),
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_WINDOW_MANAGER_AGENT_STUB_BAR_FUZZER_H
#define TEST_FUZZTEST_WINDOW_MANAGER_AGENT_STUB_BAR_FUZZER_H
#define FUZZ_PROJECT_NAME "windowmanageragentstubbar_fuzzer"
#endif

View File

@ -0,0 +1,71 @@
# 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("WindowManagerAgentStubFoucsFuzzTest") {
fuzz_config_file = "."
module_out_path = module_output_path
include_dirs = [
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
configs = [
"../..:configs_cc_ld",
"../../../../resources/config/build:coverage_flags",
"../../../../resources/config/build:testcase_flags",
]
sources = [ "windowmanageragentstubfoucs_fuzzer.cpp" ]
deps = [
"../../../..//utils:libwmutil",
"../../../..//wm:libwm",
]
external_deps = [
"c_utils:utils",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_single",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
}
###############################################################################

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,72 @@
/*
* 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 <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 "window_manager_agent.h"
#include "windowmanageragentstubfoucs_fuzzer.h"
using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
size_t GetObject(T &object, const uint8_t *data, size_t size)
{
size_t objectSize = sizeof(object);
if (objectSize > size) {
return 0;
}
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
}
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(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_FOCUS),
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_WINDOW_MANAGER_AGENT_STUB_FOUCS_FUZZER_H
#define TEST_FUZZTEST_WINDOW_MANAGER_AGENT_STUB_FOUCS_FUZZER_H
#define FUZZ_PROJECT_NAME "windowmanageragentstubfoucs_fuzzer"
#endif

View File

@ -0,0 +1,71 @@
# 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("WindowManagerAgentStubStateFuzzTest") {
fuzz_config_file = "."
module_out_path = module_output_path
include_dirs = [
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
configs = [
"../..:configs_cc_ld",
"../../../../resources/config/build:coverage_flags",
"../../../../resources/config/build:testcase_flags",
]
sources = [ "windowmanageragentstubstate_fuzzer.cpp" ]
deps = [
"../../../..//utils:libwmutil",
"../../../..//wm:libwm",
]
external_deps = [
"c_utils:utils",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_single",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
}
###############################################################################

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,72 @@
/*
* 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 <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 "window_manager_agent.h"
#include "windowmanageragentstubstate_fuzzer.h"
using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
size_t GetObject(T &object, const uint8_t *data, size_t size)
{
size_t objectSize = sizeof(object);
if (objectSize > size) {
return 0;
}
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
}
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(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_DRAWING_STATE),
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_WINDOW_MANAGER_AGENT_STUB_STATE_FUZZER_H
#define TEST_FUZZTEST_WINDOW_MANAGER_AGENT_STUB_STATE_FUZZER_H
#define FUZZ_PROJECT_NAME "windowmanageragentstubstate_fuzzer"
#endif

View File

@ -0,0 +1,71 @@
# 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("WindowManagerAgentStubStatusFuzzTest") {
fuzz_config_file = "."
module_out_path = module_output_path
include_dirs = [
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
configs = [
"../..:configs_cc_ld",
"../../../../resources/config/build:coverage_flags",
"../../../../resources/config/build:testcase_flags",
]
sources = [ "windowmanageragentstubstatus_fuzzer.cpp" ]
deps = [
"../../../..//utils:libwmutil",
"../../../..//wm:libwm",
]
external_deps = [
"c_utils:utils",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_single",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
}
###############################################################################

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,72 @@
/*
* 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 <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 "window_manager_agent.h"
#include "windowmanageragentstubstatus_fuzzer.h"
using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
size_t GetObject(T &object, const uint8_t *data, size_t size)
{
size_t objectSize = sizeof(object);
if (objectSize > size) {
return 0;
}
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
}
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(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_STATUS),
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_WINDOW_MANAGER_AGENT_STUB_STATUS_FUZZER_H
#define TEST_FUZZTEST_WINDOW_MANAGER_AGENT_STUB_STATUS_FUZZER_H
#define FUZZ_PROJECT_NAME "windowmanageragentstubstatus_fuzzer"
#endif

View File

@ -0,0 +1,71 @@
# 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("WindowManagerAgentStubTypeFuzzTest") {
fuzz_config_file = "."
module_out_path = module_output_path
include_dirs = [
"../../../../utils/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/include",
"../../../../window_scene",
"../../../../window_scene/interfaces/include",
"../../../../window_scene/session_manager/include",
"../../../../window_scene/session_manager/include/zidl",
"../../../../window_scene/session_manager_service/include",
"../../../../wmserver/include",
"../../../../wmserver/include/zidl",
"../../../../utils/include",
"../../../../dm/include",
"../../../../interfaces/innerkits/wm",
"../../../../interfaces/innerkits/dm",
"../../../../dmserver/include",
"../../../../window_scene/screen_session_manager/include",
"../../../../wm/include",
"../../../../wm/include/zidl",
]
configs = [
"../..:configs_cc_ld",
"../../../../resources/config/build:coverage_flags",
"../../../../resources/config/build:testcase_flags",
]
sources = [ "windowmanageragentstubtype_fuzzer.cpp" ]
deps = [
"../../../..//utils:libwmutil",
"../../../..//wm:libwm",
]
external_deps = [
"c_utils:utils",
"graphic_2d:librender_service_client",
"hilog:libhilog",
"image_framework:image_native",
"ipc:ipc_single",
]
}
###############################################################################
group("fuzztest") {
testonly = true
deps = []
}
###############################################################################

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,72 @@
/*
* 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 <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 "window_manager_agent.h"
#include "windowmanageragentstubtype_fuzzer.h"
using namespace OHOS::Rosen;
namespace OHOS {
namespace {
constexpr size_t DATA_MIN_SIZE = 2;
}
template<class T>
size_t GetObject(T &object, const uint8_t *data, size_t size)
{
size_t objectSize = sizeof(object);
if (objectSize > size) {
return 0;
}
return memcpy_s(&object, objectSize, data, objectSize) == EOK ? objectSize : 0;
}
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(Rosen::WindowManagerAgentStub::GetDescriptor());
parcel.WriteBuffer(data, size);
parcel.RewindRead(0);
std::shared_ptr<WindowManagerAgent> wmStub = std::make_shared<WindowManagerAgent>();
wmStub->OnRemoteRequest(
static_cast<uint32_t>(Rosen::IWindowManagerAgent::WindowManagerAgentMsg::TRANS_ID_UPDATE_WINDOW_MODE_TYPE),
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_WINDOW_MANAGER_AGENT_STUB_TYPE_FUZZER_H
#define TEST_FUZZTEST_WINDOW_MANAGER_AGENT_STUB_TYPE_FUZZER_H
#define FUZZ_PROJECT_NAME "windowmanageragentstubtype_fuzzer"
#endif