mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 08:23:15 +01:00
migrate filename glob helpers to internal
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
parent
b3ca75646c
commit
a49c7e3c53
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
@ -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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user