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 weaknesses data in packages endpoint #1789

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Mukund-Menon
Copy link

Resolves #1632

@Mukund-Menon Mukund-Menon force-pushed the 1632-add-weaknesses-in-packages-api branch from 1dcb8f0 to af30544 Compare February 28, 2025 13:40
Copy link
Member

@pombredanne pombredanne left a comment

Choose a reason for hiding this comment

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

Thanks. See comments.

instance=qs,
many=True,
context={"request": self.context["request"]},
).data

for vuln, vuln_instance in zip(vulnerabilities_data, qs):
vuln["weaknesses"] = [weakness.to_dict() for weakness in vuln_instance.prefetched_weaknesses]
Copy link
Member

Choose a reason for hiding this comment

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

Should not this go in the serializer instead?

),
Prefetch(
"weaknesses",
queryset=Weakness.objects.all(),
Copy link
Member

Choose a reason for hiding this comment

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

Why all?

Copy link
Author

Choose a reason for hiding this comment

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

I used .all() to ensure a queryset is passed, as omitting it caused a server error. Should we instead be filtering the queryset?

@Mukund-Menon Mukund-Menon force-pushed the 1632-add-weaknesses-in-packages-api branch from 90e981f to 6d26273 Compare March 6, 2025 18:43
@Mukund-Menon Mukund-Menon requested a review from pombredanne March 6, 2025 19:04
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.

Add the weaknesses data in the API packages endpoint.
2 participants