mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 06:56:40 +01:00
fix considering base path when ignoring known bad unix paths (#2644)
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -197,7 +197,7 @@ func getDirectoryExclusionFunctions(root string, exclusions []string) ([]fileres
|
||||
}
|
||||
|
||||
return []fileresolver.PathIndexVisitor{
|
||||
func(path string, info os.FileInfo, _ error) error {
|
||||
func(_, path string, info os.FileInfo, _ error) error {
|
||||
for _, exclusion := range exclusions {
|
||||
// this is required to handle Windows filepaths
|
||||
path = filepath.ToSlash(path)
|
||||
|
||||
@@ -392,7 +392,7 @@ func Test_getDirectoryExclusionFunctions_crossPlatform(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
for _, f := range fns {
|
||||
result := f(test.path, test.finfo, nil)
|
||||
result := f("", test.path, test.finfo, nil)
|
||||
require.Equal(t, test.walkHint, result)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -177,7 +177,7 @@ func (s FileSource) FileResolver(_ Scope) (file.Resolver, error) {
|
||||
exclusionFunctions = append([]fileresolver.PathIndexVisitor{
|
||||
|
||||
// note: we should exclude these kinds of paths first before considering any other user-provided exclusions
|
||||
func(p string, _ os.FileInfo, _ error) error {
|
||||
func(_, p string, _ os.FileInfo, _ error) error {
|
||||
if p == absParentDir {
|
||||
// this is the root directory... always include it
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user