Fix Abs path validation on Windows (#124084)
* Windows: Consider slash-prefixed paths as absolute filepath.IsAbs does not consider "/" or "\" as absolute paths, even though files can be addressed as such. [1][2] Currently, there are some unit tests that are failing on Windows due to this reason. [1] https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats#traditional-dos-paths [2] https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#fully-qualified-vs-relative-paths * Add test to verify IsAbs for windows Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com> * Fix abs path validation on windows Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com> * Skipp path clean check for podLogDir on windows Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com> * Implement IsPathClean to validate path Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com> * Add warn comment for IsAbs Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com> --------- Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com> Co-authored-by: Claudiu Belu <cbelu@cloudbasesolutions.com>
This commit is contained in:
@@ -22,6 +22,7 @@ package filesystem
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// IsUnixDomainSocket returns whether a given file is a AF_UNIX socket file
|
||||
@@ -35,3 +36,8 @@ func IsUnixDomainSocket(filePath string) (bool, error) {
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// IsAbs is same as filepath.IsAbs on Unix.
|
||||
func IsAbs(path string) bool {
|
||||
return filepath.IsAbs(path)
|
||||
}
|
||||
|
Reference in New Issue
Block a user