From 0a2a86cf47a793dd02a6329b07b754a494e80576 Mon Sep 17 00:00:00 2001 From: baurine <2008.hbl@gmail.com> Date: Mon, 5 Aug 2024 16:31:58 +0800 Subject: [PATCH] fix: fix potenial vulnerability issue --- pkg/dashboard/distroutil/distro.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/dashboard/distroutil/distro.go b/pkg/dashboard/distroutil/distro.go index 9eb1a2eb31b..69086cbe086 100644 --- a/pkg/dashboard/distroutil/distro.go +++ b/pkg/dashboard/distroutil/distro.go @@ -17,6 +17,7 @@ package distroutil import ( "os" "path" + "path/filepath" "github.com/pingcap/log" "github.com/pingcap/tidb-dashboard/util/distro" @@ -36,7 +37,8 @@ func MustGetResPath() string { log.Fatal("failed to read the execution path", zap.Error(err)) return "" } - return path.Join(path.Dir(exePath), resFolderName) + + return filepath.Join(path.Dir(exePath), resFolderName) } // MustLoadAndReplaceStrings loads the distro strings from ${BinaryPath}/distro-res/strings.json @@ -44,7 +46,7 @@ func MustGetResPath() string { // distro string will be used. func MustLoadAndReplaceStrings() { resPath := MustGetResPath() - strings, err := distro.ReadResourceStringsFromFile(path.Join(resPath, stringsFileName)) + strings, err := distro.ReadResourceStringsFromFile(filepath.Join(resPath, stringsFileName)) if err != nil { log.Fatal("failed to load distro strings", zap.Error(err)) }