mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +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 (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anchore/syft/syft/file"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@ -49,7 +48,7 @@ func (z ZipFileManifest) GlobMatch(patterns ...string) []string {
|
|||||||
// so that glob logic is consistent inside and outside of ZIP archives
|
// so that glob logic is consistent inside and outside of ZIP archives
|
||||||
normalizedEntry := normalizeZipEntryName(entry)
|
normalizedEntry := normalizeZipEntryName(entry)
|
||||||
|
|
||||||
if file.GlobMatch(pattern, normalizedEntry) {
|
if internal.FileNameGlobMatch(pattern, normalizedEntry) {
|
||||||
uniqueMatches.Add(entry)
|
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
|
// Source: https://research.swtch.com/glob.go
|
||||||
func GlobMatch(pattern, name string) bool {
|
func FileNameGlobMatch(pattern, name string) bool {
|
||||||
px := 0
|
px := 0
|
||||||
nx := 0
|
nx := 0
|
||||||
nextPx := 0
|
nextPx := 0
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package file
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
@ -32,7 +32,7 @@ func TestGlobMatch(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
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)
|
t.Errorf("failed glob='%s' data='%s'", test.pattern, test.data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,7 +3,7 @@ package python
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/anchore/syft/syft/file"
|
"github.com/anchore/syft/internal"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"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
|
// of egg metadata (as opposed to a directory that contains more metadata
|
||||||
// files).
|
// files).
|
||||||
func isEggRegularFile(path string) bool {
|
func isEggRegularFile(path string) bool {
|
||||||
return file.GlobMatch(eggFileMetadataGlob, path)
|
return internal.FileNameGlobMatch(eggFileMetadataGlob, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// determineSitePackagesRootPath returns the path of the site packages root,
|
// determineSitePackagesRootPath returns the path of the site packages root,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user