diff --git a/interfaces/common/include/sandbox_helper.h b/interfaces/common/include/sandbox_helper.h index ce5fcefd6abcae4314a8c39a586259584660c87a..fcb4112f38a323cc4cc61ba380f37c1e12ec2252 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 1f8f50410c7bbeebf2718b2df408b00983d10b69..23065c8e664a7435b4a4455ed02151daa2044823 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();