mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-01 10:00:19 +08:00
fix: Gosec/sec fixes (#2004)
* Customization of the initialization file * fix: G601 (CWE-118): Implicit memory aliasing in for loop * fix: G304 (CWE-22): Potential file inclusion via variable * fix: G110 (CWE-409): Potential DoS vulnerability via decompression bomb
This commit is contained in:
@ -22,6 +22,7 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
@ -201,7 +202,7 @@ func GetMinLenStr(strs ...string) string {
|
||||
}
|
||||
|
||||
func ReadStringFromPath(path string) string {
|
||||
data, err := os.ReadFile(path)
|
||||
data, err := os.ReadFile(filepath.Clean(path))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"bufio"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strconv"
|
||||
@ -155,7 +156,7 @@ func GetVersionInfoFromFile() (*VersionInfo, error) {
|
||||
|
||||
_, filename, _, _ := runtime.Caller(0)
|
||||
rootPath := path.Dir(path.Dir(filename))
|
||||
file, err := os.Open(path.Join(rootPath, "version_info.txt"))
|
||||
file, err := os.Open(filepath.Clean(path.Join(rootPath, "version_info.txt")))
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user