Skip to content
New issue

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

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

Already on GitHub? # 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.

wagoodman added 2 commits May 7, 2024 13:30
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
wagoodman added 7 commits May 13, 2024 17:59
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
@wagoodman wagoodman added the enhancement New feature or request label May 28, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants