Skip to content

Commit 088279c

Browse files
committed
docs(almalinux-importer): Add docstring to parse_advisory_data function
- Added a detailed docstring to the `parse_advisory_data` function in the `almalinux-importer` module. - The docstring includes a clear description of the function's purpose, arguments, return value, and an example usage. - Improved the readability and structure of the example output in the docstring to ensure clarity and consistency. This documentation enhancement makes the `parse_advisory_data` function easier to understand and use, aiding future development and maintenance. Signed-off-by: ambuj <kulshreshthaak.12@gmail.com>
1 parent c679856 commit 088279c

File tree

5 files changed

+216
-59
lines changed

5 files changed

+216
-59
lines changed

vulnerabilities/importers/almalinux.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,53 @@ def advisory_data(self) -> Iterable[AdvisoryData]:
6565

6666

6767
def parse_advisory_data(raw_data, advisory_url) -> Optional[AdvisoryData]:
68+
"""
69+
Parse Alma Linux advisory data and convert it into an AdvisoryData object.
70+
71+
Args:
72+
raw_data (dict): A dictionary containing raw advisory information.
73+
advisory_url (str): The URL to the advisory.
74+
75+
Returns:
76+
AdvisoryData: An instance of AdvisoryData with processed information, or
77+
None if the data cannot be parsed correctly.
78+
79+
Example:
80+
>>> raw_data = {
81+
... "id": "ALBA-2020:4512",
82+
... "summary": "libteam bug fix and enhancement update",
83+
... "details": "For detailed information on changes in this release, see the AlmaLinux Release Notes linked from the References section.",
84+
... "published": "2020-11-03T12:11:24Z",
85+
... "affected": [
86+
... {
87+
... "package": {
88+
... "ecosystem": "AlmaLinux:8",
89+
... "name": "libteam"
90+
... },
91+
... "ranges": [
92+
... {
93+
... "type": "ECOSYSTEM",
94+
... "events": [
95+
... {"introduced": "0"},
96+
... {"fixed": "1.31-2.el8"}
97+
... ]
98+
... }
99+
... ]
100+
... }
101+
... ],
102+
... "references": [
103+
... {
104+
... "url": "https://errata.almalinux.org/8/ALBA-2020-4512.html",
105+
... "type": "ADVISORY"
106+
... }
107+
... ]
108+
... }
109+
>>> advisory_url = "https://github.com/AlmaLinux/osv-database/blob/master/advisories/almalinux/example_advisory.json"
110+
>>> advisory = parse_advisory_data(raw_data, advisory_url).to_dict()
111+
>>> print(advisory)
112+
{'aliases': ['ALBA-2020:4512'], 'summary': 'libteam bug fix and enhancement update\\nFor detailed information on changes in this release, see the AlmaLinux Release Notes linked from the References section.', 'affected_packages': [{'package': {'type': 'rpm', 'namespace': 'almalinux', 'name': 'libteam', 'version': '', 'qualifiers': '', 'subpath': ''}, 'affected_version_range': None, 'fixed_version': '1.31-2.el8'}], 'references': [{'reference_id': '', 'reference_type': '', 'url': 'https://errata.almalinux.org/8/ALBA-2020-4512.html', 'severities': []}], 'date_published': '2020-11-03T12:11:24+00:00', 'weaknesses': [], 'url': 'https://github.com/AlmaLinux/osv-database/blob/master/advisories/almalinux/example_advisory.json'}
113+
"""
114+
68115
raw_id = raw_data.get("id") or ""
69116
summary = raw_data.get("summary") or ""
70117
details = raw_data.get("details") or ""

vulnerabilities/tests/test_almalinux.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import os
1111
from unittest import TestCase
1212

13-
from vulnerabilities.importers.almalinux import get_affected_purl
14-
from vulnerabilities.importers.almalinux import get_fixed_versions
1513
from vulnerabilities.importers.almalinux import parse_advisory_data
1614
from vulnerabilities.tests import util_tests
1715

@@ -44,7 +42,7 @@ def test_almalinux_importer2(self):
4442
result = imported_data.to_dict()
4543
util_tests.check_results_against_json(result, expected_file)
4644

47-
def test_github_osv_importer3(self):
45+
def test_almalinux_importer3(self):
4846
with open(os.path.join(TEST_DATA, "almalinux_test_3.json")) as f:
4947
mock_response = json.load(f)
5048
expected_file = os.path.join(TEST_DATA, "almalinux_expected_3.json")
Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
{
2-
"aliases": ["ALBA-2019:3336"],
3-
"summary": "nss-altfiles bug fix and enhancement update\nFor detailed information on changes in this release, see the AlmaLinux Release Notes linked from the References section.",
2+
"aliases": [
3+
"ALBA-2019:3336"
4+
],
5+
"summary": "nss-altfiles bug fix and enhancement update\nFor detailed information on changes in this release, see the AlmaLinux Release Notes linked from the References section.",
46
"affected_packages": [
57
{
6-
"package": {"type": "rpm", "namespace": "almalinux", "name": "nss-altfiles", "version": "", "qualifiers": "", "subpath": ""},
7-
"affected_version_range": null,
8-
"fixed_version": "2.18.1-12.el8"
9-
}
10-
],
8+
"package": {
9+
"type": "rpm",
10+
"namespace": "almalinux",
11+
"name": "nss-altfiles",
12+
"version": "",
13+
"qualifiers": "",
14+
"subpath": ""
15+
},
16+
"affected_version_range": null,
17+
"fixed_version": "2.18.1-12.el8"
18+
}
19+
],
1120
"references": [
1221
{
13-
"reference_id": "",
14-
"url": "https://errata.almalinux.org/8/ALBA-2019-3336.html",
15-
"severities": []
16-
}
17-
],
18-
"date_published": "2019-11-05T17:32:18+00:00",
19-
"weaknesses": [],
22+
"reference_id": "",
23+
"reference_type": "",
24+
"url": "https://errata.almalinux.org/8/ALBA-2019-3336.html",
25+
"severities": []
26+
}
27+
],
28+
"date_published": "2019-11-05T17:32:18+00:00",
29+
"weaknesses": [],
2030
"url": "https://github.com/AlmaLinux/osv-database/blob/master/advisories/almalinux8/almalinux_test_1.json"
2131
}
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
{
2-
"aliases": ["ALEA-2019:3314"],
3-
"summary": "python3-azure-sdk bug fix and enhancement update\nFor detailed information on changes in this release, see the AlmaLinux Release Notes linked from the References section.",
2+
"aliases": [
3+
"ALEA-2019:3314"
4+
],
5+
"summary": "python3-azure-sdk bug fix and enhancement update\nFor detailed information on changes in this release, see the AlmaLinux Release Notes linked from the References section.",
46
"affected_packages": [
57
{
68
"package": {
7-
"type": "rpm", "namespace": "almalinux", "name": "python3-azure-sdk", "version": "", "qualifiers": "", "subpath": ""
8-
},
9-
"affected_version_range": null,
10-
"fixed_version": "4.0.0-9.el8"
9+
"type": "rpm",
10+
"namespace": "almalinux",
11+
"name": "python3-azure-sdk",
12+
"version": "",
13+
"qualifiers": "",
14+
"subpath": ""
15+
},
16+
"affected_version_range": null,
17+
"fixed_version": "4.0.0-9.el8"
1118
}
12-
],
13-
"references": [],
14-
"date_published": "2019-11-05T17:29:24+00:00",
15-
"weaknesses": [],
19+
],
20+
"references": [],
21+
"date_published": "2019-11-05T17:29:24+00:00",
22+
"weaknesses": [],
1623
"url": "https://github.com/AlmaLinux/osv-database/blob/master/advisories/almalinux8/almalinux_test_2.json"
1724
}
Lines changed: 127 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,145 @@
11
{
2-
"aliases": ["ALSA-2022:8221"],
3-
"summary": "Moderate: xorg-x11-server security and bug fix update\nX.Org is an open-source implementation of the X Window System. It provides the basic low-level functionality that full-fledged graphical user interfaces are designed upon.\n\nSecurity Fix(es)n\n* xorg-x11-server: X.Org Server ProcXkbSetGeometry out-of-bounds access (CVE-2022-2319)\n* xorg-x11-server: out-of-bounds access in ProcXkbSetDeviceInfo request handler of the Xkb extension VE-2022-2320)\n\nFor more details about the security issue(s), including the impact, a CVSS score, acknowledgments, and other related information, refer to the CVE page(s) listed in the References section.\nAdditional Changes:\n\nFor detailed information on changes in this release, see the AlmaLinux Release Notes linked from the References section.",
2+
"aliases": [
3+
"ALSA-2022:8221"
4+
],
5+
"summary": "Moderate: xorg-x11-server security and bug fix update\nX.Org is an open-source implementation of the X Window System. It provides the basic low-level functionality that full-fledged graphical user interfaces are designed upon.\n\nSecurity Fix(es)n\n* xorg-x11-server: X.Org Server ProcXkbSetGeometry out-of-bounds access (CVE-2022-2319)\n* xorg-x11-server: out-of-bounds access in ProcXkbSetDeviceInfo request handler of the Xkb extension VE-2022-2320)\n\nFor more details about the security issue(s), including the impact, a CVSS score, acknowledgments, and other related information, refer to the CVE page(s) listed in the References section.\nAdditional Changes:\n\nFor detailed information on changes in this release, see the AlmaLinux Release Notes linked from the References section.",
46
"affected_packages": [
5-
{"package": {"type": "rpm", "namespace": "almalinux", "name": "xorg-x11-server-Xdmx", "version": "", "qualifiers": "", "subpath": ""}, "affected_version_range": null, "fixed_version": "1.20.11-11.el9"},
6-
{"package": {"type": "rpm", "namespace": "almalinux", "name": "xorg-x11-server-Xephyr", "version": "", "qualifiers": "", "subpath": ""}, "affected_version_range": null, "fixed_version": "1.20.11-11.el9"},
7-
{"package": {"type": "rpm", "namespace": "almalinux", "name": "xorg-x11-server-Xnest", "version": "", "qualifiers": "", "subpath": ""}, "affected_version_range": null, "fixed_version": "1.20.11-11.el9"},
8-
{"package": {"type": "rpm", "namespace": "almalinux", "name": "xorg-x11-server-Xorg", "version": "", "qualifiers": "", "subpath": ""}, "affected_version_range": null, "fixed_version": "1.20.11-11.el9"},
9-
{"package": {"type": "rpm", "namespace": "almalinux", "name": "xorg-x11-server-Xvfb", "version": "", "qualifiers": "", "subpath": ""}, "affected_version_range": null, "fixed_version": "1.20.11-11.el9"},
10-
{"package": {"type": "rpm", "namespace": "almalinux", "name": "xorg-x11-server-common", "version": "", "qualifiers": "", "subpath": ""}, "affected_version_range": null, "fixed_version": "1.20.11-11.el9"},
11-
{"package": {"type": "rpm", "namespace": "almalinux", "name": "xorg-x11-server-devel", "version": "", "qualifiers": "", "subpath": ""}, "affected_version_range": null, "fixed_version": "1.20.11-11.el9"},
12-
{"package": {"type": "rpm", "namespace": "almalinux", "name": "xorg-x11-server-source", "version": "", "qualifiers": "", "subpath": ""}, "affected_version_range": null, "fixed_version": "1.20.11-11.el9"}
13-
14-
],
7+
{
8+
"package": {
9+
"type": "rpm",
10+
"namespace": "almalinux",
11+
"name": "xorg-x11-server-Xdmx",
12+
"version": "",
13+
"qualifiers": "",
14+
"subpath": ""
15+
},
16+
"affected_version_range": null,
17+
"fixed_version": "1.20.11-11.el9"
18+
},
19+
{
20+
"package": {
21+
"type": "rpm",
22+
"namespace": "almalinux",
23+
"name": "xorg-x11-server-Xephyr",
24+
"version": "",
25+
"qualifiers": "",
26+
"subpath": ""
27+
},
28+
"affected_version_range": null,
29+
"fixed_version": "1.20.11-11.el9"
30+
},
31+
{
32+
"package": {
33+
"type": "rpm",
34+
"namespace": "almalinux",
35+
"name": "xorg-x11-server-Xnest",
36+
"version": "",
37+
"qualifiers": "",
38+
"subpath": ""
39+
},
40+
"affected_version_range": null,
41+
"fixed_version": "1.20.11-11.el9"
42+
},
43+
{
44+
"package": {
45+
"type": "rpm",
46+
"namespace": "almalinux",
47+
"name": "xorg-x11-server-Xorg",
48+
"version": "",
49+
"qualifiers": "",
50+
"subpath": ""
51+
},
52+
"affected_version_range": null,
53+
"fixed_version": "1.20.11-11.el9"
54+
},
55+
{
56+
"package": {
57+
"type": "rpm",
58+
"namespace": "almalinux",
59+
"name": "xorg-x11-server-Xvfb",
60+
"version": "",
61+
"qualifiers": "",
62+
"subpath": ""
63+
},
64+
"affected_version_range": null,
65+
"fixed_version": "1.20.11-11.el9"
66+
},
67+
{
68+
"package": {
69+
"type": "rpm",
70+
"namespace": "almalinux",
71+
"name": "xorg-x11-server-common",
72+
"version": "",
73+
"qualifiers": "",
74+
"subpath": ""
75+
},
76+
"affected_version_range": null,
77+
"fixed_version": "1.20.11-11.el9"
78+
},
79+
{
80+
"package": {
81+
"type": "rpm",
82+
"namespace": "almalinux",
83+
"name": "xorg-x11-server-devel",
84+
"version": "",
85+
"qualifiers": "",
86+
"subpath": ""
87+
},
88+
"affected_version_range": null,
89+
"fixed_version": "1.20.11-11.el9"
90+
},
91+
{
92+
"package": {
93+
"type": "rpm",
94+
"namespace": "almalinux",
95+
"name": "xorg-x11-server-source",
96+
"version": "",
97+
"qualifiers": "",
98+
"subpath": ""
99+
},
100+
"affected_version_range": null,
101+
"fixed_version": "1.20.11-11.el9"
102+
}
103+
],
15104
"references": [
16105
{
17-
"reference_id": "",
18-
"url": "https://access.redhat.com/errata/RHSA-2022:8221",
106+
"reference_id": "",
107+
"reference_type": "",
108+
"url": "https://access.redhat.com/errata/RHSA-2022:8221",
19109
"severities": []
20-
},
110+
},
21111
{
22-
"reference_id": "",
23-
"url": "https://access.redhat.com/security/cve/CVE-2022-2319",
112+
"reference_id": "",
113+
"reference_type": "",
114+
"url": "https://access.redhat.com/security/cve/CVE-2022-2319",
24115
"severities": []
25-
},
116+
},
26117
{
27-
"reference_id": "",
28-
"url": "https://access.redhat.com/security/cve/CVE-2022-2320",
118+
"reference_id": "",
119+
"reference_type": "",
120+
"url": "https://access.redhat.com/security/cve/CVE-2022-2320",
29121
"severities": []
30-
},
122+
},
31123
{
32-
"reference_id": "",
33-
"url": "https://bugzilla.redhat.com/2106671",
124+
"reference_id": "",
125+
"reference_type": "",
126+
"url": "https://bugzilla.redhat.com/2106671",
34127
"severities": []
35-
},
128+
},
36129
{
37-
"reference_id": "",
38-
"url": "https://bugzilla.redhat.com/2106683",
130+
"reference_id": "",
131+
"reference_type": "",
132+
"url": "https://bugzilla.redhat.com/2106683",
39133
"severities": []
40-
},
134+
},
41135
{
42-
"reference_id": "",
43-
"url": "https://errata.almalinux.org/9/ALSA-2022-8221.html",
136+
"reference_id": "",
137+
"reference_type": "",
138+
"url": "https://errata.almalinux.org/9/ALSA-2022-8221.html",
44139
"severities": []
45140
}
46-
],
47-
"date_published": "2022-11-15T00:00:00+00:00",
48-
"weaknesses": [],
141+
],
142+
"date_published": "2022-11-15T00:00:00+00:00",
143+
"weaknesses": [],
49144
"url": "https://github.com/AlmaLinux/osv-database/blob/master/advisories/almalinux8/almalinux_test_3.json"
50145
}

0 commit comments

Comments
 (0)