Skip to content

Sort vulnerabilities from newest to oldest in API responses#2243

Open
ashwinraj8090 wants to merge 1 commit intoaboutcode-org:mainfrom
ashwinraj8090:sort-order
Open

Sort vulnerabilities from newest to oldest in API responses#2243
ashwinraj8090 wants to merge 1 commit intoaboutcode-org:mainfrom
ashwinraj8090:sort-order

Conversation

@ashwinraj8090
Copy link
Copy Markdown

Hi @pombredanne,

I worked on this issue and implemented descending sorting for vulnerabilities so that newer entries appear first in the API responses.

Approach

Since there is no explicit timestamp field available, I used vulnerability_id as a proxy for ordering, assuming higher IDs correspond to more recent entries.

The sorting has been applied across relevant API querysets, including:

  • VulnerabilityViewSet
  • CPE-related queries
  • V2 API endpoints

For packages, I did not introduce sorting as there does not appear to be a clear field representing recency. Please let me know if a specific field should be used.

Please let me know if this approach aligns with the intended solution or if a different field or strategy should be preferred.

Fixes #1754

Thank you!

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.

In UI and API, sort packages and vulnerabilities from newest to oldest.

1 participant