diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index c6c14e7a9d711bd46194679e7e842ddb886cf633..eb1c319f1b4d64b4c23d1d0a4eb76d05a021753a 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -29,6 +29,11 @@ group("fuzztest") { "getnotificationslotnumasbundle_fuzzer:GetNotificationSlotNumAsBundleFuzzTest", "getnotificationslotsforbundle_fuzzer:GetNotificationSlotsForBundleFuzzTest", "notification_fuzzer:NotificationFuzzTest", + "notificationconversationalcontent_fuzzer:NotificationConversationalContentFuzzTest", + "notificationconversationalmessage_fuzzer:NotificationConversationalMessageFuzzTest", + "notificationdonotdisturbdate_fuzzer:NotificationDoNotDisturbDateFuzzTest", + "notificationlongtextcontent_fuzzer:NotificationLongTextContentFuzzTest", + "notificationmultilinecontent_fuzzer:NotificationMultiLineContentFuzzTest", "notificationrequest_fuzzer:NotificationRequestFuzzTest", "publishcontinuoustasknotification_fuzzer:PublishContinuousTaskNotificationFuzzTest", "publishnotification_fuzzer:PublishNotificationFuzzTest", diff --git a/test/fuzztest/notificationconversationalcontent_fuzzer/BUILD.gn b/test/fuzztest/notificationconversationalcontent_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bec34b5e456785c58b2c034350c7206d07c8aa6a --- /dev/null +++ b/test/fuzztest/notificationconversationalcontent_fuzzer/BUILD.gn @@ -0,0 +1,55 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "${component_name}/fuzztest" + +##############################fuzztest########################################## +ohos_fuzztest("NotificationConversationalContentFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "${component_path}/test/fuzztest/notificationconversationalcontent_fuzzer" + + include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "notificationconversationalcontent_fuzzer.cpp" ] + + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${frameworks_module_ans_path}:ans_innerkits", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "multimedia_image_framework:image_native", + "relational_store:native_rdb", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":NotificationConversationalContentFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/notificationconversationalcontent_fuzzer/corpus/init b/test/fuzztest/notificationconversationalcontent_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..1b910144fb1ff33a40a44b1d2a491b1ab05b598b --- /dev/null +++ b/test/fuzztest/notificationconversationalcontent_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/notificationconversationalcontent_fuzzer/notificationconversationalcontent_fuzzer.cpp b/test/fuzztest/notificationconversationalcontent_fuzzer/notificationconversationalcontent_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d843842862f1fcce6b8047aff1617ce29a23c5b4 --- /dev/null +++ b/test/fuzztest/notificationconversationalcontent_fuzzer/notificationconversationalcontent_fuzzer.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2022 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. + */ + +#define private public +#define protected public +#include "notification_conversational_content.h" +#undef private +#undef protected +#include "notificationconversationalcontent_fuzzer.h" + +namespace OHOS { + namespace { + constexpr uint8_t ENABLE = 2; + } + bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) + { + Notification::MessageUser messageUser; + Notification::NotificationConversationalContent NotificationConversationalContent(messageUser); + NotificationConversationalContent.GetMessageUser(); + std::string stringData(data); + NotificationConversationalContent.SetConversationTitle(stringData); + NotificationConversationalContent.GetConversationTitle(); + NotificationConversationalContent.IsConversationGroup(); + bool enabled = *data % ENABLE; + NotificationConversationalContent.SetConversationGroup(enabled); + int64_t timestamp = 1; + NotificationConversationalContent.AddConversationalMessage(stringData, timestamp, messageUser); + Notification::NotificationConversationalContent::MessagePtr message; + NotificationConversationalContent.AddConversationalMessage(message); + NotificationConversationalContent.GetAllConversationalMessages(); + NotificationConversationalContent.Dump(); + Parcel parcel; + NotificationConversationalContent.Marshalling(parcel); + NotificationConversationalContent.Unmarshalling(parcel); + return NotificationConversationalContent.ReadFromParcel(parcel); + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + char *ch = ParseData(data, size); + if (ch != nullptr && size >= GetU32Size()) { + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + } + return 0; +} diff --git a/test/fuzztest/notificationconversationalcontent_fuzzer/notificationconversationalcontent_fuzzer.h b/test/fuzztest/notificationconversationalcontent_fuzzer/notificationconversationalcontent_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..20494fc74176155d9e4a96341e13e7193f50ef49 --- /dev/null +++ b/test/fuzztest/notificationconversationalcontent_fuzzer/notificationconversationalcontent_fuzzer.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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_NOTIFICATIONCONVERSATIONALCONTENT_FUZZER_NOTIFICATIONCONVERSATIONALCONTENT_FUZZER_H +#define TEST_FUZZTEST_NOTIFICATIONCONVERSATIONALCONTENT_FUZZER_NOTIFICATIONCONVERSATIONALCONTENT_FUZZER_H + +#include "fuzz_common_base.h" + +#define FUZZ_PROJECT_NAME "notificationconversationalcontent_fuzzer" + +#endif // TEST_FUZZTEST_NOTIFICATIONCONVERSATIONALCONTENT_FUZZER_NOTIFICATIONCONVERSATIONALCONTENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/notificationconversationalcontent_fuzzer/project.xml b/test/fuzztest/notificationconversationalcontent_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/notificationconversationalcontent_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/notificationconversationalmessage_fuzzer/BUILD.gn b/test/fuzztest/notificationconversationalmessage_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d7bbfd8d8f7728180f2363a05cca80e8f71bc4e4 --- /dev/null +++ b/test/fuzztest/notificationconversationalmessage_fuzzer/BUILD.gn @@ -0,0 +1,55 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "${component_name}/fuzztest" + +##############################fuzztest########################################## +ohos_fuzztest("NotificationConversationalMessageFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "${component_path}/test/fuzztest/notificationconversationalmessage_fuzzer" + + include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "notificationconversationalmessage_fuzzer.cpp" ] + + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${frameworks_module_ans_path}:ans_innerkits", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "multimedia_image_framework:image_native", + "relational_store:native_rdb", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":NotificationConversationalMessageFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/notificationconversationalmessage_fuzzer/corpus/init b/test/fuzztest/notificationconversationalmessage_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..1b910144fb1ff33a40a44b1d2a491b1ab05b598b --- /dev/null +++ b/test/fuzztest/notificationconversationalmessage_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/notificationconversationalmessage_fuzzer/notificationconversationalmessage_fuzzer.cpp b/test/fuzztest/notificationconversationalmessage_fuzzer/notificationconversationalmessage_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bb47d23831d70ff75f18a4d6927fdb9a31fdb21f --- /dev/null +++ b/test/fuzztest/notificationconversationalmessage_fuzzer/notificationconversationalmessage_fuzzer.cpp @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022 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 "notification_conversational_message.h" +#include "notificationconversationalmessage_fuzzer.h" + +namespace OHOS { + bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) + { + std::string stringData(data); + int64_t timestamp = 1; + Notification::MessageUser sender; + Notification::NotificationConversationalMessage notificationConversationalMessage( + stringData, timestamp, sender); + notificationConversationalMessage.GetText(); + notificationConversationalMessage.GetSender(); + notificationConversationalMessage.GetMimeType(); + notificationConversationalMessage.GetUri(); + return notificationConversationalMessage.GetArrivedTime(); + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + char *ch = ParseData(data, size); + if (ch != nullptr && size >= GetU32Size()) { + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + } + return 0; +} diff --git a/test/fuzztest/notificationconversationalmessage_fuzzer/notificationconversationalmessage_fuzzer.h b/test/fuzztest/notificationconversationalmessage_fuzzer/notificationconversationalmessage_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..56abc86accf9c76907289af38a1319134ad24672 --- /dev/null +++ b/test/fuzztest/notificationconversationalmessage_fuzzer/notificationconversationalmessage_fuzzer.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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_NOTIFICATIONCONVERSATIONALMESSAGE_FUZZER_NOTIFICATIONCONVERSATIONALMESSAGE_FUZZER_H +#define TEST_FUZZTEST_NOTIFICATIONCONVERSATIONALMESSAGE_FUZZER_NOTIFICATIONCONVERSATIONALMESSAGE_FUZZER_H + +#include "fuzz_common_base.h" + +#define FUZZ_PROJECT_NAME "notificationconversationalmessage_fuzzer" + +#endif // TEST_FUZZTEST_NOTIFICATIONCONVERSATIONALMESSAGE_FUZZER_NOTIFICATIONCONVERSATIONALMESSAGE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/notificationconversationalmessage_fuzzer/project.xml b/test/fuzztest/notificationconversationalmessage_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/notificationconversationalmessage_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/notificationdonotdisturbdate_fuzzer/BUILD.gn b/test/fuzztest/notificationdonotdisturbdate_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..3e6eb1146d55ba9345ca13d6ce533a98d699dd9d --- /dev/null +++ b/test/fuzztest/notificationdonotdisturbdate_fuzzer/BUILD.gn @@ -0,0 +1,55 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "${component_name}/fuzztest" + +##############################fuzztest########################################## +ohos_fuzztest("NotificationDoNotDisturbDateFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "${component_path}/test/fuzztest/notificationdonotdisturbdate_fuzzer" + + include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "notificationdonotdisturbdate_fuzzer.cpp" ] + + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${frameworks_module_ans_path}:ans_innerkits", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "multimedia_image_framework:image_native", + "relational_store:native_rdb", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":NotificationDoNotDisturbDateFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/notificationdonotdisturbdate_fuzzer/corpus/init b/test/fuzztest/notificationdonotdisturbdate_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..1b910144fb1ff33a40a44b1d2a491b1ab05b598b --- /dev/null +++ b/test/fuzztest/notificationdonotdisturbdate_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/notificationdonotdisturbdate_fuzzer/notificationdonotdisturbdate_fuzzer.cpp b/test/fuzztest/notificationdonotdisturbdate_fuzzer/notificationdonotdisturbdate_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8641146ba7789768d3eb613323a6f2659b8cbb10 --- /dev/null +++ b/test/fuzztest/notificationdonotdisturbdate_fuzzer/notificationdonotdisturbdate_fuzzer.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022 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 "notification_do_not_disturb_date.h" +#include "notificationdonotdisturbdate_fuzzer.h" + +namespace OHOS { + bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) + { + std::string stringData(data); + int64_t beginDate = 1; + int64_t endDate = 3; + uint32_t type = GetU32Data(data); + Notification::NotificationConstant::DoNotDisturbType disturbType = + Notification::NotificationConstant::DoNotDisturbType(type); + Notification::NotificationDoNotDisturbDate notificationDoNotDisturbDate(disturbType, beginDate, endDate); + notificationDoNotDisturbDate.SetDoNotDisturbType(disturbType); + notificationDoNotDisturbDate.GetDoNotDisturbType(); + notificationDoNotDisturbDate.SetBeginDate(beginDate); + notificationDoNotDisturbDate.GetBeginDate(); + notificationDoNotDisturbDate.SetEndDate(endDate); + return notificationDoNotDisturbDate.GetEndDate(); + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + char *ch = ParseData(data, size); + if (ch != nullptr && size >= GetU32Size()) { + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + } + return 0; +} diff --git a/test/fuzztest/notificationdonotdisturbdate_fuzzer/notificationdonotdisturbdate_fuzzer.h b/test/fuzztest/notificationdonotdisturbdate_fuzzer/notificationdonotdisturbdate_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..7d5b711d0dc6850a59215601c98c6a24ffec4bf2 --- /dev/null +++ b/test/fuzztest/notificationdonotdisturbdate_fuzzer/notificationdonotdisturbdate_fuzzer.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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_NOTIFICATIONDONOTDISTURBDATE_FUZZER_NOTIFICATIONDONOTDISTURBDATE_FUZZER_H +#define TEST_FUZZTEST_NOTIFICATIONDONOTDISTURBDATE_FUZZER_NOTIFICATIONDONOTDISTURBDATE_FUZZER_H + +#include "fuzz_common_base.h" + +#define FUZZ_PROJECT_NAME "notificationdonotdisturbdate_fuzzer" + +#endif // TEST_FUZZTEST_NOTIFICATIONDONOTDISTURBDATE_FUZZER_NOTIFICATIONDONOTDISTURBDATE_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/notificationdonotdisturbdate_fuzzer/project.xml b/test/fuzztest/notificationdonotdisturbdate_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/notificationdonotdisturbdate_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/notificationlongtextcontent_fuzzer/BUILD.gn b/test/fuzztest/notificationlongtextcontent_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..355cc5b530dbf7ce4eeebb41f9fefdbba86d1b11 --- /dev/null +++ b/test/fuzztest/notificationlongtextcontent_fuzzer/BUILD.gn @@ -0,0 +1,55 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "${component_name}/fuzztest" + +##############################fuzztest########################################## +ohos_fuzztest("NotificationLongTextContentFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "${component_path}/test/fuzztest/notificationlongtextcontent_fuzzer" + + include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "notificationlongtextcontent_fuzzer.cpp" ] + + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${frameworks_module_ans_path}:ans_innerkits", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "multimedia_image_framework:image_native", + "relational_store:native_rdb", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":NotificationLongTextContentFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/notificationlongtextcontent_fuzzer/corpus/init b/test/fuzztest/notificationlongtextcontent_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..1b910144fb1ff33a40a44b1d2a491b1ab05b598b --- /dev/null +++ b/test/fuzztest/notificationlongtextcontent_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/notificationlongtextcontent_fuzzer/notificationlongtextcontent_fuzzer.cpp b/test/fuzztest/notificationlongtextcontent_fuzzer/notificationlongtextcontent_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e0851d74ad35f34e510e565e5e18c8422248aad0 --- /dev/null +++ b/test/fuzztest/notificationlongtextcontent_fuzzer/notificationlongtextcontent_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 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 "notification_long_text_content.h" +#include "notificationlongtextcontent_fuzzer.h" + +namespace OHOS { + bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) + { + std::string stringData(data); + Notification::NotificationLongTextContent notificationLongTextContent(stringData); + notificationLongTextContent.SetExpandedTitle(stringData); + notificationLongTextContent.GetExpandedTitle(); + notificationLongTextContent.SetBriefText(stringData); + notificationLongTextContent.GetBriefText(); + notificationLongTextContent.SetLongText(stringData); + notificationLongTextContent.GetLongText(); + notificationLongTextContent.Dump(); + Parcel parcel; + return notificationLongTextContent.Marshalling(parcel); + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + char *ch = ParseData(data, size); + if (ch != nullptr && size >= GetU32Size()) { + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + } + return 0; +} diff --git a/test/fuzztest/notificationlongtextcontent_fuzzer/notificationlongtextcontent_fuzzer.h b/test/fuzztest/notificationlongtextcontent_fuzzer/notificationlongtextcontent_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..0e3a0fc037ce7706a7b921b9a3e32da114252757 --- /dev/null +++ b/test/fuzztest/notificationlongtextcontent_fuzzer/notificationlongtextcontent_fuzzer.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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_NOTIFICATIONLONGTEXTCONTENT_FUZZER_NOTIFICATIONLONGTEXTCONTENT_FUZZER_H +#define TEST_FUZZTEST_NOTIFICATIONLONGTEXTCONTENT_FUZZER_NOTIFICATIONLONGTEXTCONTENT_FUZZER_H + +#include "fuzz_common_base.h" + +#define FUZZ_PROJECT_NAME "notificationlongtextcontent_fuzzer" + +#endif // TEST_FUZZTEST_NOTIFICATIONLONGTEXTCONTENT_FUZZER_NOTIFICATIONLONGTEXTCONTENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/notificationlongtextcontent_fuzzer/project.xml b/test/fuzztest/notificationlongtextcontent_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/notificationlongtextcontent_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/notificationmultilinecontent_fuzzer/BUILD.gn b/test/fuzztest/notificationmultilinecontent_fuzzer/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7d7e7199814f5b60c9ff7294ae9d0656cfd0bd46 --- /dev/null +++ b/test/fuzztest/notificationmultilinecontent_fuzzer/BUILD.gn @@ -0,0 +1,55 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//base/notification/distributed_notification_service/notification.gni") +import("//build/config/features.gni") +import("//build/test.gni") +module_output_path = "${component_name}/fuzztest" + +##############################fuzztest########################################## +ohos_fuzztest("NotificationMultiLineContentFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "${component_path}/test/fuzztest/notificationmultilinecontent_fuzzer" + + include_dirs = [ "${component_path}/test/fuzztest/fuzz_common_base" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "notificationmultilinecontent_fuzzer.cpp" ] + + deps = [ + "${component_path}/test/fuzztest/fuzz_common_base:fuzz_common_base", + "${frameworks_module_ans_path}:ans_innerkits", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "c_utils:utils", + "hiviewdfx_hilog_native:libhilog", + "multimedia_image_framework:image_native", + "relational_store:native_rdb", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [ ":NotificationMultiLineContentFuzzTest" ] +} +############################################################################### diff --git a/test/fuzztest/notificationmultilinecontent_fuzzer/corpus/init b/test/fuzztest/notificationmultilinecontent_fuzzer/corpus/init new file mode 100644 index 0000000000000000000000000000000000000000..1b910144fb1ff33a40a44b1d2a491b1ab05b598b --- /dev/null +++ b/test/fuzztest/notificationmultilinecontent_fuzzer/corpus/init @@ -0,0 +1,13 @@ +# Copyright (c) 2022 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/notificationmultilinecontent_fuzzer/notificationmultilinecontent_fuzzer.cpp b/test/fuzztest/notificationmultilinecontent_fuzzer/notificationmultilinecontent_fuzzer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a72016f0828d313d67dd6c1afa24a4fef4f77a2 --- /dev/null +++ b/test/fuzztest/notificationmultilinecontent_fuzzer/notificationmultilinecontent_fuzzer.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2022 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 "notification_multiline_content.h" +#include "notificationmultilinecontent_fuzzer.h" + +namespace OHOS { + bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) + { + std::string stringData(data); + Notification::NotificationMultiLineContent notificationMultiLineContent; + notificationMultiLineContent.SetExpandedTitle(stringData); + notificationMultiLineContent.GetExpandedTitle(); + notificationMultiLineContent.SetBriefText(stringData); + notificationMultiLineContent.GetBriefText(); + notificationMultiLineContent.AddSingleLine(stringData); + notificationMultiLineContent.GetAllLines(); + notificationMultiLineContent.Dump(); + Parcel parcel; + return notificationMultiLineContent.Marshalling(parcel); + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + char *ch = ParseData(data, size); + if (ch != nullptr && size >= GetU32Size()) { + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + } + return 0; +} diff --git a/test/fuzztest/notificationmultilinecontent_fuzzer/notificationmultilinecontent_fuzzer.h b/test/fuzztest/notificationmultilinecontent_fuzzer/notificationmultilinecontent_fuzzer.h new file mode 100644 index 0000000000000000000000000000000000000000..4f808e102c173c29ebd20ad82fc340b0cf52a332 --- /dev/null +++ b/test/fuzztest/notificationmultilinecontent_fuzzer/notificationmultilinecontent_fuzzer.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 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_NOTIFICATIONMULTILINECONTENT_FUZZER_NOTIFICATIONMULTILINECONTENT_FUZZER_H +#define TEST_FUZZTEST_NOTIFICATIONMULTILINECONTENT_FUZZER_NOTIFICATIONMULTILINECONTENT_FUZZER_H + +#include "fuzz_common_base.h" + +#define FUZZ_PROJECT_NAME "notificationmultilinecontent_fuzzer" + +#endif // TEST_FUZZTEST_NOTIFICATIONMULTILINECONTENT_FUZZER_NOTIFICATIONMULTILINECONTENT_FUZZER_H \ No newline at end of file diff --git a/test/fuzztest/notificationmultilinecontent_fuzzer/project.xml b/test/fuzztest/notificationmultilinecontent_fuzzer/project.xml new file mode 100644 index 0000000000000000000000000000000000000000..6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec --- /dev/null +++ b/test/fuzztest/notificationmultilinecontent_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + +