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

expose cve_statuses on api/v1/sbom/{id}/advisory #1145

Open
JimFuller-RedHat opened this issue Jan 15, 2025 · 8 comments
Open

expose cve_statuses on api/v1/sbom/{id}/advisory #1145

JimFuller-RedHat opened this issue Jan 15, 2025 · 8 comments

Comments

@JimFuller-RedHat
Copy link
Collaborator

JimFuller-RedHat commented Jan 15, 2025

Now that we have the ability to filter on cve statuses for cves on an sbom's advisory we should expose via endpoint api/v1/sbom/{id}/advisory.

It is unclear how we can add this kind of nested query param to our default ?q= approach .. I am pretty sure we do not want to add a special 'snowflake' of ?cve_statuses=comma separated list of statuses.

When no filter is provided we select all statuses, otherwise a single value or a comma delimited set of values will instruct filter accordingly ... the status values should probably be those defined in status.slug.

@jcrossley3
Copy link
Contributor

The query language already supports alternative values as |-delimited: ?q=cve_status=x|y|z

But that only works if cve_status is a scalar. I'm guessing since you called it cve_statuses (plural) that it's an array? That will require some thought. :)

@JimFuller-RedHat
Copy link
Collaborator Author

But that only works if cve_status is a scalar. I'm guessing since you called it cve_statuses (plural) that it's an array? That will require some thought. :)

yes ;) for example ?q=cve_statuses=affected,not_affected

@jcrossley3
Copy link
Contributor

We can still use a pipe for that -- comma is used as a filter separator -- but we'd need to introduce logic to determine whether the field is a list and generate some sort of IN query.

@JimFuller-RedHat
Copy link
Collaborator Author

sounds good - as for IN query ... this specific example is another case of 'we just want to use the values' I think because the actual db filtering happens far down the call chain ... I could be mistaken.

@jcrossley3
Copy link
Contributor

I'm sure IN query is wrong -- I'm a SQL idiot. However you say "are any of these things in your listy thing?"

@JimFuller-RedHat
Copy link
Collaborator Author

JimFuller-RedHat commented Jan 15, 2025

in pgsql, something like passing in ARRAY[] of strings ...

"status"."slug" = ANY($1::text[]))

or concretely

"status"."slug" = ANY(ARRAY["affected"])

@jcrossley3
Copy link
Contributor

cool. if i can identify the appropriate type for slug, i can generate that.

@JimFuller-RedHat
Copy link
Collaborator Author

JimFuller-RedHat commented Jan 15, 2025

for this specifically (for now) we do not need db query as this filter is applied so differently and later then most of our queries (part of the work @dejanb has been doing) ... just another way of saying values are good for now.

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

No branches or pull requests

2 participants