Skip to content

Commit c71edf1

Browse files
authored
Merge pull request #1162 from TG1999/remove_excessive_network_calls_from_redhat
Remove excessive network calls from redhat importer #1161
2 parents 0a8f7a8 + baa47b5 commit c71edf1

File tree

2 files changed

+15
-63
lines changed

2 files changed

+15
-63
lines changed

vulnerabilities/importers/redhat.py

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,12 @@ def to_advisory(advisory_data):
9898
bugzilla = advisory_data.get("bugzilla")
9999
if bugzilla:
100100
url = "https://bugzilla.redhat.com/show_bug.cgi?id={}".format(bugzilla)
101-
bugzilla_url = f"https://bugzilla.redhat.com/rest/bug/{bugzilla}"
102-
bugzilla_data = get_data_from_url(bugzilla_url)
103-
bugs = bugzilla_data.get("bugs") or []
104-
if bugs:
105-
# why [0] only here?
106-
severity = bugs[0].get("severity")
107-
if severity:
108-
bugzilla_severity = VulnerabilitySeverity(
109-
system=severity_systems.REDHAT_BUGZILLA,
110-
value=severity,
111-
)
112-
references.append(
113-
Reference(
114-
severities=[bugzilla_severity],
115-
url=url,
116-
reference_id=bugzilla,
117-
)
118-
)
101+
references.append(
102+
Reference(
103+
url=url,
104+
reference_id=bugzilla,
105+
)
106+
)
119107

120108
for rh_adv in advisory_data.get("advisories") or []:
121109
# RH provides 3 types of advisories RHSA, RHBA, RHEA. Only RHSA's contain severity score.
@@ -126,25 +114,8 @@ def to_advisory(advisory_data):
126114
continue
127115

128116
if "RHSA" in rh_adv.upper():
129-
rhsa_url = f"https://access.redhat.com/hydra/rest/securitydata/cvrf/{rh_adv}.json"
130-
rhsa_data = get_data_from_url(rhsa_url)
131-
if not rhsa_data:
132-
continue
133-
rhsa_aggregate_severities = []
134-
if rhsa_data.get("cvrfdoc"):
135-
# not all RHSA errata have a corresponding CVRF document
136-
value = get_item(rhsa_data, "cvrfdoc", "aggregate_severity")
137-
if value:
138-
rhsa_aggregate_severities.append(
139-
VulnerabilitySeverity(
140-
system=severity_systems.REDHAT_AGGREGATE,
141-
value=value,
142-
)
143-
)
144-
145117
references.append(
146118
Reference(
147-
severities=rhsa_aggregate_severities,
148119
url="https://access.redhat.com/errata/{}".format(rh_adv),
149120
reference_id=rh_adv,
150121
)

vulnerabilities/tests/test_data/redhat/redhat-expected.json

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@
99
{
1010
"reference_id": 2077736,
1111
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=2077736",
12-
"severities": [
13-
{
14-
"system": "rhbs",
15-
"value": "medium",
16-
"scoring_elements": ""
17-
}
18-
]
12+
"severities": []
1913
},
2014
{
2115
"reference_id": "",
@@ -197,35 +191,22 @@
197191
{
198192
"reference_id": 2075788,
199193
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=2075788",
200-
"severities": [
201-
{
202-
"system": "rhbs",
203-
"value": "medium",
204-
"scoring_elements": ""
205-
}
206-
]
194+
"severities": []
207195
},
208196
{
209197
"reference_id": "RHSA-2022:1439",
210198
"url": "https://access.redhat.com/errata/RHSA-2022:1439",
211-
"severities": [
212-
{
213-
"system": "rhas",
214-
"value": "Important",
215-
"scoring_elements": ""
216-
}
217-
]
199+
"severities": []
218200
},
219201
{
220202
"reference_id": "RHSA-2022:1437",
221203
"url": "https://access.redhat.com/errata/RHSA-2022:1437",
222-
"severities": [
223-
{
224-
"system": "rhas",
225-
"value": "Important",
226-
"scoring_elements": ""
227-
}
228-
]
204+
"severities": []
205+
},
206+
{
207+
"reference_id": "RHSA-2022:1436",
208+
"url": "https://access.redhat.com/errata/RHSA-2022:1436",
209+
"severities": []
229210
},
230211
{
231212
"reference_id": "",

0 commit comments

Comments
 (0)