1# Copyright (c) 2022-2024 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14#####################hydra-fuzz################### 15import("//build/config/features.gni") 16import("//build/test.gni") 17import("//foundation/communication/netmanager_ext/netmanager_ext_config.gni") 18##############################fuzztest########################################## 19EXT_SECURITY_PATH = "../../.." 20 21ohos_fuzztest("NetShareClientFuzzTest") { 22 module_out_path = fuzz_test_path 23 fuzz_config_file = "$NETMANAGER_EXT_ROOT/test/networksharemanager/fuzztest/netshareclient_fuzzer" 24 _cfi_blocklist_path = "$NETMANAGER_EXT_ROOT/test/networksharemanager/fuzztest/netshareclient_fuzzer/cfi_blocklist.txt" 25 26 include_dirs = [ 27 "$EXT_INNERKITS_ROOT/ethernetclient/include", 28 "$EXT_INNERKITS_ROOT/netshareclient/include", 29 "$EXT_INNERKITS_ROOT/netshareclient/include/proxy", 30 "$EXT_INNERKITS_ROOT/netshareclient/include/proxy/ipccallback", 31 "$EXT_INNERKITS_ROOT/include", 32 "$EXT_INNERKITS_ROOT/include/proxy", 33 "$EXT_SECURITY_PATH/security", 34 "$NETMANAGER_EXT_ROOT/utils/log/include", 35 "$NETWORKSHAREMANAGER_SOURCE_DIR/include", 36 "$NETWORKSHAREMANAGER_SOURCE_DIR/include/stub", 37 "$NETWORKSHAREMANAGER_UTILS_DIR/event_report/include", 38 "$NETSYSCONTROLLER_ROOT_DIR/include", 39 ] 40 41 if (communication_wifi_switch_enable) { 42 include_dirs += [ 43 "$WIFI_MANAGER_ROOT/interfaces/kits/c", 44 "$WIFI_MANAGER_ROOT/frameworks/native/interfaces", 45 ] 46 } 47 48 cflags = [ 49 "-g", 50 "-O0", 51 "-Wno-unused-variable", 52 "-fno-omit-frame-pointer", 53 ] 54 55 if (!(use_libfuzzer || use_clang_coverage)) { 56 cflags += [ 57 "-flto", 58 "-fsanitize=cfi", 59 "-fsanitize-cfi-cross-dso", 60 "-fvisibility=hidden", 61 "-fsanitize-blacklist=" + 62 rebase_path(_cfi_blocklist_path, root_build_dir), 63 ] 64 } 65 66 ldflags = [] 67 if (!(use_libfuzzer || use_clang_coverage)) { 68 ldflags += [ 69 "-flto", 70 "-fsanitize=cfi", 71 "-fsanitize-cfi-cross-dso", 72 ] 73 } 74 75 sources = [ 76 "$EXT_SECURITY_PATH/security/netmanager_ext_test_security.cpp", 77 "netshare_client_fuzzer.cpp", 78 ] 79 80 deps = [ 81 "$BASE_INNERKITS_ROOT/netconnclient:net_conn_manager_if", 82 "$BLUETOOTH_ROOT/frameworks/inner:btframework", 83 "$NETMANAGER_BASE_ROOT/utils:net_manager_common", 84 "$NETMANAGER_EXT_ROOT/services/networksharemanager:net_tether_manager_static", 85 "$NETSYSCONTROLLER_ROOT_DIR:netsys_controller", 86 ] 87 88 external_deps = [ 89 "access_token:libaccesstoken_sdk", 90 "access_token:libnativetoken", 91 "access_token:libtoken_setproc", 92 "c_utils:utils", 93 "dhcp:dhcp_sdk", 94 "ffrt:libffrt", 95 "hilog:libhilog", 96 "ipc:ipc_core", 97 "safwk:system_ability_fwk", 98 ] 99 100 defines = [] 101 102 if (communication_wifi_switch_enable) { 103 defines += [ "WIFI_MODOULE" ] 104 external_deps += [ "wifi:wifi_sdk" ] 105 } 106 107 defines += [ 108 "NETMGR_LOG_TAG = \"NetShareManager\"", 109 "LOG_DOMAIN = 0xD0015B0", 110 ] 111 112 if (communication_bluetooth_switch_enable) { 113 defines += [ "BLUETOOTH_MODOULE=1" ] 114 external_deps += [ "bluetooth:btframework" ] 115 } 116} 117 118############################################################################### 119group("fuzztest") { 120 testonly = true 121 122 deps = [ ":NetShareClientFuzzTest" ] 123} 124############################################################################### 125