diff --git a/syft/file/cataloger/filecontent/cataloger.go b/syft/file/cataloger/filecontent/cataloger.go index d108af3931ff..18ef45151553 100644 --- a/syft/file/cataloger/filecontent/cataloger.go +++ b/syft/file/cataloger/filecontent/cataloger.go @@ -63,7 +63,7 @@ func (i *Cataloger) catalogLocation(resolver file.Resolver, location file.Locati if err != nil { return "", err } - defer internal.CloseAndLogError(contentReader, location.VirtualPath) + defer internal.CloseAndLogError(contentReader, location.AccessPath) buf := &bytes.Buffer{} encoder := base64.NewEncoder(base64.StdEncoding, buf) diff --git a/syft/file/cataloger/filedigest/cataloger.go b/syft/file/cataloger/filedigest/cataloger.go index 31a4367ab1fa..64dbdc05e75f 100644 --- a/syft/file/cataloger/filedigest/cataloger.go +++ b/syft/file/cataloger/filedigest/cataloger.go @@ -81,7 +81,7 @@ func (i *Cataloger) catalogLocation(resolver file.Resolver, location file.Locati if err != nil { return nil, err } - defer internal.CloseAndLogError(contentReader, location.VirtualPath) + defer internal.CloseAndLogError(contentReader, location.AccessPath) digests, err := intFile.NewDigestsFromFile(contentReader, i.hashes) if err != nil { diff --git a/syft/file/cataloger/internal/all_regular_files_test.go b/syft/file/cataloger/internal/all_regular_files_test.go index 07430f041daf..4e28a164b41d 100644 --- a/syft/file/cataloger/internal/all_regular_files_test.go +++ b/syft/file/cataloger/internal/all_regular_files_test.go @@ -15,10 +15,10 @@ import ( func Test_allRegularFiles(t *testing.T) { tests := []struct { - name string - setup func() file.Resolver - wantRealPaths *strset.Set - wantVirtualPaths *strset.Set + name string + setup func() file.Resolver + wantRealPaths *strset.Set + wantAccessPaths *strset.Set }{ { name: "image", @@ -35,8 +35,8 @@ func Test_allRegularFiles(t *testing.T) { return r }, - wantRealPaths: strset.New("/file-1.txt"), - wantVirtualPaths: strset.New("/file-1.txt", "/symlink-1", "/hardlink-1"), + wantRealPaths: strset.New("/file-1.txt"), + wantAccessPaths: strset.New("/file-1.txt", "/symlink-1", "/hardlink-1"), }, { name: "directory", @@ -47,8 +47,8 @@ func Test_allRegularFiles(t *testing.T) { require.NoError(t, err) return r }, - wantRealPaths: strset.New("file1.txt", "nested/file2.txt"), - wantVirtualPaths: strset.New("file1.txt", "nested/file2.txt", "nested/linked-file1.txt"), + wantRealPaths: strset.New("file1.txt", "nested/file2.txt"), + wantAccessPaths: strset.New("file1.txt", "nested/file2.txt", "nested/linked-file1.txt"), }, } for _, tt := range tests { @@ -59,8 +59,8 @@ func Test_allRegularFiles(t *testing.T) { virtualLocations := strset.New() for _, l := range locations { realLocations.Add(l.RealPath) - if l.VirtualPath != "" { - virtualLocations.Add(l.VirtualPath) + if l.AccessPath != "" { + virtualLocations.Add(l.AccessPath) } } @@ -68,10 +68,10 @@ func Test_allRegularFiles(t *testing.T) { realLocations.Remove("/hardlink-1") virtualLocations.Remove("/hardlink-1") tt.wantRealPaths.Remove("/hardlink-1") - tt.wantVirtualPaths.Remove("/hardlink-1") + tt.wantAccessPaths.Remove("/hardlink-1") assert.ElementsMatch(t, tt.wantRealPaths.List(), realLocations.List(), "real paths differ: "+cmp.Diff(tt.wantRealPaths.List(), realLocations.List())) - assert.ElementsMatch(t, tt.wantVirtualPaths.List(), virtualLocations.List(), "virtual paths differ: "+cmp.Diff(tt.wantVirtualPaths.List(), virtualLocations.List())) + assert.ElementsMatch(t, tt.wantAccessPaths.List(), virtualLocations.List(), "virtual paths differ: "+cmp.Diff(tt.wantAccessPaths.List(), virtualLocations.List())) }) } } diff --git a/syft/file/cataloger/secrets/cataloger.go b/syft/file/cataloger/secrets/cataloger.go index 488f849b53b2..1f87fe44e658 100644 --- a/syft/file/cataloger/secrets/cataloger.go +++ b/syft/file/cataloger/secrets/cataloger.go @@ -111,7 +111,7 @@ func extractValue(resolver file.Resolver, location file.Location, start, length if err != nil { return "", fmt.Errorf("unable to fetch reader for location=%q : %w", location, err) } - defer internal.CloseAndLogError(readCloser, location.VirtualPath) + defer internal.CloseAndLogError(readCloser, location.AccessPath) n, err := io.CopyN(io.Discard, readCloser, start) if err != nil { diff --git a/syft/file/cataloger/secrets/secrets_search_by_line_strategy.go b/syft/file/cataloger/secrets/secrets_search_by_line_strategy.go index f1beeb525e71..3868018596af 100644 --- a/syft/file/cataloger/secrets/secrets_search_by_line_strategy.go +++ b/syft/file/cataloger/secrets/secrets_search_by_line_strategy.go @@ -16,7 +16,7 @@ func catalogLocationByLine(resolver file.Resolver, location file.Location, patte if err != nil { return nil, fmt.Errorf("unable to fetch reader for location=%q : %w", location, err) } - defer internal.CloseAndLogError(readCloser, location.VirtualPath) + defer internal.CloseAndLogError(readCloser, location.AccessPath) var scanner = bufio.NewReader(readCloser) var position int64 @@ -65,7 +65,7 @@ func searchForSecretsWithinLine(resolver file.Resolver, location file.Location, if secret != nil { secrets = append(secrets, *secret) } - internal.CloseAndLogError(reader, location.VirtualPath) + internal.CloseAndLogError(reader, location.AccessPath) } } diff --git a/syft/file/location.go b/syft/file/location.go index 13229069aeba..25bc753b97e7 100644 --- a/syft/file/location.go +++ b/syft/file/location.go @@ -10,7 +10,7 @@ import ( ) // Location represents a path relative to a particular filesystem resolved to a specific file.Reference. This struct is used as a key -// in content fetching to uniquely identify a file relative to a request (the VirtualPath). +// in content fetching to uniquely identify a file relative to a request (the AccessPath). type Location struct { LocationData `cyclonedx:""` LocationMetadata `cyclonedx:""` @@ -20,8 +20,8 @@ type LocationData struct { Coordinates `cyclonedx:""` // Empty string here means there is no intermediate property name, e.g. syft:locations:0:path without "coordinates" // note: it is IMPORTANT to ignore anything but the coordinates for a Location when considering the ID (hash value) // since the coordinates are the minimally correct ID for a location (symlinks should not come into play) - VirtualPath string `hash:"ignore" json:"accessPath"` // The path to the file which may or may not have hardlinks / symlinks - ref file.Reference `hash:"ignore"` // The file reference relative to the stereoscope.FileCatalog that has more information about this location. + AccessPath string `hash:"ignore" json:"accessPath"` // The path to the file which may or may not have hardlinks / symlinks + ref file.Reference `hash:"ignore"` // The file reference relative to the stereoscope.FileCatalog that has more information about this location. } func (l LocationData) Reference() file.Reference { @@ -68,7 +68,7 @@ func NewLocation(realPath string) Location { Coordinates: Coordinates{ RealPath: realPath, }, - VirtualPath: realPath, + AccessPath: realPath, }, LocationMetadata: LocationMetadata{ Annotations: map[string]string{}, @@ -77,13 +77,13 @@ func NewLocation(realPath string) Location { } // NewVirtualLocation creates a new location for a path accessed by a virtual path (a path with a symlink or hardlink somewhere in the path) -func NewVirtualLocation(realPath, virtualPath string) Location { +func NewVirtualLocation(realPath, accessPath string) Location { return Location{ LocationData: LocationData{ Coordinates: Coordinates{ RealPath: realPath, }, - VirtualPath: virtualPath, + AccessPath: accessPath, }, LocationMetadata: LocationMetadata{ Annotations: map[string]string{}, @@ -95,7 +95,7 @@ func NewLocationFromCoordinates(coordinates Coordinates) Location { return Location{ LocationData: LocationData{ Coordinates: coordinates, - VirtualPath: coordinates.RealPath, + AccessPath: coordinates.RealPath, }, LocationMetadata: LocationMetadata{ Annotations: map[string]string{}, @@ -103,11 +103,11 @@ func NewLocationFromCoordinates(coordinates Coordinates) Location { } // NewVirtualLocationFromCoordinates creates a new location for the given Coordinates via a virtual path. -func NewVirtualLocationFromCoordinates(coordinates Coordinates, virtualPath string) Location { +func NewVirtualLocationFromCoordinates(coordinates Coordinates, accessPath string) Location { return Location{ LocationData: LocationData{ Coordinates: coordinates, - VirtualPath: virtualPath, + AccessPath: accessPath, }, LocationMetadata: LocationMetadata{ Annotations: map[string]string{}, @@ -115,7 +115,7 @@ func NewVirtualLocationFromCoordinates(coordinates Coordinates, virtualPath stri } // NewLocationFromImage creates a new Location representing the given path (extracted from the Reference) relative to the given image. -func NewLocationFromImage(virtualPath string, ref file.Reference, img *image.Image) Location { +func NewLocationFromImage(accessPath string, ref file.Reference, img *image.Image) Location { layer := img.FileCatalog.Layer(ref) return Location{ LocationData: LocationData{ @@ -123,8 +123,8 @@ func NewLocationFromImage(virtualPath string, ref file.Reference, img *image.Ima RealPath: string(ref.RealPath), FileSystemID: layer.Metadata.Digest, }, - VirtualPath: virtualPath, - ref: ref, + AccessPath: accessPath, + ref: ref, }, LocationMetadata: LocationMetadata{ Annotations: map[string]string{}, @@ -139,8 +139,8 @@ func NewLocationFromDirectory(responsePath string, ref file.Reference) Location Coordinates: Coordinates{ RealPath: responsePath, }, - VirtualPath: responsePath, - ref: ref, + AccessPath: responsePath, + ref: ref, }, LocationMetadata: LocationMetadata{ Annotations: map[string]string{}, @@ -149,14 +149,14 @@ func NewLocationFromDirectory(responsePath string, ref file.Reference) Location } // NewVirtualLocationFromDirectory creates a new Location representing the given path (extracted from the Reference) relative to the given directory with a separate virtual access path. -func NewVirtualLocationFromDirectory(responsePath, virtualResponsePath string, ref file.Reference) Location { +func NewVirtualLocationFromDirectory(responsePath, responseAccessPath string, ref file.Reference) Location { return Location{ LocationData: LocationData{ Coordinates: Coordinates{ RealPath: responsePath, }, - VirtualPath: virtualResponsePath, - ref: ref, + AccessPath: responseAccessPath, + ref: ref, }, LocationMetadata: LocationMetadata{ Annotations: map[string]string{}, @@ -164,9 +164,9 @@ func NewVirtualLocationFromDirectory(responsePath, virtualResponsePath string, r } } -func (l Location) AccessPath() string { - if l.VirtualPath != "" { - return l.VirtualPath +func (l Location) Path() string { + if l.AccessPath != "" { + return l.AccessPath } return l.RealPath } @@ -179,8 +179,8 @@ func (l Location) String() string { str += fmt.Sprintf("RealPath=%q", l.RealPath) - if l.VirtualPath != "" && l.VirtualPath != l.RealPath { - str += fmt.Sprintf(" VirtualPath=%q", l.VirtualPath) + if l.AccessPath != "" && l.AccessPath != l.RealPath { + str += fmt.Sprintf(" AccessPath=%q", l.AccessPath) } if l.FileSystemID != "" { @@ -191,6 +191,6 @@ func (l Location) String() string { func (l Location) Equals(other Location) bool { return l.RealPath == other.RealPath && - l.VirtualPath == other.VirtualPath && + l.AccessPath == other.AccessPath && l.FileSystemID == other.FileSystemID } diff --git a/syft/file/location_set_test.go b/syft/file/location_set_test.go index 1613c71a5395..fabe3240c976 100644 --- a/syft/file/location_set_test.go +++ b/syft/file/location_set_test.go @@ -17,7 +17,7 @@ func TestLocationSet(t *testing.T) { RealPath: "/etc/hosts", FileSystemID: "a", }, - VirtualPath: "/var/etc/hosts", + AccessPath: "/var/etc/hosts", }, } @@ -27,7 +27,7 @@ func TestLocationSet(t *testing.T) { RealPath: "/etc/hosts", FileSystemID: "a", }, - VirtualPath: "/home/wagoodman/hosts", + AccessPath: "/home/wagoodman/hosts", }, } @@ -37,7 +37,7 @@ func TestLocationSet(t *testing.T) { RealPath: "/bin", FileSystemID: "a", }, - VirtualPath: "/usr/bin", + AccessPath: "/usr/bin", }, } @@ -47,7 +47,7 @@ func TestLocationSet(t *testing.T) { RealPath: "/bin", FileSystemID: "b", }, - VirtualPath: "/usr/bin", + AccessPath: "/usr/bin", }, } @@ -100,7 +100,7 @@ func TestLocationSet_Hash(t *testing.T) { RealPath: "/etc/hosts", FileSystemID: "a", }, - VirtualPath: "/var/etc/hosts", + AccessPath: "/var/etc/hosts", }, } @@ -128,7 +128,7 @@ func TestLocationSet_Hash(t *testing.T) { RealPath: "/bin", FileSystemID: "a", }, - VirtualPath: "/usr/bin", + AccessPath: "/usr/bin", }, } @@ -138,7 +138,7 @@ func TestLocationSet_Hash(t *testing.T) { RealPath: "/bin", FileSystemID: "b", }, - VirtualPath: "/usr/bin", + AccessPath: "/usr/bin", }, } diff --git a/syft/file/location_test.go b/syft/file/location_test.go index 261ae9caa0f3..36626955b475 100644 --- a/syft/file/location_test.go +++ b/syft/file/location_test.go @@ -39,7 +39,7 @@ func TestLocation_ID(t *testing.T) { l := Location{ LocationData: LocationData{ Coordinates: test.coordinates, - VirtualPath: test.virtualPath, + AccessPath: test.virtualPath, ref: test.ref, }, } diff --git a/syft/file/locations.go b/syft/file/locations.go index da298643ec91..80a4503cb1fa 100644 --- a/syft/file/locations.go +++ b/syft/file/locations.go @@ -8,10 +8,10 @@ func (l Locations) Len() int { func (l Locations) Less(i, j int) bool { if l[i].RealPath == l[j].RealPath { - if l[i].VirtualPath == l[j].VirtualPath { + if l[i].AccessPath == l[j].AccessPath { return l[i].FileSystemID < l[j].FileSystemID } - return l[i].VirtualPath < l[j].VirtualPath + return l[i].AccessPath < l[j].AccessPath } return l[i].RealPath < l[j].RealPath } diff --git a/syft/format/common/spdxhelpers/to_syft_model_test.go b/syft/format/common/spdxhelpers/to_syft_model_test.go index 0bc3ae340d08..4b54d2f6113d 100644 --- a/syft/format/common/spdxhelpers/to_syft_model_test.go +++ b/syft/format/common/spdxhelpers/to_syft_model_test.go @@ -636,7 +636,7 @@ func Test_directPackageFiles(t *testing.T) { RealPath: "some-file", FileSystemID: "", }, - VirtualPath: "some-file", + AccessPath: "some-file", }, LocationMetadata: file.LocationMetadata{ Annotations: map[string]string{}, diff --git a/syft/format/github/internal/model/model.go b/syft/format/github/internal/model/model.go index b5dc39ed1136..d87038c6b6eb 100644 --- a/syft/format/github/internal/model/model.go +++ b/syft/format/github/internal/model/model.go @@ -111,8 +111,8 @@ func toPath(s source.Description, p pkg.Package) string { if len(locations) > 0 { location := locations[0] packagePath := location.RealPath - if location.VirtualPath != "" { - packagePath = location.VirtualPath + if location.AccessPath != "" { + packagePath = location.AccessPath } packagePath = strings.TrimPrefix(packagePath, "/") switch metadata := s.Metadata.(type) { diff --git a/syft/format/spdxtagvalue/decoder_test.go b/syft/format/spdxtagvalue/decoder_test.go index 497b7d81229d..22c54e6f2e96 100644 --- a/syft/format/spdxtagvalue/decoder_test.go +++ b/syft/format/spdxtagvalue/decoder_test.go @@ -123,7 +123,7 @@ FileCopyrightText: NOASSERTION f = file.Location{ LocationData: file.LocationData{ Coordinates: c, - VirtualPath: "", + AccessPath: "", }, LocationMetadata: file.LocationMetadata{}, } diff --git a/syft/format/syftjson/decoder_test.go b/syft/format/syftjson/decoder_test.go index f6a95e86e568..9e3a98729b28 100644 --- a/syft/format/syftjson/decoder_test.go +++ b/syft/format/syftjson/decoder_test.go @@ -80,7 +80,7 @@ func Test_EncodeDecodeCycle(t *testing.T) { } for _, d := range deep.Equal(p, actualPackages[idx]) { - if strings.Contains(d, ".VirtualPath: ") { + if strings.Contains(d, ".AccessPath: ") { // location.Virtual path is not exposed in the json output continue } diff --git a/syft/internal/fileresolver/container_image_all_layers.go b/syft/internal/fileresolver/container_image_all_layers.go index e66c92aaf1b3..4bf7a1d23ae4 100644 --- a/syft/internal/fileresolver/container_image_all_layers.go +++ b/syft/internal/fileresolver/container_image_all_layers.go @@ -193,10 +193,10 @@ func (r *ContainerImageAllLayers) FileContentsByLocation(location file.Location) switch entry.Metadata.Type { case stereoscopeFile.TypeSymLink, stereoscopeFile.TypeHardLink: // the location we are searching may be a symlink, we should always work with the resolved file - newLocation := r.RelativeFileByPath(location, location.VirtualPath) + newLocation := r.RelativeFileByPath(location, location.AccessPath) if newLocation == nil { // this is a dead link - return nil, fmt.Errorf("no contents for location=%q", location.VirtualPath) + return nil, fmt.Errorf("no contents for location=%q", location.AccessPath) } location = *newLocation case stereoscopeFile.TypeDirectory: diff --git a/syft/internal/fileresolver/directory.go b/syft/internal/fileresolver/directory.go index 0b972a2d56e7..2d74d826fb70 100644 --- a/syft/internal/fileresolver/directory.go +++ b/syft/internal/fileresolver/directory.go @@ -110,7 +110,7 @@ func (r Directory) FilesByPath(userPaths ...string) ([]file.Location, error) { continue } - // we should be resolving symlinks and preserving this information as a VirtualPath to the real file + // we should be resolving symlinks and preserving this information as a AccessPath to the real file ref, err := r.searchContext.SearchByPath(userStrPath, filetree.FollowBasenameLinks) if err != nil { log.Tracef("unable to evaluate symlink for path=%q : %+v", userPath, err) diff --git a/syft/internal/fileresolver/directory_test.go b/syft/internal/fileresolver/directory_test.go index 7032a43c2bd7..a862ce6ed8ed 100644 --- a/syft/internal/fileresolver/directory_test.go +++ b/syft/internal/fileresolver/directory_test.go @@ -65,13 +65,13 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { t.Cleanup(cleanup) cases := []struct { - name string - cwd string - root string - base string - input string - expectedRealPath string - expectedVirtualPath string // note: if empty it will be assumed to match the expectedRealPath + name string + cwd string + root string + base string + input string + expectedRealPath string + expectedAccessPath string // note: if empty it will be assumed to match the expectedRealPath }{ { name: "relative root, relative request, direct", @@ -139,7 +139,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "path/to/the/file.txt", - expectedVirtualPath: "path/to/the/file.txt", + expectedAccessPath: "path/to/the/file.txt", }, { name: "abs root, relative request, direct, cwd within symlink root", @@ -159,7 +159,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "path/to/the/file.txt", - expectedVirtualPath: "path/to/the/file.txt", + expectedAccessPath: "path/to/the/file.txt", }, { name: "abs root, abs request, direct, cwd within symlink root", @@ -180,7 +180,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "to/the/file.txt", - expectedVirtualPath: "to/the/file.txt", + expectedAccessPath: "to/the/file.txt", }, { name: "abs root, relative nested request, direct, cwd within symlink root", @@ -200,7 +200,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "to/the/file.txt", - expectedVirtualPath: "to/the/file.txt", + expectedAccessPath: "to/the/file.txt", }, { name: "abs root, abs nested request, direct, cwd within symlink root", @@ -221,7 +221,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "path/to/the/file.txt", - expectedVirtualPath: "path/to/the/file.txt", + expectedAccessPath: "path/to/the/file.txt", }, { name: "abs root, relative request, direct, cwd within (double) symlink root", @@ -241,7 +241,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "path/to/the/file.txt", - expectedVirtualPath: "path/to/the/file.txt", + expectedAccessPath: "path/to/the/file.txt", }, { name: "abs root, abs request, direct, cwd within (double) symlink root", @@ -262,7 +262,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "to/the/file.txt", - expectedVirtualPath: "to/the/file.txt", + expectedAccessPath: "to/the/file.txt", }, { name: "abs root, relative nested request, direct, cwd within (double) symlink root", @@ -282,7 +282,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "to/the/file.txt", - expectedVirtualPath: "to/the/file.txt", + expectedAccessPath: "to/the/file.txt", }, { name: "abs root, abs nested request, direct, cwd within (double) symlink root", @@ -303,7 +303,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "to/the/file.txt", - expectedVirtualPath: "to/the/file.txt", + expectedAccessPath: "to/the/file.txt", }, { name: "abs root, relative nested request, direct, cwd deep within (double) symlink root", @@ -323,7 +323,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { // outside the root. expectedRealPath: filepath.Join(absolute, "path/to/the/file.txt"), //expectedRealPath: "to/the/file.txt", - expectedVirtualPath: "to/the/file.txt", + expectedAccessPath: "to/the/file.txt", }, { name: "abs root, abs nested request, direct, cwd deep within (double) symlink root", @@ -334,163 +334,163 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { }, // link to outside of root cases... { - name: "relative root, relative request, abs indirect (outside of root)", - root: filepath.Join(relative, "path"), - input: "to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "relative root, relative request, abs indirect (outside of root)", + root: filepath.Join(relative, "path"), + input: "to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "abs root, relative request, abs indirect (outside of root)", - root: filepath.Join(absolute, "path"), - input: "to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "abs root, relative request, abs indirect (outside of root)", + root: filepath.Join(absolute, "path"), + input: "to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "relative root, abs request, abs indirect (outside of root)", - root: filepath.Join(relative, "path"), - input: "/to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "relative root, abs request, abs indirect (outside of root)", + root: filepath.Join(relative, "path"), + input: "/to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "abs root, abs request, abs indirect (outside of root)", - root: filepath.Join(absolute, "path"), - input: "/to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "abs root, abs request, abs indirect (outside of root)", + root: filepath.Join(absolute, "path"), + input: "/to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "relative root, relative request, relative indirect (outside of root)", - root: filepath.Join(relative, "path"), - input: "to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "relative root, relative request, relative indirect (outside of root)", + root: filepath.Join(relative, "path"), + input: "to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "abs root, relative request, relative indirect (outside of root)", - root: filepath.Join(absolute, "path"), - input: "to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "abs root, relative request, relative indirect (outside of root)", + root: filepath.Join(absolute, "path"), + input: "to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "relative root, abs request, relative indirect (outside of root)", - root: filepath.Join(relative, "path"), - input: "/to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "relative root, abs request, relative indirect (outside of root)", + root: filepath.Join(relative, "path"), + input: "/to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "abs root, abs request, relative indirect (outside of root)", - root: filepath.Join(absolute, "path"), - input: "/to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "abs root, abs request, relative indirect (outside of root)", + root: filepath.Join(absolute, "path"), + input: "/to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, // link to outside of root cases... cwd within symlink root { - name: "relative root, relative request, abs indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: "path", - input: "to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "relative root, relative request, abs indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: "path", + input: "to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "abs root, relative request, abs indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: filepath.Join(absolute, "path"), - input: "to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "abs root, relative request, abs indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: filepath.Join(absolute, "path"), + input: "to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "relative root, abs request, abs indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: "path", - input: "/to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "relative root, abs request, abs indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: "path", + input: "/to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "abs root, abs request, abs indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: filepath.Join(absolute, "path"), - input: "/to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "abs root, abs request, abs indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: filepath.Join(absolute, "path"), + input: "/to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "relative root, relative request, relative indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: "path", - input: "to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "relative root, relative request, relative indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: "path", + input: "to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "abs root, relative request, relative indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: filepath.Join(absolute, "path"), - input: "to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "abs root, relative request, relative indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: filepath.Join(absolute, "path"), + input: "to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "relative root, abs request, relative indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: "path", - input: "/to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "relative root, abs request, relative indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: "path", + input: "/to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "abs root, abs request, relative indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: filepath.Join(absolute, "path"), - input: "/to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "abs root, abs request, relative indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: filepath.Join(absolute, "path"), + input: "/to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "relative root, relative request, relative indirect (outside of root), cwd within DOUBLE symlink root", - cwd: relativeViaDoubleLink, - root: "path", - input: "to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "relative root, relative request, relative indirect (outside of root), cwd within DOUBLE symlink root", + cwd: relativeViaDoubleLink, + root: "path", + input: "to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "abs root, relative request, relative indirect (outside of root), cwd within DOUBLE symlink root", - cwd: relativeViaDoubleLink, - root: filepath.Join(absolute, "path"), - input: "to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "abs root, relative request, relative indirect (outside of root), cwd within DOUBLE symlink root", + cwd: relativeViaDoubleLink, + root: filepath.Join(absolute, "path"), + input: "to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "relative root, abs request, relative indirect (outside of root), cwd within DOUBLE symlink root", - cwd: relativeViaDoubleLink, - root: "path", - input: "/to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "relative root, abs request, relative indirect (outside of root), cwd within DOUBLE symlink root", + cwd: relativeViaDoubleLink, + root: "path", + input: "/to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, { - name: "abs root, abs request, relative indirect (outside of root), cwd within DOUBLE symlink root", - cwd: relativeViaDoubleLink, - root: filepath.Join(absolute, "path"), - input: "/to/the/rel-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/rel-outside.txt", + name: "abs root, abs request, relative indirect (outside of root), cwd within DOUBLE symlink root", + cwd: relativeViaDoubleLink, + root: filepath.Join(absolute, "path"), + input: "/to/the/rel-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/rel-outside.txt", }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { - if c.expectedVirtualPath == "" { - c.expectedVirtualPath = c.expectedRealPath + if c.expectedAccessPath == "" { + c.expectedAccessPath = c.expectedRealPath } // we need to mimic a shell, otherwise we won't get a path within a symlink @@ -515,7 +515,7 @@ func TestDirectoryResolver_FilesByPath_request_response(t *testing.T) { } require.Len(t, refs, 1) assert.Equal(t, c.expectedRealPath, refs[0].RealPath, "real path different") - assert.Equal(t, c.expectedVirtualPath, refs[0].VirtualPath, "virtual path different") + assert.Equal(t, c.expectedAccessPath, refs[0].AccessPath, "virtual path different") }) } } @@ -961,14 +961,14 @@ func Test_IndexingNestedSymLinks(t *testing.T) { require.NoError(t, err) require.Len(t, locations, 1) assert.Equal(t, "readme", locations[0].RealPath) - assert.Equal(t, "link_to_new_readme", locations[0].VirtualPath) + assert.Equal(t, "link_to_new_readme", locations[0].AccessPath) // check that we can access the same file via 2 symlinks locations, err = resolver.FilesByPath("./link_to_link_to_new_readme") require.NoError(t, err) require.Len(t, locations, 1) assert.Equal(t, "readme", locations[0].RealPath) - assert.Equal(t, "link_to_link_to_new_readme", locations[0].VirtualPath) + assert.Equal(t, "link_to_link_to_new_readme", locations[0].AccessPath) // check that we can access the same file via 2 symlinks locations, err = resolver.FilesByGlob("**/link_*") @@ -976,7 +976,7 @@ func Test_IndexingNestedSymLinks(t *testing.T) { require.Len(t, locations, 1) // you would think this is 2, however, they point to the same file, and glob only returns unique files // returned locations can be in any order - expectedVirtualPaths := []string{ + expectedAccessPaths := []string{ "link_to_link_to_new_readme", //"link_to_new_readme", // we filter out this one because the first symlink resolves to the same file } @@ -986,13 +986,13 @@ func Test_IndexingNestedSymLinks(t *testing.T) { } actualRealPaths := strset.New() - actualVirtualPaths := strset.New() + actualAccessPaths := strset.New() for _, a := range locations { - actualVirtualPaths.Add(a.VirtualPath) + actualAccessPaths.Add(a.AccessPath) actualRealPaths.Add(a.RealPath) } - assert.ElementsMatch(t, expectedVirtualPaths, actualVirtualPaths.List()) + assert.ElementsMatch(t, expectedAccessPaths, actualAccessPaths.List()) assert.ElementsMatch(t, expectedRealPaths, actualRealPaths.List()) } diff --git a/syft/internal/fileresolver/excluding_file.go b/syft/internal/fileresolver/excluding_file.go index 34c4948a2322..cbccd3642a42 100644 --- a/syft/internal/fileresolver/excluding_file.go +++ b/syft/internal/fileresolver/excluding_file.go @@ -83,7 +83,7 @@ func (r *excluding) AllLocations() <-chan file.Location { } func locationMatches(location *file.Location, exclusionFn excludeFn) bool { - return exclusionFn(location.RealPath) || exclusionFn(location.VirtualPath) + return exclusionFn(location.RealPath) || exclusionFn(location.AccessPath) } func filterLocations(locations []file.Location, err error, exclusionFn excludeFn) ([]file.Location, error) { diff --git a/syft/internal/fileresolver/unindexed_directory.go b/syft/internal/fileresolver/unindexed_directory.go index e82b3b472158..5ef892cfdb6a 100644 --- a/syft/internal/fileresolver/unindexed_directory.go +++ b/syft/internal/fileresolver/unindexed_directory.go @@ -165,8 +165,8 @@ nextPath: for i := range out { existing := &out[i] if existing.RealPath == l.RealPath { - if l.VirtualPath == "" { - existing.VirtualPath = "" + if l.AccessPath == "" { + existing.AccessPath = "" } continue nextPath } diff --git a/syft/internal/fileresolver/unindexed_directory_test.go b/syft/internal/fileresolver/unindexed_directory_test.go index 0d6ecb1062a8..5cc878e9eb66 100644 --- a/syft/internal/fileresolver/unindexed_directory_test.go +++ b/syft/internal/fileresolver/unindexed_directory_test.go @@ -90,13 +90,13 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { t.Cleanup(cleanup) cases := []struct { - name string - cwd string - root string - base string - input string - expectedRealPath string - expectedVirtualPath string // if empty, the virtual path should be the same as the real path + name string + cwd string + root string + base string + input string + expectedRealPath string + expectedAccessPath string // if empty, the virtual path should be the same as the real path }{ { name: "relative root, relative request, direct", @@ -319,32 +319,32 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { }, // link to outside of root cases... { - name: "relative root, relative request, abs indirect (outside of root)", - root: filepath.Join(relative, "path"), - input: "to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "relative root, relative request, abs indirect (outside of root)", + root: filepath.Join(relative, "path"), + input: "to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "abs root, relative request, abs indirect (outside of root)", - root: filepath.Join(absolute, "path"), - input: "to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "abs root, relative request, abs indirect (outside of root)", + root: filepath.Join(absolute, "path"), + input: "to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "relative root, abs request, abs indirect (outside of root)", - root: filepath.Join(relative, "path"), - input: "/to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "relative root, abs request, abs indirect (outside of root)", + root: filepath.Join(relative, "path"), + input: "/to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "abs root, abs request, abs indirect (outside of root)", - root: filepath.Join(absolute, "path"), - input: "/to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "abs root, abs request, abs indirect (outside of root)", + root: filepath.Join(absolute, "path"), + input: "/to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { name: "relative root, relative request, relative indirect (outside of root)", @@ -352,8 +352,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "abs root, relative request, relative indirect (outside of root)", @@ -361,8 +361,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "relative root, abs request, relative indirect (outside of root)", @@ -370,8 +370,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "/to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "abs root, abs request, relative indirect (outside of root)", @@ -379,41 +379,41 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "/to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, // link to outside of root cases... cwd within symlink root { - name: "relative root, relative request, abs indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: "path", - input: "to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "relative root, relative request, abs indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: "path", + input: "to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "abs root, relative request, abs indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: filepath.Join(absolute, "path"), - input: "to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "abs root, relative request, abs indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: filepath.Join(absolute, "path"), + input: "to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "relative root, abs request, abs indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: "path", - input: "/to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "relative root, abs request, abs indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: "path", + input: "/to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { - name: "abs root, abs request, abs indirect (outside of root), cwd within symlink root", - cwd: relativeViaLink, - root: filepath.Join(absolute, "path"), - input: "/to/the/abs-outside.txt", - expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), - expectedVirtualPath: "to/the/abs-outside.txt", + name: "abs root, abs request, abs indirect (outside of root), cwd within symlink root", + cwd: relativeViaLink, + root: filepath.Join(absolute, "path"), + input: "/to/the/abs-outside.txt", + expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), + expectedAccessPath: "to/the/abs-outside.txt", }, { name: "relative root, relative request, relative indirect (outside of root), cwd within symlink root", @@ -422,8 +422,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "abs root, relative request, relative indirect (outside of root), cwd within symlink root", @@ -432,8 +432,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "relative root, abs request, relative indirect (outside of root), cwd within symlink root", @@ -442,8 +442,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "/to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "abs root, abs request, relative indirect (outside of root), cwd within symlink root", @@ -452,8 +452,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "/to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "relative root, relative request, relative indirect (outside of root), cwd within DOUBLE symlink root", @@ -462,8 +462,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "abs root, relative request, relative indirect (outside of root), cwd within DOUBLE symlink root", @@ -472,8 +472,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "relative root, abs request, relative indirect (outside of root), cwd within DOUBLE symlink root", @@ -482,8 +482,8 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "/to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, { name: "abs root, abs request, relative indirect (outside of root), cwd within DOUBLE symlink root", @@ -492,14 +492,14 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { input: "/to/the/rel-outside.txt", //expectedRealPath: filepath.Join(absolute, "/somewhere/outside.txt"), // TODO: the real path is not correct - expectedRealPath: "../somewhere/outside.txt", - expectedVirtualPath: "to/the/rel-outside.txt", + expectedRealPath: "../somewhere/outside.txt", + expectedAccessPath: "to/the/rel-outside.txt", }, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { - if c.expectedVirtualPath == "" { - c.expectedVirtualPath = c.expectedRealPath + if c.expectedAccessPath == "" { + c.expectedAccessPath = c.expectedRealPath } // we need to mimic a shell, otherwise we won't get a path within a symlink @@ -523,7 +523,7 @@ func Test_UnindexDirectoryResolver_FilesByPath_request_response(t *testing.T) { } require.Len(t, refs, 1) assert.Equal(t, c.expectedRealPath, refs[0].RealPath, "real path different") - assert.Equal(t, c.expectedVirtualPath, refs[0].VirtualPath, "virtual path different") + assert.Equal(t, c.expectedAccessPath, refs[0].AccessPath, "virtual path different") }) } } @@ -847,14 +847,14 @@ func Test_UnindexedDirectoryResover_IndexingNestedSymLinks(t *testing.T) { require.NoError(t, err) require.Len(t, locations, 1) assert.Equal(t, "readme", locations[0].RealPath) - assert.Equal(t, "link_to_new_readme", locations[0].VirtualPath) + assert.Equal(t, "link_to_new_readme", locations[0].AccessPath) // check that we can access the same file via 2 symlinks locations, err = resolver.FilesByPath("./link_to_link_to_new_readme") require.NoError(t, err) require.Len(t, locations, 1) assert.Equal(t, "readme", locations[0].RealPath) - assert.Equal(t, "link_to_link_to_new_readme", locations[0].VirtualPath) + assert.Equal(t, "link_to_link_to_new_readme", locations[0].AccessPath) // check that we can access the same file via 2 symlinks locations, err = resolver.FilesByGlob("**/link_*") @@ -862,7 +862,7 @@ func Test_UnindexedDirectoryResover_IndexingNestedSymLinks(t *testing.T) { require.Len(t, locations, 1) // you would think this is 2, however, they point to the same file, and glob only returns unique files // returned locations can be in any order - expectedVirtualPaths := []string{ + expectedAccessPaths := []string{ "link_to_link_to_new_readme", //"link_to_new_readme", // we filter out this one because the first symlink resolves to the same file } @@ -872,13 +872,13 @@ func Test_UnindexedDirectoryResover_IndexingNestedSymLinks(t *testing.T) { } actualRealPaths := strset.New() - actualVirtualPaths := strset.New() + actualAccessPaths := strset.New() for _, a := range locations { - actualVirtualPaths.Add(a.VirtualPath) + actualAccessPaths.Add(a.AccessPath) actualRealPaths.Add(a.RealPath) } - assert.ElementsMatch(t, expectedVirtualPaths, actualVirtualPaths.List()) + assert.ElementsMatch(t, expectedAccessPaths, actualAccessPaths.List()) assert.ElementsMatch(t, expectedRealPaths, actualRealPaths.List()) } diff --git a/syft/linux/identify_release.go b/syft/linux/identify_release.go index cf2da477cc3a..3ab8db903fdc 100644 --- a/syft/linux/identify_release.go +++ b/syft/linux/identify_release.go @@ -71,7 +71,7 @@ func IdentifyRelease(resolver file.Resolver) *Release { } content, err := io.ReadAll(contentReader) - internal.CloseAndLogError(contentReader, location.VirtualPath) + internal.CloseAndLogError(contentReader, location.AccessPath) if err != nil { logger.WithFields("error", err, "path", location.RealPath).Trace("unable to read contents") continue diff --git a/syft/pkg/catalog.go b/syft/pkg/catalog.go index 2120dfdfc861..1bca0fb43610 100644 --- a/syft/pkg/catalog.go +++ b/syft/pkg/catalog.go @@ -130,9 +130,9 @@ func (c *Collection) addPathsToIndex(p Package) { c.addPathToIndex(p.id, l.RealPath) observedPaths.Add(l.RealPath) } - if l.VirtualPath != "" && l.RealPath != l.VirtualPath && !observedPaths.Has(l.VirtualPath) { - c.addPathToIndex(p.id, l.VirtualPath) - observedPaths.Add(l.VirtualPath) + if l.AccessPath != "" && l.RealPath != l.AccessPath && !observedPaths.Has(l.AccessPath) { + c.addPathToIndex(p.id, l.AccessPath) + observedPaths.Add(l.AccessPath) } } } @@ -179,9 +179,9 @@ func (c *Collection) deletePathsFromIndex(p Package) { c.deletePathFromIndex(p.id, l.RealPath) observedPaths.Add(l.RealPath) } - if l.VirtualPath != "" && l.RealPath != l.VirtualPath && !observedPaths.Has(l.VirtualPath) { - c.deletePathFromIndex(p.id, l.VirtualPath) - observedPaths.Add(l.VirtualPath) + if l.AccessPath != "" && l.RealPath != l.AccessPath && !observedPaths.Has(l.AccessPath) { + c.deletePathFromIndex(p.id, l.AccessPath) + observedPaths.Add(l.AccessPath) } } } diff --git a/syft/pkg/cataloger/binary/cataloger_test.go b/syft/pkg/cataloger/binary/cataloger_test.go index 1461edaba49d..77d727c25f04 100644 --- a/syft/pkg/cataloger/binary/cataloger_test.go +++ b/syft/pkg/cataloger/binary/cataloger_test.go @@ -833,7 +833,7 @@ func assertPackagesAreEqual(t *testing.T, expected pkg.Package, p pkg.Package) { matches = false break } - if m1.Location.VirtualPath != "" && m1.Location.VirtualPath != m2.Location.VirtualPath { + if m1.Location.AccessPath != "" && m1.Location.AccessPath != m2.Location.AccessPath { matches = false break } diff --git a/syft/pkg/cataloger/cpp/parse_conaninfo.go b/syft/pkg/cataloger/cpp/parse_conaninfo.go index e2628110811f..b53273937c6c 100644 --- a/syft/pkg/cataloger/cpp/parse_conaninfo.go +++ b/syft/pkg/cataloger/cpp/parse_conaninfo.go @@ -17,7 +17,7 @@ import ( var _ generic.Parser = parseConaninfo func parseConanMetadataFromFilePath(path string) (pkg.ConaninfoEntry, error) { - // fullFilePath = str(reader.Location.VirtualPath) + // fullFilePath = str(reader.Location.AccessPath) // Split the full patch into the folders we expect. I.e.: // $HOME/.conan/data/////package//conaninfo.txt re := regexp.MustCompile(`.*[/\\](?P[^/\\]+)[/\\](?P[^/\\]+)[/\\](?P[^/\\]+)[/\\](?P[^/\\]+)[/\\]package[/\\](?P[^/\\]+)[/\\]conaninfo\.txt`) diff --git a/syft/pkg/cataloger/debian/package.go b/syft/pkg/cataloger/debian/package.go index e762eeb8e3ad..1d62851ecca6 100644 --- a/syft/pkg/cataloger/debian/package.go +++ b/syft/pkg/cataloger/debian/package.go @@ -96,7 +96,7 @@ func addLicenses(resolver file.Resolver, dbLocation file.Location, p *pkg.Packag copyrightReader, copyrightLocation := fetchCopyrightContents(resolver, dbLocation, metadata) if copyrightReader != nil && copyrightLocation != nil { - defer internal.CloseAndLogError(copyrightReader, copyrightLocation.VirtualPath) + defer internal.CloseAndLogError(copyrightReader, copyrightLocation.AccessPath) // attach the licenses licenseStrs := parseLicensesFromCopyright(copyrightReader) for _, licenseStr := range licenseStrs { @@ -147,7 +147,7 @@ func getAdditionalFileListing(resolver file.Resolver, dbLocation file.Location, md5Reader, md5Location := fetchMd5Contents(resolver, dbLocation, m) if md5Reader != nil && md5Location != nil { - defer internal.CloseAndLogError(md5Reader, md5Location.VirtualPath) + defer internal.CloseAndLogError(md5Reader, md5Location.AccessPath) // attach the file list files = append(files, parseDpkgMD5Info(md5Reader)...) @@ -158,7 +158,7 @@ func getAdditionalFileListing(resolver file.Resolver, dbLocation file.Location, conffilesReader, conffilesLocation := fetchConffileContents(resolver, dbLocation, m) if conffilesReader != nil && conffilesLocation != nil { - defer internal.CloseAndLogError(conffilesReader, conffilesLocation.VirtualPath) + defer internal.CloseAndLogError(conffilesReader, conffilesLocation.AccessPath) // attach the file list files = append(files, parseDpkgConffileInfo(conffilesReader)...) diff --git a/syft/pkg/cataloger/dotnet/parse_dotnet_deps.go b/syft/pkg/cataloger/dotnet/parse_dotnet_deps.go index 28d5f26891db..fc7687804e0c 100644 --- a/syft/pkg/cataloger/dotnet/parse_dotnet_deps.go +++ b/syft/pkg/cataloger/dotnet/parse_dotnet_deps.go @@ -49,9 +49,9 @@ func parseDotnetDeps(_ file.Resolver, _ *generic.Environment, reader file.Locati return nil, nil, fmt.Errorf("failed to parse deps.json file: %w", err) } - rootName := getDepsJSONFilePrefix(reader.AccessPath()) + rootName := getDepsJSONFilePrefix(reader.Path()) if rootName == "" { - return nil, nil, fmt.Errorf("unable to determine root package name from deps.json file: %s", reader.AccessPath()) + return nil, nil, fmt.Errorf("unable to determine root package name from deps.json file: %s", reader.Path()) } var rootPkg *pkg.Package for nameVersion, lib := range depsDoc.Libraries { @@ -65,7 +65,7 @@ func parseDotnetDeps(_ file.Resolver, _ *generic.Environment, reader file.Locati } } if rootPkg == nil { - return nil, nil, fmt.Errorf("unable to determine root package from deps.json file: %s", reader.AccessPath()) + return nil, nil, fmt.Errorf("unable to determine root package from deps.json file: %s", reader.Path()) } pkgs = append(pkgs, *rootPkg) pkgMap[createNameAndVersion(rootPkg.Name, rootPkg.Version)] = *rootPkg diff --git a/syft/pkg/cataloger/generic/cataloger.go b/syft/pkg/cataloger/generic/cataloger.go index b898133f74d8..41faaf2856a5 100644 --- a/syft/pkg/cataloger/generic/cataloger.go +++ b/syft/pkg/cataloger/generic/cataloger.go @@ -127,7 +127,7 @@ func (c *Cataloger) Catalog(resolver file.Resolver) ([]pkg.Package, []artifact.R } discoveredPackages, discoveredRelationships, err := parser(resolver, &env, file.NewLocationReadCloser(location, contentReader)) - internal.CloseAndLogError(contentReader, location.VirtualPath) + internal.CloseAndLogError(contentReader, location.AccessPath) if err != nil { logger.WithFields("location", location.RealPath, "error", err).Warnf("cataloger failed") continue diff --git a/syft/pkg/cataloger/generic/cataloger_test.go b/syft/pkg/cataloger/generic/cataloger_test.go index d2aabf28c8dd..c99a91ff0290 100644 --- a/syft/pkg/cataloger/generic/cataloger_test.go +++ b/syft/pkg/cataloger/generic/cataloger_test.go @@ -16,7 +16,7 @@ import ( func Test_Cataloger(t *testing.T) { allParsedPaths := make(map[string]bool) parser := func(resolver file.Resolver, env *Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) { - allParsedPaths[reader.AccessPath()] = true + allParsedPaths[reader.Path()] = true contents, err := io.ReadAll(reader) require.NoError(t, err) diff --git a/syft/pkg/cataloger/internal/pkgtest/test_generic_parser.go b/syft/pkg/cataloger/internal/pkgtest/test_generic_parser.go index e5b44d459616..f39523706f3d 100644 --- a/syft/pkg/cataloger/internal/pkgtest/test_generic_parser.go +++ b/syft/pkg/cataloger/internal/pkgtest/test_generic_parser.go @@ -61,7 +61,7 @@ func NewCatalogTester() *CatalogTester { } func DefaultLocationComparer(x, y file.Location) bool { - return cmp.Equal(x.Coordinates, y.Coordinates) && cmp.Equal(x.VirtualPath, y.VirtualPath) + return cmp.Equal(x.Coordinates, y.Coordinates) && cmp.Equal(x.AccessPath, y.AccessPath) } func DefaultLicenseComparer(x, y pkg.License) bool { @@ -161,7 +161,7 @@ func (p *CatalogTester) WithImageResolver(t *testing.T, fixtureName string) *Cat func (p *CatalogTester) IgnoreLocationLayer() *CatalogTester { p.locationComparer = func(x, y file.Location) bool { - return cmp.Equal(x.Coordinates.RealPath, y.Coordinates.RealPath) && cmp.Equal(x.VirtualPath, y.VirtualPath) + return cmp.Equal(x.Coordinates.RealPath, y.Coordinates.RealPath) && cmp.Equal(x.AccessPath, y.AccessPath) } // we need to update the license comparer to use the ignored location layer diff --git a/syft/pkg/cataloger/java/archive_parser.go b/syft/pkg/cataloger/java/archive_parser.go index 109ea5bbcd7d..32bb0dc5e7e8 100644 --- a/syft/pkg/cataloger/java/archive_parser.go +++ b/syft/pkg/cataloger/java/archive_parser.go @@ -87,7 +87,7 @@ func uniquePkgKey(groupID string, p *pkg.Package) string { // and parse nested archives or ignore them. func newJavaArchiveParser(reader file.LocationReadCloser, detectNested bool, cfg Config) (*archiveParser, func(), error) { // fetch the last element of the virtual path - virtualElements := strings.Split(reader.AccessPath(), ":") + virtualElements := strings.Split(reader.Path(), ":") currentFilepath := virtualElements[len(virtualElements)-1] contentPath, archivePath, cleanupFn, err := saveArchiveToTmp(currentFilepath, reader) @@ -208,7 +208,7 @@ func (j *archiveParser) discoverMainPackage() (*pkg.Package, error) { ), Type: j.fileInfo.pkgType(), Metadata: pkg.JavaArchive{ - VirtualPath: j.location.AccessPath(), + VirtualPath: j.location.Path(), Manifest: manifest, ArchiveDigests: digests, }, @@ -526,7 +526,7 @@ func discoverPkgsFromOpeners(location file.Location, openers map[string]intFile. for pathWithinArchive, archiveOpener := range openers { nestedPkgs, nestedRelationships, err := discoverPkgsFromOpener(location, pathWithinArchive, archiveOpener, cfg) if err != nil { - log.WithFields("location", location.AccessPath()).Warnf("unable to discover java packages from opener: %+v", err) + log.WithFields("location", location.Path()).Warnf("unable to discover java packages from opener: %+v", err) continue } @@ -559,9 +559,9 @@ func discoverPkgsFromOpener(location file.Location, pathWithinArchive string, ar } }() - nestedPath := fmt.Sprintf("%s:%s", location.AccessPath(), pathWithinArchive) + nestedPath := fmt.Sprintf("%s:%s", location.Path(), pathWithinArchive) nestedLocation := file.NewLocationFromCoordinates(location.Coordinates) - nestedLocation.VirtualPath = nestedPath + nestedLocation.AccessPath = nestedPath gap := newGenericArchiveParserAdapter(cfg) nestedPkgs, nestedRelationships, err := gap.parseJavaArchive(nil, nil, file.LocationReadCloser{ Location: nestedLocation, @@ -584,7 +584,7 @@ func pomPropertiesByParentPath(archivePath string, location file.Location, extra for filePath, fileContents := range contentsOfMavenPropertiesFiles { pomProperties, err := parsePomProperties(filePath, strings.NewReader(fileContents)) if err != nil { - log.WithFields("contents-path", filePath, "location", location.AccessPath()).Warnf("failed to parse pom.properties: %+v", err) + log.WithFields("contents-path", filePath, "location", location.Path()).Warnf("failed to parse pom.properties: %+v", err) continue } @@ -614,7 +614,7 @@ func pomProjectByParentPath(archivePath string, location file.Location, extractP // TODO: when we support locations of paths within archives we should start passing the specific pom.xml location object instead of the top jar pomProject, err := parsePomXMLProject(filePath, strings.NewReader(fileContents), location) if err != nil { - log.WithFields("contents-path", filePath, "location", location.AccessPath()).Warnf("failed to parse pom.xml: %+v", err) + log.WithFields("contents-path", filePath, "location", location.Path()).Warnf("failed to parse pom.xml: %+v", err) continue } @@ -655,7 +655,7 @@ func newPackageFromMavenData(pomProperties pkg.JavaPomProperties, parsedPomProje // https://github.com/anchore/syft/issues/1944 vPathSuffix += ":" + pomProperties.GroupID + ":" + pomProperties.ArtifactID } - virtualPath := location.AccessPath() + vPathSuffix + virtualPath := location.Path() + vPathSuffix var pkgPomProject *pkg.JavaPomProject licenses := make([]pkg.License, 0) diff --git a/syft/pkg/cataloger/java/tar_wrapped_archive_parser.go b/syft/pkg/cataloger/java/tar_wrapped_archive_parser.go index 6f64088574c0..195940d87043 100644 --- a/syft/pkg/cataloger/java/tar_wrapped_archive_parser.go +++ b/syft/pkg/cataloger/java/tar_wrapped_archive_parser.go @@ -57,7 +57,7 @@ func newGenericTarWrappedJavaArchiveParser(cfg Config) genericTarWrappedJavaArch } func (gtp genericTarWrappedJavaArchiveParser) parseTarWrappedJavaArchive(_ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) { - contentPath, archivePath, cleanupFn, err := saveArchiveToTmp(reader.AccessPath(), reader) + contentPath, archivePath, cleanupFn, err := saveArchiveToTmp(reader.Path(), reader) // note: even on error, we should always run cleanup functions defer cleanupFn() if err != nil { diff --git a/syft/pkg/cataloger/java/zip_wrapped_archive_parser.go b/syft/pkg/cataloger/java/zip_wrapped_archive_parser.go index 1bb72afe665e..763c17240436 100644 --- a/syft/pkg/cataloger/java/zip_wrapped_archive_parser.go +++ b/syft/pkg/cataloger/java/zip_wrapped_archive_parser.go @@ -29,7 +29,7 @@ func newGenericZipWrappedJavaArchiveParser(cfg Config) genericZipWrappedJavaArch } func (gzp genericZipWrappedJavaArchiveParser) parseZipWrappedJavaArchive(_ file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) { - contentPath, archivePath, cleanupFn, err := saveArchiveToTmp(reader.AccessPath(), reader) + contentPath, archivePath, cleanupFn, err := saveArchiveToTmp(reader.Path(), reader) // note: even on error, we should always run cleanup functions defer cleanupFn() if err != nil { diff --git a/syft/pkg/cataloger/javascript/parse_package_json.go b/syft/pkg/cataloger/javascript/parse_package_json.go index 0c05aedc0e35..d0e7edbc0bed 100644 --- a/syft/pkg/cataloger/javascript/parse_package_json.go +++ b/syft/pkg/cataloger/javascript/parse_package_json.go @@ -64,7 +64,7 @@ func parsePackageJSON(_ file.Resolver, _ *generic.Environment, reader file.Locat } if !p.hasNameAndVersionValues() { - log.Debugf("encountered package.json file without a name and/or version field, ignoring (path=%q)", reader.AccessPath()) + log.Debugf("encountered package.json file without a name and/or version field, ignoring (path=%q)", reader.Path()) return nil, nil, nil } diff --git a/syft/pkg/cataloger/javascript/parse_package_lock.go b/syft/pkg/cataloger/javascript/parse_package_lock.go index 91663b1b250a..45c5a0c1f531 100644 --- a/syft/pkg/cataloger/javascript/parse_package_lock.go +++ b/syft/pkg/cataloger/javascript/parse_package_lock.go @@ -47,7 +47,7 @@ type packageLockLicense []string func parsePackageLock(resolver file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) { // in the case we find package-lock.json files in the node_modules directories, skip those // as the whole purpose of the lock file is for the specific dependencies of the root project - if pathContainsNodeModulesDirectory(reader.AccessPath()) { + if pathContainsNodeModulesDirectory(reader.Path()) { return nil, nil, nil } diff --git a/syft/pkg/cataloger/javascript/parse_yarn_lock.go b/syft/pkg/cataloger/javascript/parse_yarn_lock.go index e5fecff855d7..d42490ed30d3 100644 --- a/syft/pkg/cataloger/javascript/parse_yarn_lock.go +++ b/syft/pkg/cataloger/javascript/parse_yarn_lock.go @@ -46,7 +46,7 @@ const ( func parseYarnLock(resolver file.Resolver, _ *generic.Environment, reader file.LocationReadCloser) ([]pkg.Package, []artifact.Relationship, error) { // in the case we find yarn.lock files in the node_modules directories, skip those // as the whole purpose of the lock file is for the specific dependencies of the project - if pathContainsNodeModulesDirectory(reader.AccessPath()) { + if pathContainsNodeModulesDirectory(reader.Path()) { return nil, nil, nil } diff --git a/syft/pkg/cataloger/python/parse_wheel_egg.go b/syft/pkg/cataloger/python/parse_wheel_egg.go index f09d1c8cd841..e98fe9de898a 100644 --- a/syft/pkg/cataloger/python/parse_wheel_egg.go +++ b/syft/pkg/cataloger/python/parse_wheel_egg.go @@ -112,7 +112,7 @@ func fetchTopLevelPackages(resolver file.Resolver, metadataLocation file.Locatio if err != nil { return nil, nil, err } - defer internal.CloseAndLogError(topLevelContents, topLevelLocation.VirtualPath) + defer internal.CloseAndLogError(topLevelContents, topLevelLocation.AccessPath) scanner := bufio.NewScanner(topLevelContents) for scanner.Scan() { @@ -162,7 +162,7 @@ func fetchDirectURLData(resolver file.Resolver, metadataLocation file.Location) if err != nil { return nil, nil, err } - defer internal.CloseAndLogError(directURLContents, directURLLocation.VirtualPath) + defer internal.CloseAndLogError(directURLContents, directURLLocation.AccessPath) buffer, err := io.ReadAll(directURLContents) if err != nil { @@ -191,7 +191,7 @@ func assembleEggOrWheelMetadata(resolver file.Resolver, metadataLocation file.Lo if err != nil { return nil, nil, err } - defer internal.CloseAndLogError(metadataContents, metadataLocation.VirtualPath) + defer internal.CloseAndLogError(metadataContents, metadataLocation.AccessPath) pd, err := parseWheelOrEggMetadata(metadataLocation.RealPath, metadataContents) if err != nil { diff --git a/syft/pkg/license_set_test.go b/syft/pkg/license_set_test.go index b49274d13009..15da2bb761d8 100644 --- a/syft/pkg/license_set_test.go +++ b/syft/pkg/license_set_test.go @@ -139,7 +139,7 @@ func TestLicenseSet_Add(t *testing.T) { } func defaultLocationComparer(x, y file.Location) bool { - return cmp.Equal(x.Coordinates, y.Coordinates) && cmp.Equal(x.VirtualPath, y.VirtualPath) + return cmp.Equal(x.Coordinates, y.Coordinates) && cmp.Equal(x.AccessPath, y.AccessPath) } func defaultLicenseComparer(x, y License) bool { diff --git a/syft/pkg/package_test.go b/syft/pkg/package_test.go index ff07bd51a8fc..20e2031ef150 100644 --- a/syft/pkg/package_test.go +++ b/syft/pkg/package_test.go @@ -429,7 +429,7 @@ func licenseComparer(x, y License) bool { } func locationComparer(x, y file.Location) bool { - return cmp.Equal(x.Coordinates, y.Coordinates) && cmp.Equal(x.VirtualPath, y.VirtualPath) + return cmp.Equal(x.Coordinates, y.Coordinates) && cmp.Equal(x.AccessPath, y.AccessPath) } func TestIsValid(t *testing.T) {