use filepath.Match instead of regex

This commit is contained in:
Tejal Desai 2020-01-24 22:12:37 -08:00
parent 5951d9b0ee
commit e0322042c7
2 changed files with 2 additions and 2 deletions

View File

@ -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
}

View File

@ -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 {