MCPcopy Create free account
hub / github.com/Snapchat/Valdi / resolveAbsolutePath

Method resolveAbsolutePath

valdi/src/valdi/runtime/Resources/DiskCacheImpl.cpp:107–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107Result<Path> DiskCacheImpl::resolveAbsolutePath(const Path& path, bool isRead) const {
108 auto newPath = !path.isAbsolute() ? _rootPath.appending(path) : path;
109 newPath.normalize();
110
111 const auto& pathToCheck = isRead ? _allowedReadPath : _rootPath;
112
113 if (!newPath.startsWith(pathToCheck)) {
114 return Error(STRING_FORMAT(
115 "Resolved path '{}' is outside of allowed path '{}'", newPath.toString(), pathToCheck.toString()));
116 }
117
118 return newPath;
119}
120
121std::vector<Path> DiskCacheImpl::list(const Path& path) const {
122 return DiskUtils::listDirectory(path);

Callers

nothing calls this directly

Calls 6

isAbsoluteMethod · 0.80
startsWithMethod · 0.80
toStringMethod · 0.65
ErrorInterface · 0.50
appendingMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected