Skip to content

fix(relationship): favor real paths over symlinks for ownership by file#3923

Merged
kzantow merged 4 commits intoanchore:mainfrom
luhring:apk-fight
May 23, 2025
Merged

fix(relationship): favor real paths over symlinks for ownership by file#3923
kzantow merged 4 commits intoanchore:mainfrom
luhring:apk-fight

Conversation

@luhring
Copy link
Copy Markdown
Contributor

@luhring luhring commented May 20, 2025

Description

This adjusts the way "ownership by file" relationships are formed, by preventing the scenario where a symlinked path can cause two packages to "own" the same package (one via the real path, and the other via the symlink). Now, when we're about to form a relationship via a symlink, we first check to see if there's a non-symlink ownership that exists, which should prevent the symlink-based relationship from being created.

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

luhring added 2 commits May 20, 2025 15:08
…mlinks

Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
Signed-off-by: Dan Luhring <dluhring@chainguard.dev>
Comment thread internal/relationship/by_file_ownership.go Outdated
Copy link
Copy Markdown
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @luhring! 👍

@kzantow kzantow merged commit bbf3bb5 into anchore:main May 23, 2025
12 checks passed
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.

Syft incorrectly reports multiple APKs as parents of symlinked files

2 participants