From 1a78adf71f64de71de8411e23a7bc0cb2630901a Mon Sep 17 00:00:00 2001 From: cuiruibin Date: Wed, 9 Jul 2025 17:44:54 +0800 Subject: [PATCH] =?UTF-8?q?inner=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=20Signed-off-by:=20cuiruibin=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interfaces/common/include/sandbox_helper.h | 10 ++++++++++ .../innerkits/native/file_uri/include/file_uri.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/interfaces/common/include/sandbox_helper.h b/interfaces/common/include/sandbox_helper.h index ce5fcefd6..fcb4112f3 100644 --- a/interfaces/common/include/sandbox_helper.h +++ b/interfaces/common/include/sandbox_helper.h @@ -32,15 +32,25 @@ private: static void* libMediaHandle_; public: static std::string Encode(const std::string &uri); + // 接口功能:生成fileUri,字符串中的特殊字符进行编码处理。 static std::string Decode(const std::string &uri); + // 接口功能:fileUri转沙箱路径时,对字符串中的字符进行解码处理,解码规则对应上述Encode编码规则。 static bool CheckValidPath(const std::string &filePath); + // 接口功能:对传入的路径进行realpath操作,判断其中间是否存在穿越或者其他场景的风险。 static int32_t GetMediaSharePath(const std::vector &fileUris, std::vector &physicalPaths); + // 接口功能:应用跨进程访问业务,媒体类型fileUri转沙箱外路径。 + // 接口范围:仅作为应用跨进程访问时,文件动态挂载使用,目前转换结果为媒体库查库所得,存在IPC操作。 static int32_t GetPhysicalPath(const std::string &fileUri, const std::string &userId, std::string &physicalPath); + // 接口功能:应用跨进程访问业务,fileUri转沙箱外路径。 + // 接口范围:仅作为应用跨进程访问时,文件动态挂载使用,目前按照当前业务规格仅支持部分路径转换,且转换结果为本业务所需路径。 static int32_t GetPhysicalDir(const std::string &fileUri, const std::string &userId, std::string &physicalDir); static int32_t GetBackupPhysicalPath(const std::string &fileUri, const std::string &userId, std::string &physicalPath); + // 接口功能:备份恢复业务,fileUri转沙箱外路径。 + // 接口范围:仅作为备份恢复业务使用,目前支持的可转换路径均为备份恢复业务范围内的路径。 static bool IsValidPath(const std::string &path); + // 接口功能:仅校验存在路径穿越风险的../或/..的字符串。 static void GetNetworkIdFromUri(const std::string &fileUri, std::string &networkId); static std::string GetLowerDir(std::string &lowerPathHead, const std::string &userId, const std::string &bundleName, const std::string &networkId); diff --git a/interfaces/innerkits/native/file_uri/include/file_uri.h b/interfaces/innerkits/native/file_uri/include/file_uri.h index 1f8f50410..23065c8e6 100644 --- a/interfaces/innerkits/native/file_uri/include/file_uri.h +++ b/interfaces/innerkits/native/file_uri/include/file_uri.h @@ -27,7 +27,11 @@ public: std::string GetName(); std::string GetPath(); std::string GetRealPathBySA(const std::string &targetBundleName = ""); + // 接口功能:fileUri转沙箱路径,根据当前应用跨进程访问的挂载方案,进行对应的字符串转换; + // 接口范围:仅供UPMS模块进行临时授权fileUri转path使用。 std::string GetRealPath(); + // 接口功能:fileUri转沙箱路径,根据当前应用跨进程访问的挂载方案,进行对应的字符串转换。 + // 接口范围:不涉及校验及文件相关操作。仅支持业务范围内的规则转换,超范围的入参仅按照规则转换不保证可用。 std::string ToString(); std::string GetFullDirectoryUri(); bool IsRemoteUri(); -- Gitee