diff --git a/internal/formats/common/spdxhelpers/to_syft_model.go b/internal/formats/common/spdxhelpers/to_syft_model.go index 4f5db9944..4f0fd5e24 100644 --- a/internal/formats/common/spdxhelpers/to_syft_model.go +++ b/internal/formats/common/spdxhelpers/to_syft_model.go @@ -191,7 +191,7 @@ func toSyftCoordinates(f *spdx.File2_2) file.Coordinates { func toSyftLocation(f *spdx.File2_2) *file.Location { return &file.Location{ Coordinates: toSyftCoordinates(f), - VirtualPath: f.FileName, + AccessPath: f.FileName, } } diff --git a/syft/file/cataloger/fileclassifier/classifier.go b/syft/file/cataloger/fileclassifier/classifier.go index c4d39d3b3..1103432d7 100644 --- a/syft/file/cataloger/fileclassifier/classifier.go +++ b/syft/file/cataloger/fileclassifier/classifier.go @@ -80,7 +80,7 @@ func (c Classifier) Classify(resolver source.FileResolver, location file.Locatio if err != nil { return nil, err } - defer internal.CloseAndLogError(contentReader, location.VirtualPath) + defer internal.CloseAndLogError(contentReader, location.AccessPath) // TODO: there is room for improvement here, as this may use an excessive amount of memory. Alternate approach is to leverage a RuneReader. contents, err := ioutil.ReadAll(contentReader) @@ -126,7 +126,7 @@ func (c Classifier) Classify(resolver source.FileResolver, location file.Locatio } func filepathMatches(patterns []*regexp.Regexp, location file.Location) (bool, map[string]string) { - for _, path := range []string{location.RealPath, location.VirtualPath} { + for _, path := range []string{location.RealPath, location.AccessPath} { if path == "" { continue } diff --git a/syft/file/cataloger/fileclassifier/classifier_test.go b/syft/file/cataloger/fileclassifier/classifier_test.go index 475a221d3..1c684fcf5 100644 --- a/syft/file/cataloger/fileclassifier/classifier_test.go +++ b/syft/file/cataloger/fileclassifier/classifier_test.go @@ -43,7 +43,7 @@ func TestFilepathMatches(t *testing.T) { { name: "virtual-filepath-match", location: file.Location{ - VirtualPath: "/usr/bin/python2.7", + AccessPath: "/usr/bin/python2.7", }, patterns: []string{ `python([0-9]+\.[0-9]+)$`, @@ -53,7 +53,7 @@ func TestFilepathMatches(t *testing.T) { { name: "full-filepath-match", location: file.Location{ - VirtualPath: "/usr/bin/python2.7", + AccessPath: "/usr/bin/python2.7", }, patterns: []string{ `.*/bin/python([0-9]+\.[0-9]+)$`, diff --git a/syft/file/cataloger/filecontents/cataloger.go b/syft/file/cataloger/filecontents/cataloger.go index fb0f15e43..84038728f 100644 --- a/syft/file/cataloger/filecontents/cataloger.go +++ b/syft/file/cataloger/filecontents/cataloger.go @@ -72,7 +72,7 @@ func (i *Cataloger) catalogLocation(resolver source.FileResolver, location file. 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/filedigests/cataloger.go b/syft/file/cataloger/filedigests/cataloger.go index 45c11ae9a..b2b93bcc6 100644 --- a/syft/file/cataloger/filedigests/cataloger.go +++ b/syft/file/cataloger/filedigests/cataloger.go @@ -72,7 +72,7 @@ func (i *Cataloger) catalogLocation(resolver source.FileResolver, location file. if err != nil { return nil, err } - defer internal.CloseAndLogError(contentReader, location.VirtualPath) + defer internal.CloseAndLogError(contentReader, location.AccessPath) // create a set of hasher objects tied together with a single writer to feed content into hashers := make([]hash.Hash, len(i.hashes)) diff --git a/syft/file/cataloger/secrets/cataloger.go b/syft/file/cataloger/secrets/cataloger.go index 9b43d7d8f..37e757390 100644 --- a/syft/file/cataloger/secrets/cataloger.go +++ b/syft/file/cataloger/secrets/cataloger.go @@ -125,7 +125,7 @@ func extractValue(resolver source.FileResolver, location file.Location, start, l 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(ioutil.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 bfd2507d3..d946cde1d 100644 --- a/syft/file/cataloger/secrets/secrets_search_by_line_strategy.go +++ b/syft/file/cataloger/secrets/secrets_search_by_line_strategy.go @@ -20,7 +20,7 @@ func catalogLocationByLine(resolver source.FileResolver, location file.Location, 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 @@ -69,7 +69,7 @@ func searchForSecretsWithinLine(resolver source.FileResolver, location file.Loca 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 cfde75cc7..7fcf1d27b 100644 --- a/syft/file/location.go +++ b/syft/file/location.go @@ -14,8 +14,8 @@ type Location 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"` // 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"` // 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. } // NewLocation creates a new Location representing a path without denoting a filesystem or FileCatalog reference. @@ -28,12 +28,12 @@ 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{ Coordinates: Coordinates{ RealPath: realPath, }, - VirtualPath: virtualPath, + AccessPath: accessPath, } } @@ -45,7 +45,7 @@ func NewLocationFromCoordinates(coordinates Coordinates) Location { } // NewLocationFromImage creates a new Location representing the given path (extracted from the ref) 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 { entry, err := img.FileCatalog.Get(ref) if err != nil { log.Warnf("unable to find file catalog entry for ref=%+v", ref) @@ -53,8 +53,8 @@ func NewLocationFromImage(virtualPath string, ref file.Reference, img *image.Ima Coordinates: Coordinates{ RealPath: string(ref.RealPath), }, - VirtualPath: virtualPath, - ref: ref, + AccessPath: accessPath, + ref: ref, } } @@ -63,8 +63,8 @@ func NewLocationFromImage(virtualPath string, ref file.Reference, img *image.Ima RealPath: string(ref.RealPath), FileSystemID: entry.Layer.Metadata.Digest, }, - VirtualPath: virtualPath, - ref: ref, + AccessPath: accessPath, + ref: ref, } } @@ -87,8 +87,8 @@ func NewVirtualLocationFromDirectory(responsePath, virtualResponsePath string, r Coordinates: Coordinates{ RealPath: responsePath, }, - VirtualPath: virtualResponsePath, - ref: ref, + AccessPath: virtualResponsePath, + ref: ref, } } @@ -100,8 +100,8 @@ func (l Location) String() string { str += fmt.Sprintf("RealPath=%q", l.RealPath) - if l.VirtualPath != "" { - str += fmt.Sprintf(" VirtualPath=%q", l.VirtualPath) + if l.AccessPath != "" { + str += fmt.Sprintf(" AccessPath=%q", l.AccessPath) } if l.FileSystemID != "" { diff --git a/syft/file/location_test.go b/syft/file/location_test.go index 59d927b07..55ed49271 100644 --- a/syft/file/location_test.go +++ b/syft/file/location_test.go @@ -11,7 +11,7 @@ func TestLocation_ID(t *testing.T) { tests := []struct { name string coordinates Coordinates - virtualPath string + accessPath string ref file.Reference }{ { @@ -27,7 +27,7 @@ func TestLocation_ID(t *testing.T) { RealPath: "path!", FileSystemID: "filesystem!", }, - virtualPath: "virtualPath!", + accessPath: "accessPath!", ref: file.Reference{ RealPath: "other-real-path!", }, @@ -37,7 +37,7 @@ func TestLocation_ID(t *testing.T) { t.Run(test.name, func(t *testing.T) { l := Location{ Coordinates: test.coordinates, - VirtualPath: test.virtualPath, + AccessPath: test.accessPath, ref: test.ref, } assert.Equal(t, l.ID(), test.coordinates.ID()) diff --git a/syft/linux/identify_release.go b/syft/linux/identify_release.go index ec95dabcf..63bcd2b59 100644 --- a/syft/linux/identify_release.go +++ b/syft/linux/identify_release.go @@ -69,7 +69,7 @@ func IdentifyRelease(resolver source.FileResolver) *Release { } content, err := ioutil.ReadAll(contentReader) - internal.CloseAndLogError(contentReader, location.VirtualPath) + internal.CloseAndLogError(contentReader, location.AccessPath) if err != nil { log.Warnf("unable to read %q: %+v", location.RealPath, err) break diff --git a/syft/pkg/catalog.go b/syft/pkg/catalog.go index 1c8e8db56..b51714176 100644 --- a/syft/pkg/catalog.go +++ b/syft/pkg/catalog.go @@ -94,9 +94,9 @@ func (c *Catalog) Add(p Package) { c.idsByPath[l.RealPath] = append(c.idsByPath[l.RealPath], id) observedPaths.Add(l.RealPath) } - if l.VirtualPath != "" && l.RealPath != l.VirtualPath && !observedPaths.Contains(l.VirtualPath) { - c.idsByPath[l.VirtualPath] = append(c.idsByPath[l.VirtualPath], id) - observedPaths.Add(l.VirtualPath) + if l.AccessPath != "" && l.RealPath != l.AccessPath && !observedPaths.Contains(l.AccessPath) { + c.idsByPath[l.AccessPath] = append(c.idsByPath[l.AccessPath], id) + observedPaths.Add(l.AccessPath) } } } diff --git a/syft/pkg/cataloger/deb/cataloger.go b/syft/pkg/cataloger/deb/cataloger.go index 9181626f6..85d6e60c3 100644 --- a/syft/pkg/cataloger/deb/cataloger.go +++ b/syft/pkg/cataloger/deb/cataloger.go @@ -53,7 +53,7 @@ func (c *Cataloger) Catalog(resolver source.FileResolver) ([]pkg.Package, []arti } pkgs, err := parseDpkgStatus(dbContents) - internal.CloseAndLogError(dbContents, dbLocation.VirtualPath) + internal.CloseAndLogError(dbContents, dbLocation.AccessPath) if err != nil { log.Warnf("dpkg cataloger: unable to catalog package=%+v: %w", dbLocation.RealPath, err) continue @@ -85,7 +85,7 @@ func addLicenses(resolver source.FileResolver, dbLocation file.Location, p *pkg. copyrightReader, copyrightLocation := fetchCopyrightContents(resolver, dbLocation, p) if copyrightReader != nil && copyrightLocation != nil { - defer internal.CloseAndLogError(copyrightReader, copyrightLocation.VirtualPath) + defer internal.CloseAndLogError(copyrightReader, copyrightLocation.AccessPath) // attach the licenses p.Licenses = parseLicensesFromCopyright(copyrightReader) @@ -130,7 +130,7 @@ func getAdditionalFileListing(resolver source.FileResolver, dbLocation file.Loca md5Reader, md5Location := fetchMd5Contents(resolver, dbLocation, p) 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)...) @@ -141,7 +141,7 @@ func getAdditionalFileListing(resolver source.FileResolver, dbLocation file.Loca conffilesReader, conffilesLocation := fetchConffileContents(resolver, dbLocation, p) 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/generic/cataloger.go b/syft/pkg/cataloger/generic/cataloger.go index 320306ecf..1f6913f34 100644 --- a/syft/pkg/cataloger/generic/cataloger.go +++ b/syft/pkg/cataloger/generic/cataloger.go @@ -51,7 +51,7 @@ func (c *Cataloger) Catalog(resolver source.FileResolver) ([]pkg.Package, []arti } discoveredPackages, discoveredRelationships, err := parser(location.RealPath, contentReader) - internal.CloseAndLogError(contentReader, location.VirtualPath) + internal.CloseAndLogError(contentReader, location.AccessPath) if err != nil { // TODO: should we fail? or only log? log.Warnf("cataloger '%s' failed to parse entries at location=%+v: %+v", c.upstreamCataloger, location, err) diff --git a/syft/pkg/cataloger/python/package_cataloger.go b/syft/pkg/cataloger/python/package_cataloger.go index c546c73f9..53d40dae6 100644 --- a/syft/pkg/cataloger/python/package_cataloger.go +++ b/syft/pkg/cataloger/python/package_cataloger.go @@ -142,7 +142,7 @@ func (c *PackageCataloger) fetchTopLevelPackages(resolver source.FileResolver, m 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() { @@ -171,7 +171,7 @@ func (c *PackageCataloger) fetchDirectURLData(resolver source.FileResolver, meta if err != nil { return nil, nil, err } - defer internal.CloseAndLogError(directURLContents, directURLLocation.VirtualPath) + defer internal.CloseAndLogError(directURLContents, directURLLocation.AccessPath) buffer, err := ioutil.ReadAll(directURLContents) if err != nil { @@ -198,7 +198,7 @@ func (c *PackageCataloger) assembleEggOrWheelMetadata(resolver source.FileResolv if err != nil { return nil, nil, err } - defer internal.CloseAndLogError(metadataContents, metadataLocation.VirtualPath) + defer internal.CloseAndLogError(metadataContents, metadataLocation.AccessPath) metadata, err := parseWheelOrEggMetadata(metadataLocation.RealPath, metadataContents) if err != nil { diff --git a/syft/pkg/cataloger/rpmdb/cataloger.go b/syft/pkg/cataloger/rpmdb/cataloger.go index 4571e67e4..1dc6b5832 100644 --- a/syft/pkg/cataloger/rpmdb/cataloger.go +++ b/syft/pkg/cataloger/rpmdb/cataloger.go @@ -42,7 +42,7 @@ func (c *Cataloger) Catalog(resolver source.FileResolver) ([]pkg.Package, []arti } discoveredPkgs, err := parseRpmDB(resolver, location, dbContentReader) - internal.CloseAndLogError(dbContentReader, location.VirtualPath) + internal.CloseAndLogError(dbContentReader, location.AccessPath) if err != nil { return nil, nil, fmt.Errorf("unable to catalog rpmdb package=%+v: %w", location.RealPath, err) } diff --git a/syft/pkg/package_test.go b/syft/pkg/package_test.go index fc3332721..714e08459 100644 --- a/syft/pkg/package_test.go +++ b/syft/pkg/package_test.go @@ -18,7 +18,7 @@ func TestFingerprint(t *testing.T) { RealPath: "39.0742° N, 21.8243° E", FileSystemID: "Earth", }, - VirtualPath: "/Ancient-Greece", + AccessPath: "/Ancient-Greece", }, }, Licenses: []string{ diff --git a/syft/source/all_layers_resolver.go b/syft/source/all_layers_resolver.go index 9d540ce44..e9173172c 100644 --- a/syft/source/all_layers_resolver.go +++ b/syft/source/all_layers_resolver.go @@ -193,10 +193,10 @@ func (r *allLayersResolver) FileContentsByLocation(location file.Location) (io.R switch entry.Metadata.TypeFlag { case tar.TypeSymlink, tar.TypeLink: // 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 } diff --git a/syft/source/all_layers_resolver_test.go b/syft/source/all_layers_resolver_test.go index 317e24e12..4128c7095 100644 --- a/syft/source/all_layers_resolver_test.go +++ b/syft/source/all_layers_resolver_test.go @@ -381,59 +381,59 @@ func Test_imageAllLayersResolver_resolvesLinks(t *testing.T) { Coordinates: file.Coordinates{ RealPath: "/etc/group", }, - VirtualPath: "/etc/group", + AccessPath: "/etc/group", }, { Coordinates: file.Coordinates{ RealPath: "/etc/passwd", }, - VirtualPath: "/etc/passwd", + AccessPath: "/etc/passwd", }, { Coordinates: file.Coordinates{ RealPath: "/etc/shadow", }, - VirtualPath: "/etc/shadow", + AccessPath: "/etc/shadow", }, { Coordinates: file.Coordinates{ RealPath: "/file-1.txt", }, - VirtualPath: "/file-1.txt", + AccessPath: "/file-1.txt", }, // copy 1 { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/file-2.txt", + AccessPath: "/file-2.txt", }, { Coordinates: file.Coordinates{ RealPath: "/file-3.txt", }, - VirtualPath: "/file-3.txt", + AccessPath: "/file-3.txt", }, // copy 2 { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/file-2.txt", + AccessPath: "/file-2.txt", }, // copy 1 { Coordinates: file.Coordinates{ RealPath: "/parent/file-4.txt", }, - VirtualPath: "/parent/file-4.txt", + AccessPath: "/parent/file-4.txt", }, // copy 2 { Coordinates: file.Coordinates{ RealPath: "/parent/file-4.txt", }, - VirtualPath: "/parent/file-4.txt", + AccessPath: "/parent/file-4.txt", }, }, }, @@ -450,27 +450,27 @@ func Test_imageAllLayersResolver_resolvesLinks(t *testing.T) { Coordinates: file.Coordinates{ RealPath: "/file-1.txt", }, - VirtualPath: "/link-1", + AccessPath: "/link-1", }, // copy 1 { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/link-2", + AccessPath: "/link-2", }, // copy 2 { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/link-2", + AccessPath: "/link-2", }, { Coordinates: file.Coordinates{ RealPath: "/file-3.txt", }, - VirtualPath: "/link-within", + AccessPath: "/link-within", }, }, }, @@ -488,13 +488,13 @@ func Test_imageAllLayersResolver_resolvesLinks(t *testing.T) { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/link-2", + AccessPath: "/link-2", }, { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/link-2", + AccessPath: "/link-2", }, }, }, @@ -512,13 +512,13 @@ func Test_imageAllLayersResolver_resolvesLinks(t *testing.T) { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/link-indirect", + AccessPath: "/link-indirect", }, { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/link-indirect", + AccessPath: "/link-indirect", }, }, }, @@ -536,7 +536,7 @@ func Test_imageAllLayersResolver_resolvesLinks(t *testing.T) { assert.Len(t, actualLocations, len(test.expected)) for i, actual := range actualLocations { assert.Equal(t, test.expected[i].RealPath, actual.RealPath) - assert.Equal(t, test.expected[i].VirtualPath, actual.VirtualPath) + assert.Equal(t, test.expected[i].AccessPath, actual.AccessPath) } }) } diff --git a/syft/source/all_regular_files_test.go b/syft/source/all_regular_files_test.go index 24c378948..0f7a7b161 100644 --- a/syft/source/all_regular_files_test.go +++ b/syft/source/all_regular_files_test.go @@ -10,8 +10,8 @@ import ( func Test_allRegularFiles(t *testing.T) { type access struct { - realPath string - virtualPath string + realPath string + accessPath string } tests := []struct { name string @@ -56,8 +56,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) } } assert.ElementsMatch(t, tt.wantRealPaths.List(), realLocations.List(), "mismatched real paths") diff --git a/syft/source/directory_resolver.go b/syft/source/directory_resolver.go index 4b6f30d4a..e5b6f99b8 100644 --- a/syft/source/directory_resolver.go +++ b/syft/source/directory_resolver.go @@ -261,7 +261,7 @@ func (r directoryResolver) addSymlinkToIndex(p string, info os.FileInfo) (string } location := file.NewLocationFromDirectory(p, *ref) - location.VirtualPath = p + location.AccessPath = p metadata := file.MetadataFromPath(p, usedInfo, r.isInIndex(location)) metadata.LinkDestination = linkTarget r.addFileMetadataToIndex(ref, metadata) diff --git a/syft/source/directory_resolver_test.go b/syft/source/directory_resolver_test.go index 94bc5094b..75acbf92c 100644 --- a/syft/source/directory_resolver_test.go +++ b/syft/source/directory_resolver_test.go @@ -634,14 +634,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_*") @@ -661,7 +661,7 @@ func Test_IndexingNestedSymLinks(t *testing.T) { actualRealPaths := strset.New() actualVirtualPaths := strset.New() for _, a := range locations { - actualVirtualPaths.Add(a.VirtualPath) + actualVirtualPaths.Add(a.AccessPath) actualRealPaths.Add(a.RealPath) } diff --git a/syft/source/excluding_file_resolver.go b/syft/source/excluding_file_resolver.go index 9c20ec61b..97e54aa81 100644 --- a/syft/source/excluding_file_resolver.go +++ b/syft/source/excluding_file_resolver.go @@ -83,7 +83,7 @@ func (r *excludingResolver) 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/source/excluding_file_resolver_test.go b/syft/source/excluding_file_resolver_test.go index e45082c0f..e9d75b5a1 100644 --- a/syft/source/excluding_file_resolver_test.go +++ b/syft/source/excluding_file_resolver_test.go @@ -124,7 +124,7 @@ func makeLocation(path string) file.Location { RealPath: path, FileSystemID: "", }, - VirtualPath: "", + AccessPath: "", } } diff --git a/syft/source/image_squash_resolver_test.go b/syft/source/image_squash_resolver_test.go index 0ffc1fd64..4eb53a851 100644 --- a/syft/source/image_squash_resolver_test.go +++ b/syft/source/image_squash_resolver_test.go @@ -364,43 +364,43 @@ func Test_imageSquashResolver_resolvesLinks(t *testing.T) { Coordinates: file.Coordinates{ RealPath: "/etc/group", }, - VirtualPath: "/etc/group", + AccessPath: "/etc/group", }, { Coordinates: file.Coordinates{ RealPath: "/etc/passwd", }, - VirtualPath: "/etc/passwd", + AccessPath: "/etc/passwd", }, { Coordinates: file.Coordinates{ RealPath: "/etc/shadow", }, - VirtualPath: "/etc/shadow", + AccessPath: "/etc/shadow", }, { Coordinates: file.Coordinates{ RealPath: "/file-1.txt", }, - VirtualPath: "/file-1.txt", + AccessPath: "/file-1.txt", }, { Coordinates: file.Coordinates{ RealPath: "/file-3.txt", }, - VirtualPath: "/file-3.txt", + AccessPath: "/file-3.txt", }, { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/file-2.txt", + AccessPath: "/file-2.txt", }, { Coordinates: file.Coordinates{ RealPath: "/parent/file-4.txt", }, - VirtualPath: "/parent/file-4.txt", + AccessPath: "/parent/file-4.txt", }, }, }, @@ -417,19 +417,19 @@ func Test_imageSquashResolver_resolvesLinks(t *testing.T) { Coordinates: file.Coordinates{ RealPath: "/file-3.txt", }, - VirtualPath: "/link-within", + AccessPath: "/link-within", }, { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/link-2", + AccessPath: "/link-2", }, { Coordinates: file.Coordinates{ RealPath: "/file-1.txt", }, - VirtualPath: "/link-1", + AccessPath: "/link-1", }, }, }, @@ -447,7 +447,7 @@ func Test_imageSquashResolver_resolvesLinks(t *testing.T) { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/link-2", + AccessPath: "/link-2", }, }, }, @@ -465,7 +465,7 @@ func Test_imageSquashResolver_resolvesLinks(t *testing.T) { Coordinates: file.Coordinates{ RealPath: "/file-2.txt", }, - VirtualPath: "/link-indirect", + AccessPath: "/link-indirect", }, }, }, @@ -486,12 +486,12 @@ func Test_imageSquashResolver_resolvesLinks(t *testing.T) { expectedMap := make(map[string]string) for _, e := range test.expected { - expectedMap[e.VirtualPath] = e.RealPath + expectedMap[e.AccessPath] = e.RealPath } actualMap := make(map[string]string) for _, a := range test.expected { - actualMap[a.VirtualPath] = a.RealPath + actualMap[a.AccessPath] = a.RealPath } assert.Equal(t, expectedMap, actualMap)