-
Notifications
You must be signed in to change notification settings - Fork 229
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
base: main
Are you sure you want to change the base?
Add weaknesses data in packages endpoint #1789
Conversation
1dcb8f0
to
af30544
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. See comments.
vulnerabilities/api.py
Outdated
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] |
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why all?
There was a problem hiding this comment.
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?
Signed-off-by: Mukund Menon <[email protected]>
Signed-off-by: Mukund Menon <[email protected]>
90e981f
to
6d26273
Compare
Resolves #1632