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

CPE definition on pkg.Package is coupled to an external package as a type alias #2529

Closed
wagoodman opened this issue Jan 22, 2024 · 1 comment · Fixed by #2534
Closed

CPE definition on pkg.Package is coupled to an external package as a type alias #2529

wagoodman opened this issue Jan 22, 2024 · 1 comment · Fixed by #2534
Assignees
Labels
breaking-change Change is not backwards compatible bug Something isn't working
Milestone

Comments

@wagoodman
Copy link
Contributor

Today we have the CPEs field on the pkg.Package struct:

CPEs []cpe.CPE `hash:"ignore"` // all possible Common Platform Enumerators (note: this is NOT included in the definition of the ID since all fields on a CPE are derived from other fields)

However, the cpe.CPE definition is a type alias:

type CPE = wfn.Attributes

This isn't good for a couple of reasons:

  • type aliases are really intended for making refactors easier, not for permanently defining a type
  • the underlying type behavior or shape can change out from underneath us without warning

Ideally we should have an internal type that represents a CPE and has the basic functionality we need within syft. Downstream consumers (such as grype) that require additional behaviors (e.g. CPE matching or comparison) should use abstractions to protect against direct use of the upstream wfn package.

@wagoodman wagoodman added the bug Something isn't working label Jan 22, 2024
@wagoodman wagoodman added this to the Syft 1.0 milestone Jan 22, 2024
@wagoodman wagoodman added the breaking-change Change is not backwards compatible label Jan 22, 2024
@willmurphyscode
Copy link
Contributor

I think that making an identically laid out struct that Syft controls, and wrapping the type conversion in helper methods will prevent us from having break changes here. Example conversion: https://go.dev/play/p/f5VDwwTYBb8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Change is not backwards compatible bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants