fix(fxconfig/validation): treat ".." only as a path component, not as…#225
Conversation
… a substring Signed-off-by: abhayrajjais01 <abhayraj916146@gmail.com>
|
What was wrong? Those checks tried to block path traversal (paths that sneak “upward” using They did it in a clumsy way: “if the path string contains two dots ( Why is that bad? A backup folder named What does the PR fix? |
Type of change
Description
OSFileCheckerandOSDirectoryCheckerrejected any cleaned path containing the substring"..", which blocked valid paths whose file or directory names include two dots (for example names likefoo..backuporconfig..yaml), not actual traversalChange: Replace the substring check with a rule that only treats leading
..segments (whole path".."or prefix".." + filepath.Separator) as traversal, consistent with paths left byfilepath.CleanTests: Extended
tools/fxconfig/internal/validation/validator_test.gowith cases for benign..-in-name paths, regressions (..,../…), and internal..segments thatCleancollapsesAdditional details (Optional)
Suggested checks:
go test -race ./tools/fxconfig/internal/validation/...(or
go test -race ./tools/fxconfig/...including integration tests if you prefer a full sweep)