Skip to content

Commit

Permalink
Sanity Checks for redhat import response
Browse files Browse the repository at this point in the history
Signed-off-by: savish <savishbedi1@gmail.com>
  • Loading branch information
savish28 committed Mar 18, 2021
1 parent 80c65a2 commit 67f420c
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions vulnerabilities/importers/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,24 @@ def to_advisory(advisory_data):
if bugzilla:
url = "https://bugzilla.redhat.com/show_bug.cgi?id={}".format(bugzilla)
bugzilla_data = requests.get(f"https://bugzilla.redhat.com/rest/bug/{bugzilla}").json()
bugzilla_severity_val = bugzilla_data["bugs"][0]["severity"]
bugzilla_severity = VulnerabilitySeverity(
system=scoring_systems["rhbs"],
value=bugzilla_severity_val,
)
if (
("bugs" in bugzilla_data)
and len(bugzilla_data["bugs"])
and ("severity" in bugzilla_data["bugs"][0])
):
bugzilla_severity_val = bugzilla_data["bugs"][0]["severity"]
bugzilla_severity = VulnerabilitySeverity(
system=scoring_systems["rhbs"],
value=bugzilla_severity_val,
)

references.append(
Reference(
severities=[bugzilla_severity],
url=url,
reference_id=bugzilla,
references.append(
Reference(
severities=[bugzilla_severity],
url=url,
reference_id=bugzilla,
)
)
)

for rh_adv in advisory_data["advisories"]:
# RH provides 3 types of advisories RHSA, RHBA, RHEA. Only RHSA's contain severity score.
Expand Down

0 comments on commit 67f420c

Please sign in to comment.