Skip to content

Resolve owned file paths when searching for overlaps#3828

Merged
wagoodman merged 2 commits intomainfrom
resolve-owned-file-paths
Apr 24, 2025
Merged

Resolve owned file paths when searching for overlaps#3828
wagoodman merged 2 commits intomainfrom
resolve-owned-file-paths

Conversation

@wagoodman
Copy link
Copy Markdown
Contributor

@wagoodman wagoodman commented Apr 24, 2025

Today we add relationships between packages that overlap in file ownership, say when the python cataloger finds a package at path X and the debian DB cataloger also finds the same package at the same file path X --in this case we leave both packages and add a file-ownership-by-overlap relationship between them. In the case where the same path conflict occurs and this is between a binary file and a debian package then we remove the binary package altogether.

The problem is that package ownership locations are unresolved strings (copied from the RPM DB or the Dpkg DB, etc) and the package locations are resolved real paths. This can cause issues int he case of anchore/grype#2527 where the debian package writes through the /bin symlink to the realpath of /usr/bin to drop in the gzip binary.

This PR fixes this behavior by just-in-time attempting to resolve any paths from the FileOwner

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have added unit tests that cover changed behavior
  • I have tested my code in common scenarios and confirmed there are no regressions
  • I have added comments to my code, particularly in hard-to-understand sections

TODO

  • Check the performance implications of putting path resolutions in the relationship creation path

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman wagoodman self-assigned this Apr 24, 2025
@wagoodman wagoodman marked this pull request as ready for review April 24, 2025 21:24
Comment thread internal/relationship/by_file_ownership.go
Comment thread internal/relationship/by_file_ownership.go
Comment thread internal/relationship/by_file_ownership.go Outdated
Comment thread internal/relationship/by_file_ownership.go
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman wagoodman enabled auto-merge (squash) April 24, 2025 21:41
@wagoodman wagoodman merged commit 03fa142 into main Apr 24, 2025
13 checks passed
@wagoodman wagoodman deleted the resolve-owned-file-paths branch April 24, 2025 21:59
spiffcs added a commit that referenced this pull request Apr 29, 2025
* main: (150 commits)
  fix the fluent-bit regex detection pattern (#3817)
  chore(deps): bump anchore/sbom-action from 0.18.0 to 0.19.0 (#3832)
  chore(deps): update tools to latest versions (#3830)
  Resolve owned file paths when searching for overlaps (#3828)
  chore(deps): update anchore dependencies (#3827)
  fix: Make the fileresolver Support Prefix Match of Files (#3820)
  Add support for detecting javascript assets in .NET projects using libman (#3825)
  chore(deps): update tools to latest versions (#3823)
  (feat): support skipping archive extraction with file source (#3795)
  Consider DLL claims for dependencies of .NET packages from deps.json (#3822)
  PE cataloger should consider compile target paths from deps.json (#3821)
  Perf: skip license scanner injection (#3796)
  chore(deps): bump sigstore/cosign-installer from 3.8.1 to 3.8.2 (#3818)
  chore(deps): bump github/codeql-action from 3.28.15 to 3.28.16 (#3819)
  chore(deps): update tools to latest versions (#3815)
  docs: document test commands (#3816)
  Support detection of Chrome binaries (#3136)
  fix:allow golang tip image detection regex pattern (#3757)
  fix:Make the parse of the replace part in ```go.mod``` more compliant and traceable (#3812)
  (fix): delete collection name/type key entries when empty (#3797)
  ...

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
spiffcs added a commit that referenced this pull request May 1, 2025
* main: (142 commits)
  feat: detect when full license text has been provided and preserve as separate field (#3450)
  chore(deps): bump github.com/Masterminds/semver/v3 from 3.3.0 to 3.3.1 (#3843)
  chore(deps): update tools to latest versions (#3841)
  Update github.com/Masterminds/semver to v3 (#3836)
  Add support for PHP Pear (#2775)
  fix: Improve detection of erlang binary in alpine Linux (#3839)
  fix:Resolve ancestral symlinks correctly (#3783)
  chore(deps): update CPE dictionary index (#3834)
  chore(deps): update tools to latest versions (#3835)
  chore(deps): bump github.com/charmbracelet/bubbletea from 1.3.4 to 1.3.5 (#3838)
  fix the fluent-bit regex detection pattern (#3817)
  chore(deps): bump anchore/sbom-action from 0.18.0 to 0.19.0 (#3832)
  chore(deps): update tools to latest versions (#3830)
  Resolve owned file paths when searching for overlaps (#3828)
  chore(deps): update anchore dependencies (#3827)
  fix: Make the fileresolver Support Prefix Match of Files (#3820)
  Add support for detecting javascript assets in .NET projects using libman (#3825)
  chore(deps): update tools to latest versions (#3823)
  (feat): support skipping archive extraction with file source (#3795)
  Consider DLL claims for dependencies of .NET packages from deps.json (#3822)
  ...

Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants