|
26 | 26 |
|
27 | 27 | #include "sagemaker_server.h" |
28 | 28 |
|
| 29 | +#include <filesystem> |
| 30 | + |
29 | 31 | namespace triton { namespace server { |
30 | 32 |
|
31 | 33 | #define HTTP_RESPOND_IF_ERR(REQ, X) \ |
@@ -292,8 +294,12 @@ SagemakerAPIServer::ParseSageMakerRequest( |
292 | 294 | } |
293 | 295 | } |
294 | 296 |
|
295 | | - if (url_string.find("/dev/") == 0 || url_string.find("/proc/") == 0 || |
296 | | - url_string.find("/sys/") == 0) { |
| 297 | + std::filesystem::path url_path(url_string); |
| 298 | + url_path = std::filesystem::absolute(url_path.lexically_normal()); // Normalize the path to remove any redundant components. |
| 299 | + auto repo_path = url_path.string(); |
| 300 | + |
| 301 | + if (repo_path.find("/dev/") == 0 || repo_path.find("/proc/") == 0 |
| 302 | + || repo_path.find("/sys/") == 0) { |
297 | 303 | LOG_ERROR << "Invalid URL: " << url_string |
298 | 304 | << ". \"url\" property value cannot start with /dev/, /proc/, or " |
299 | 305 | "/sys/." << std::endl; |
@@ -901,13 +907,17 @@ SagemakerAPIServer::SageMakerMMELoadModel( |
901 | 907 | evhtp_request_t* req, |
902 | 908 | const std::unordered_map<std::string, std::string> parse_map) |
903 | 909 | { |
904 | | - std::string repo_path = parse_map.at("url"); |
| 910 | + std::string url_string = parse_map.at("url"); |
905 | 911 | std::string model_name_hash = parse_map.at("model_name_hash"); |
906 | 912 | std::string target_model = parse_map.at("target_model"); |
907 | 913 |
|
908 | | - if (repo_path.find("/dev/") == 0 || repo_path.find("/proc/") == 0 || |
909 | | - repo_path.find("/sys/") == 0) { |
910 | | - LOG_ERROR << "Invalid repository path: " << repo_path |
| 914 | + std::filesystem::path url_path(url_string); |
| 915 | + url_path = std::filesystem::absolute(url_path.lexically_normal()); // Normalize the path to remove any redundant components. |
| 916 | + std::string repo_path = url_path.string(); |
| 917 | + |
| 918 | + if (repo_path.find("/dev/") == 0 || repo_path.find("/proc/") == 0 |
| 919 | + || repo_path.find("/sys/") == 0) { |
| 920 | + LOG_ERROR << "Invalid repository path: " << url_string |
911 | 921 | << ". \"url\" property of `parse_map`cannot start with /dev/, " |
912 | 922 | "/proc/, or /sys/." << std::endl; |
913 | 923 | evhtp_send_reply(req, EVHTP_RES_BADREQ); |
|
0 commit comments