mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-26 04:20:02 +00:00
feat: improve S3 restore path handling and validation state
- Add path attribute mutator to S3Storage model ensuring paths start with / - Add updatedS3Path hook to normalize path and reset validation state on blur - Add updatedS3StorageId hook to reset validation state when storage changes - Add Enter key support to trigger file check from path input - Use wire:model.live for S3 storage select, wire:model.blur for path input - Improve shell escaping in restore job cleanup commands - Fix isSafeTmpPath helper logic for directory validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3250,18 +3250,16 @@ function isSafeTmpPath(?string $path): bool
|
||||
$dirPath = dirname($resolvedPath);
|
||||
|
||||
// If the directory exists, resolve it via realpath to catch symlink attacks
|
||||
if (file_exists($resolvedPath) || is_dir($dirPath)) {
|
||||
if (is_dir($dirPath)) {
|
||||
// For existing paths, resolve to absolute path to catch symlinks
|
||||
if (is_dir($dirPath)) {
|
||||
$realDir = realpath($dirPath);
|
||||
if ($realDir === false) {
|
||||
return false;
|
||||
}
|
||||
$realDir = realpath($dirPath);
|
||||
if ($realDir === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if the real directory is within /tmp (or its canonical path)
|
||||
if (! str($realDir)->startsWith('/tmp') && ! str($realDir)->startsWith($canonicalTmpPath)) {
|
||||
return false;
|
||||
}
|
||||
// Check if the real directory is within /tmp (or its canonical path)
|
||||
if (! str($realDir)->startsWith('/tmp') && ! str($realDir)->startsWith($canonicalTmpPath)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user