Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abstraction for adding relationships from package cataloger results #2853

Merged
merged 11 commits into from May 14, 2024

Conversation

wagoodman
Copy link
Contributor

@wagoodman wagoodman commented May 7, 2024

I made an observation that while implementing more features for #572 that there are multiple catalogers that have almost the same logic to find relationships from a collection of homogenous packages. This PR refactors those spots to use the same abstraction.

Specifically, this PR adds a new internal/dependency package that contains:

  • a Specifier function type which extracts strings that are sensitive to package resource requirements and resource provides claims from a single package, normalized as strings. A Specification collects all Provides and Requires claims into a single data type.
  • A Resolver that uses a given Specifier and a collection of packages to create relationships between the given packages

This abstraction has been leveraged in both the dpkg, alpm, and apk catalogers.

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman wagoodman self-assigned this May 7, 2024
@wagoodman wagoodman marked this pull request as ready for review May 7, 2024 19:28
@wagoodman wagoodman requested a review from a team May 7, 2024 19:28
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
syft/pkg/cataloger/arch/prosumer.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/debian/parse_dpkg_db_test.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/debian/prosumer.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/arch/prosumer.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/arch/prosumer.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/arch/prosumer.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/debian/prosumer.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/internal/dependency/resolver.go Outdated Show resolved Hide resolved
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Copy link
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.

👍

syft/pkg/cataloger/internal/dependency/resolver.go Outdated Show resolved Hide resolved
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
@wagoodman wagoodman enabled auto-merge (squash) May 14, 2024 13:18
@wagoodman wagoodman merged commit 4a18895 into main May 14, 2024
11 checks passed
@wagoodman wagoodman deleted the refactor-relationship-resolution branch May 14, 2024 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants