-
-
Notifications
You must be signed in to change notification settings - Fork 309
Expand file tree
/
Copy pathreferences.py
More file actions
145 lines (124 loc) · 4.35 KB
/
Copy pathreferences.py
File metadata and controls
145 lines (124 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# VulnerableCode is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/aboutcode-org/vulnerablecode for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
from vulnerabilities.importer import Reference
from vulnerabilities.importer import ReferenceV2
class XsaReference(Reference):
"""
A Xen advisory reference. See https://xenbits.xen.org/xsa
"""
@classmethod
def from_id(cls, xsa_id):
"""
Return a new XsaReference from an XSA-XXXX id.
"""
if not xsa_id or not xsa_id.lower().startswith("xsa"):
return ValueError(f"Not a Xen reference. Does not start with XSA: {xsa_id!r}")
_, numid = xsa_id.rsplit("-")
return cls(
reference_id=xsa_id,
url=f"https://xenbits.xen.org/xsa/advisory-{numid}.html",
)
@classmethod
def from_number(cls, number):
"""
Return a new XsaReference from an XSA number.
"""
return cls(
reference_id=f"XSA-{number}",
url=f"https://xenbits.xen.org/xsa/advisory-{number}.html",
)
class ZbxReference(Reference):
"""
A Zabbix advisory reference. See https://support.zabbix.com
"""
@classmethod
def from_id(cls, zbx_id):
"""
Return a new ZbxReference from an ZBX-XXXX id.
"""
if not zbx_id or not zbx_id.lower().startswith("zbx"):
return ValueError(f"Not a Zabbix reference. Does not start with ZBX: {zbx_id!r}")
return cls(
reference_id=zbx_id,
url=f"https://support.zabbix.com/browse/{zbx_id}",
)
class WireSharkReference(Reference):
"""
A Wireshark advisory reference. See https://www.wireshark.org/security
"""
@classmethod
def from_id(cls, wnpa_sec_id):
"""
Return a new WireSharkReference from an wnpa-sec-XXXX id.
"""
if not wnpa_sec_id or not wnpa_sec_id.lower().startswith("wnpa-sec"):
return ValueError(
f"Not a WireShark reference. Does not start with wnpa-sec: {wnpa_sec_id!r}"
)
return cls(
reference_id=wnpa_sec_id,
url=f"https://www.wireshark.org/security/{wnpa_sec_id}.html",
)
class XsaReferenceV2:
"""
A Xen advisory reference. See https://xenbits.xen.org/xsa
"""
@classmethod
def from_id(cls, xsa_id):
"""
Return a new XsaReference from an XSA-XXXX id.
"""
if not xsa_id or not xsa_id.lower().startswith("xsa"):
return ValueError(f"Not a Xen reference. Does not start with XSA: {xsa_id!r}")
_, numid = xsa_id.rsplit("-")
return ReferenceV2(
reference_id=xsa_id,
url=f"https://xenbits.xen.org/xsa/advisory-{numid}.html",
)
@classmethod
def from_number(cls, number):
"""
Return a new XsaReference from an XSA number.
"""
return ReferenceV2(
reference_id=f"XSA-{number}",
url=f"https://xenbits.xen.org/xsa/advisory-{number}.html",
)
class ZbxReferenceV2:
"""
A Zabbix advisory reference. See https://support.zabbix.com
"""
@classmethod
def from_id(cls, zbx_id):
"""
Return a new ZbxReference from an ZBX-XXXX id.
"""
if not zbx_id or not zbx_id.lower().startswith("zbx"):
return ValueError(f"Not a Zabbix reference. Does not start with ZBX: {zbx_id!r}")
return ReferenceV2(
reference_id=zbx_id,
url=f"https://support.zabbix.com/browse/{zbx_id}",
)
class WireSharkReferenceV2:
"""
A Wireshark advisory reference. See https://www.wireshark.org/security
"""
@classmethod
def from_id(cls, wnpa_sec_id):
"""
Return a new WireSharkReference from an wnpa-sec-XXXX id.
"""
if not wnpa_sec_id or not wnpa_sec_id.lower().startswith("wnpa-sec"):
return ValueError(
f"Not a WireShark reference. Does not start with wnpa-sec: {wnpa_sec_id!r}"
)
return ReferenceV2(
reference_id=wnpa_sec_id,
url=f"https://www.wireshark.org/security/{wnpa_sec_id}.html",
)