isPathAllowed static method
Validates that a path is within allowed project roots.
Implementation
static bool isPathAllowed(
String targetPath, List<String> allowedRoots, List<String> globalCachePaths) {
final resolved = PathUtils.resolveAbsolute(targetPath);
if (resolved == null) return false;
// Check if it's a global cache path
for (final globalPath in globalCachePaths) {
final resolvedGlobal = PathUtils.resolveAbsolute(globalPath);
if (resolvedGlobal != null && PathUtils.isWithin(resolved, resolvedGlobal)) {
return true;
}
}
// Check if it's within any allowed project root
for (final root in allowedRoots) {
final resolvedRoot = PathUtils.resolveAbsolute(root);
if (resolvedRoot != null && PathUtils.isWithin(resolved, resolvedRoot)) {
return true;
}
}
return false;
}