migrate filename glob helpers to internal

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2022-03-22 17:41:02 -04:00
parent b3ca75646c
commit a49c7e3c53
No known key found for this signature in database
GPG Key ID: 5CB45AE22BAB7EA7
4 changed files with 8 additions and 9 deletions

View File

@ -2,7 +2,6 @@ package archive
import (
"fmt"
"github.com/anchore/syft/syft/file"
"os"
"sort"
"strings"
@ -49,7 +48,7 @@ func (z ZipFileManifest) GlobMatch(patterns ...string) []string {
// so that glob logic is consistent inside and outside of ZIP archives
normalizedEntry := normalizeZipEntryName(entry)
if file.GlobMatch(pattern, normalizedEntry) {
if internal.FileNameGlobMatch(pattern, normalizedEntry) {
uniqueMatches.Add(entry)
}
}

View File

@ -1,8 +1,8 @@
package file
package internal
// GlobMatch evaluates the given glob pattern against the given "name" string, indicating if there is a match or not.
// FileNameGlobMatch evaluates the given glob pattern against the given "name" string, indicating if there is a match or not.
// Source: https://research.swtch.com/glob.go
func GlobMatch(pattern, name string) bool {
func FileNameGlobMatch(pattern, name string) bool {
px := 0
nx := 0
nextPx := 0

View File

@ -1,4 +1,4 @@
package file
package internal
import (
"strings"
@ -32,7 +32,7 @@ func TestGlobMatch(t *testing.T) {
}
for _, test := range tests {
if GlobMatch(test.pattern, test.data) != test.ok {
if FileNameGlobMatch(test.pattern, test.data) != test.ok {
t.Errorf("failed glob='%s' data='%s'", test.pattern, test.data)
}
}

View File

@ -3,7 +3,7 @@ package python
import (
"bufio"
"fmt"
"github.com/anchore/syft/syft/file"
"github.com/anchore/syft/internal"
"io"
"path/filepath"
"strings"
@ -82,7 +82,7 @@ func parseWheelOrEggMetadata(path string, reader io.Reader) (pkg.PythonPackageMe
// of egg metadata (as opposed to a directory that contains more metadata
// files).
func isEggRegularFile(path string) bool {
return file.GlobMatch(eggFileMetadataGlob, path)
return internal.FileNameGlobMatch(eggFileMetadataGlob, path)
}
// determineSitePackagesRootPath returns the path of the site packages root,