diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn
index 49bed1ad8e626485de8fc506cedb90b06efeeaec..80190ea050e1aa5f3567ce855e75303618233b9c 100644
--- a/test/fuzztest/BUILD.gn
+++ b/test/fuzztest/BUILD.gn
@@ -22,6 +22,7 @@ group("fuzztest") {
"fileshare_fuzzer:FileShareFuzzTest",
"remotefileshare_fuzzer:RemoteFileShareFuzzTest",
"servicereverse_fuzzer:ServiceReverseFuzzTest",
+ "svcextensionproxy_fuzzer:SvcExtensionProxyFuzzTest",
"svcrestoredepsmanager_fuzzer:SvcRestoreDepsManagerFuzzTest",
]
}
diff --git a/test/fuzztest/svcextensionproxy_fuzzer/BUILD.gn b/test/fuzztest/svcextensionproxy_fuzzer/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..196111fda125bdce60cfe596d3e919946781cdc5
--- /dev/null
+++ b/test/fuzztest/svcextensionproxy_fuzzer/BUILD.gn
@@ -0,0 +1,61 @@
+# Copyright (c) 2021-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.
+
+#####################hydra-fuzz###################
+import("//build/config/features.gni")
+import("//build/test.gni")
+import("//foundation/filemanagement/app_file_service/app_file_service.gni")
+import("//foundation/filemanagement/app_file_service/backup.gni")
+
+##############################fuzztest##########################################
+ohos_fuzztest("SvcExtensionProxyFuzzTest") {
+ module_out_path = "app_file_service/app_file_service"
+ fuzz_config_file =
+ "${app_file_service_path}/test/fuzztest/svcextensionproxy_fuzzer"
+ include_dirs = [
+ "${path_backup}/interfaces/inner_api/native/backup_kit_inner/impl",
+ "${path_backup}/services/backup_sa/include",
+ "${path_backup}/tests/unittests/backup_api/backup_impl/include",
+ "${path_backup_mock}/module_ipc/app_gallery_dispose_proxy_mock.cpp",
+ ]
+ cflags = [
+ "-g",
+ "-O0",
+ "-Wno-unused-variable",
+ "-fno-omit-frame-pointer",
+ ]
+
+ sources = [
+ "$path_backup_mock/module_ipc/svc_extension_proxy_mock.cpp",
+ "svcextensionproxy_fuzzer.cpp",
+ ]
+
+ deps = [
+ "${path_backup}/utils:backup_utils",
+ "${path_backup}/tests/utils:backup_test_utils",
+ "//third_party/googletest:gmock_main",
+ ]
+
+ external_deps = [
+ "c_utils:utils",
+ "ipc:ipc_core",
+ ]
+
+ defines = [
+ "LOG_TAG=\"app_file_service\"",
+ "LOG_DOMAIN=0xD200000",
+ ]
+}
+
+###############################################################################
+
diff --git a/test/fuzztest/svcextensionproxy_fuzzer/corpus/init b/test/fuzztest/svcextensionproxy_fuzzer/corpus/init
new file mode 100644
index 0000000000000000000000000000000000000000..6198079a28e860189d4294f6598f8ac6804c0dff
--- /dev/null
+++ b/test/fuzztest/svcextensionproxy_fuzzer/corpus/init
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/svcextensionproxy_fuzzer/project.xml b/test/fuzztest/svcextensionproxy_fuzzer/project.xml
new file mode 100644
index 0000000000000000000000000000000000000000..7133b2b92440904a5ed04b838733acea0f97486a
--- /dev/null
+++ b/test/fuzztest/svcextensionproxy_fuzzer/project.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ 1000
+
+ 300
+
+ 4096
+
+
diff --git a/test/fuzztest/svcextensionproxy_fuzzer/svcextensionproxy_fuzzer.cpp b/test/fuzztest/svcextensionproxy_fuzzer/svcextensionproxy_fuzzer.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..83af9cdfbac9495e47524d1c6cbb167bac74d24d
--- /dev/null
+++ b/test/fuzztest/svcextensionproxy_fuzzer/svcextensionproxy_fuzzer.cpp
@@ -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 "svcextensionproxy_fuzzer.h"
+
+#include
+#include
+#include
+
+#include "ext_extension_mock.h"
+#include "module_ipc/svc_extension_proxy.h"
+#include "unique_fd.h"
+
+using namespace OHOS::FileManagement::Backup;
+using namespace std;
+
+namespace OHOS {
+bool SvcExtensionProxyFuzzTest(const uint8_t *data, size_t size)
+{
+ if ((data == nullptr) || (size < sizeof(int))) {
+ return false;
+ }
+
+ sptr mock_ = sptr(new BackupExtExtensionMock());
+ sptr proxy_ = sptr(new SvcExtensionProxy(mock_));
+ std::string fileName((const char *)data, size);
+
+ proxy_->GetFileHandle(fileName);
+ proxy_->HandleClear();
+ proxy_->HandleBackup();
+ proxy_->PublishFile(fileName);
+ proxy_->HandleRestore();
+ proxy_->GetIncrementalFileHandle(fileName);
+ proxy_->PublishIncrementalFile(fileName);
+
+ int incrementalId = -1;
+ int manifestId = -1;
+
+ if (size >= sizeof(int)) {
+ incrementalId = *(reinterpret_cast(data));
+ manifestId = incrementalId;
+ }
+
+ if (size >= sizeof(int) + sizeof(int)) {
+ manifestId = *(reinterpret_cast(data + sizeof(int)));
+ }
+
+ UniqueFd incrementalFd(incrementalId);
+ UniqueFd manifestFd(manifestId);
+ proxy_->HandleIncrementalBackup(move(incrementalFd), move(manifestFd));
+ proxy_->GetIncrementalBackupFileHandle();
+ return true;
+}
+}// namespace OHOS
+
+/* Fuzzer entry point */
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+ /* Run your code on data */
+ if (data == nullptr) {
+ return 0;
+ }
+
+ OHOS::SvcExtensionProxyFuzzTest(data, size);
+ return 0;
+}
\ No newline at end of file
diff --git a/test/fuzztest/svcextensionproxy_fuzzer/svcextensionproxy_fuzzer.h b/test/fuzztest/svcextensionproxy_fuzzer/svcextensionproxy_fuzzer.h
new file mode 100644
index 0000000000000000000000000000000000000000..6146814186dbd93163666bec496f453e753b090b
--- /dev/null
+++ b/test/fuzztest/svcextensionproxy_fuzzer/svcextensionproxy_fuzzer.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2024 Huawei Device Co., Ltd.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SVCEXTENSIONPROXY_FUZZER_H
+#define SVCEXTENSIONPROXY_FUZZER_H
+
+#define FUZZ_PROJECT_NAME "svcextensionproxy_fuzzer"
+
+#endif
\ No newline at end of file