MCPcopy Create free account
hub / github.com/aboutcode-org/vulnerablecode / get_weaknesses

Function get_weaknesses

vulnerabilities/importers/apache_httpd.py:163–254  ·  view source on GitHub ↗

Extract CWE IDs from CVE data. Args: cve_data (dict): The CVE data in a dictionary format. Returns: List[int]: A list of unique CWE IDs. Examples: >>> mock_cve_data1 = { ... "containers": { ... "cna": { ... "

(cve_data)

Source from the content-addressed store, hash-verified

161
162
163def get_weaknesses(cve_data):
164 """
165 Extract CWE IDs from CVE data.
166
167 Args:
168 cve_data (dict): The CVE data in a dictionary format.
169
170 Returns:
171 List[int]: A list of unique CWE IDs.
172
173 Examples:
174 >>> mock_cve_data1 = {
175 ... "containers": {
176 ... "cna": {
177 ... "providerMetadata": {
178 ... "orgId": "f0158376-9dc2-43b6-827c-5f631a4d8d09"
179 ... },
180 ... "title": "mod_macro buffer over-read",
181 ... "problemTypes": [
182 ... {
183 ... "descriptions": [
184 ... {
185 ... "description": "CWE-125 Out-of-bounds Read",
186 ... "lang": "en",
187 ... "cweId": "CWE-125",
188 ... "type": "CWE"
189 ... }
190 ... ]
191 ... }
192 ... ]
193 ... }
194 ... }
195 ... }
196 >>> mock_cve_data2 = {
197 ... "data_type": "CVE",
198 ... "data_format": "MITRE",
199 ... "data_version": "4.0",
200 ... "generator": {
201 ... "engine": "Vulnogram 0.0.9"
202 ... },
203 ... "CVE_data_meta": {
204 ... "ID": "CVE-2022-28614",
205 ... "ASSIGNER": "security@apache.org",
206 ... "TITLE": "read beyond bounds via ap_rwrite() ",
207 ... "STATE": "PUBLIC"
208 ... },
209 ... "problemtype": {
210 ... "problemtype_data": [
211 ... {
212 ... "description": [
213 ... {
214 ... "lang": "eng",
215 ... "value": "CWE-190 Integer Overflow or Wraparound"
216 ... }
217 ... ]
218 ... },
219 ... {
220 ... "description": [

Callers 1

to_advisoryMethod · 0.70

Calls 3

get_itemFunction · 0.90
create_weaknesses_listFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected