!8383 受限worker环境,确保文件路径是 'abcs/' 开头

Merge pull request !8383 from sodanotgreen/lmz_API12
This commit is contained in:
openharmony_ci
2024-04-29 11:01:04 +00:00
committed by Gitee
+5
View File
@@ -54,6 +54,7 @@ constexpr int32_t API8 = 8;
constexpr int32_t API12 = 12;
const std::string BUNDLE_NAME_FLAG = "@bundle:";
const std::string CACHE_DIRECTORY = "el2";
const std::string RESTRICTED_PREFIX_PATH = "abcs/";
const int PATH_THREE = 3;
#ifdef APP_USE_ARM
constexpr char ARK_DEBUGGER_LIB_PATH[] = "/system/lib/platformsdk/libark_debugger.z.so";
@@ -246,6 +247,10 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf
}
filePath = NormalizedFileName(realPath);
// for safe reason, filePath must starts with 'abcs/' in restricted env
if (isRestricted && filePath.find(RESTRICTED_PREFIX_PATH) && workerInfo_->apiTargetVersion >= API12) {
filePath = RESTRICTED_PREFIX_PATH + filePath;
}
ami = workerInfo_->codePath + filePath;
TAG_LOGD(AAFwkTag::JSRUNTIME, "Get asset, ami: %{private}s", ami.c_str());
if (ami.find(CACHE_DIRECTORY) != std::string::npos) {