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 vex.EffectiveStatement deprecate StatementFromID #30

Merged
merged 1 commit into from
Jun 10, 2023

Conversation

puerco
Copy link
Member

@puerco puerco commented Apr 17, 2023

This commit adds a new method to vex.EffectiveStatement that takes a product and a vulnerability ID and returns the latest known impact statement.

It also adds a deprecation notice to vex.StatementFromID() as that function is wrongly designed (the product is required to know the latest impact statement). I added a hack to make it more or less do what it was intended to, but it will still be removed at some point.

Fixes #29

Signed-off-by: Adolfo García Veytia (Puerco) puerco@chainguard.dev

vex.EffectiveStatement replaces the now deprecated vex.StatementFromID method to compute the latest known status of a product+vuln combo 

pkg/vex/vex.go Show resolved Hide resolved
pkg/vex/vex.go Outdated Show resolved Hide resolved
@@ -169,12 +169,39 @@ func (vexDoc *VEX) ToJSON(w io.Writer) error {
return nil
}

// EffectiveStatement returns the latest VEX statement for a given product, that
// is the statement that contains the latest data about impact to a given product.
func (vexDoc *VEX) EffectiveStatement(product, vulnID string) (s *Statement) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if it'd be simpler to start by calling SortStatements to do the time sort.

And then you can go latest-to-oldest, doing the "does this statement refer to the given product?" check, and return the statement the first time the answer is "yes". WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, changed 👍

pkg/vex/vex.go Outdated Show resolved Hide resolved
This commit adds a new method vex.EffectiveStatement that takes a product
and a vulnerability ID and returns the latest known impact statement.

It also deprectares StatementFromID as that function is wrongly designed
(product is required to know the latest impact statement).

Signed-off-by: Adolfo García Veytia (Puerco) <puerco@chainguard.dev>
@puerco puerco merged commit a3ed304 into openvex:main Jun 10, 2023
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.

Take the latest statement
3 participants