🚨 fix: gosec lint

This commit is contained in:
naiba 2022-06-03 10:16:33 +08:00
parent 7d70d4c4df
commit db32cdbfae

View File

@ -4,8 +4,10 @@ import (
"crypto/md5" // #nosec "crypto/md5" // #nosec
"encoding/hex" "encoding/hex"
"io" "io"
"log"
"math/rand" "math/rand"
"os" "os"
"path/filepath"
"regexp" "regexp"
"strings" "strings"
"time" "time"
@ -96,11 +98,15 @@ func SplitIPAddr(v4v6Bundle string) (string, string, string) {
} }
func IsDirEmpty(name string) (bool, error) { func IsDirEmpty(name string) (bool, error) {
f, err := os.Open(name) f, err := os.Open(filepath.Clean(name))
if err != nil { if err != nil {
return false, err return false, err
} }
defer f.Close() defer func() {
if err := f.Close(); err != nil {
log.Printf("Error closing file: %s\n", err)
}
}()
_, err = f.Readdirnames(1) _, err = f.Readdirnames(1)
if err == io.EOF { if err == io.EOF {