24#include <system_error>
34inline std::optional<std::filesystem::path>
36 namespace fs = std::filesystem;
37 if (path.empty() || root.empty())
40 const fs::path canonical_root = fs::weakly_canonical(root, ec);
41 if (ec || canonical_root.empty())
43 const fs::path joined = path.is_absolute() ? path : canonical_root / path;
44 const fs::path canonical = fs::weakly_canonical(joined, ec);
45 if (ec || canonical.empty())
Definition analyzer_provider.hpp:12
std::optional< std::filesystem::path > confine_restored_path(const std::filesystem::path &path, const std::filesystem::path &root)
Resolve a path restored from state against the directory the plugin is allowed to read from.
Definition restored_path.hpp:35
bool is_within_directory(const std::filesystem::path &directory, const std::filesystem::path &candidate)
True if candidate, compared lexically after normalization, is directory itself or lies beneath it.
Definition safe_relative_path.hpp:43
Screening for untrusted relative paths that will be joined beneath a destination directory: archive e...