use filepath.Match instead of regex
This commit is contained in:
parent
5951d9b0ee
commit
e0322042c7
|
|
@ -26,7 +26,6 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
|
@ -696,7 +695,7 @@ func HasFilepathPrefix(path, prefix string, prefixMatchOnly bool) bool {
|
|||
}
|
||||
|
||||
for index := range prefixArray {
|
||||
m, err := regexp.MatchString(prefixArray[index], pathArray[index])
|
||||
m, err := filepath.Match(prefixArray[index], pathArray[index])
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ func Test_DetectFilesystemWhitelist(t *testing.T) {
|
|||
{"/sys", false},
|
||||
{"/var/run", false},
|
||||
{"/etc/mtab", false},
|
||||
{"/tmp/apt-key-gpghome", true},
|
||||
}
|
||||
actualWhitelist := whitelist
|
||||
sort.Slice(actualWhitelist, func(i, j int) bool {
|
||||
|
|
|
|||
Loading…
Reference in New Issue