diff --git a/vulnerabilities/api.py b/vulnerabilities/api.py index 4abec7532..ca6c111e5 100644 --- a/vulnerabilities/api.py +++ b/vulnerabilities/api.py @@ -60,8 +60,9 @@ def get_affected_vulnerabilities(self, package): def get_vulnerability(self, vuln, affected_vulnerabilities): affected_vulnerability = {} - if vuln.get("vulnerability"): - affected_vulnerability["vulnerability"] = vuln.get("vulnerability").vulnerability_id + vulnerability = vuln.get("vulnerability") + if vulnerability: + affected_vulnerability["vulnerability"] = vulnerability.vulnerability_id affected_vulnerabilities.append(affected_vulnerability) affected_by_vulnerabilities = serializers.SerializerMethodField("get_affected_vulnerabilities")