From 4ce5d515faa30d10f5d122f62d9ba0757a09dd25 Mon Sep 17 00:00:00 2001 From: "John M. Horan" Date: Wed, 1 Nov 2023 13:15:26 -0700 Subject: [PATCH] Update get_vulnerability() method #1228 Reference: https://github.com/nexB/vulnerablecode/issues/1228 Signed-off-by: John M. Horan --- vulnerabilities/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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")