Skip to content

Commit f079171

Browse files
committed
add docstring in fireeye
Signed-off-by: ambuj <[email protected]>
1 parent 131f37c commit f079171

File tree

2 files changed

+74
-72
lines changed

2 files changed

+74
-72
lines changed

vulnerabilities/importers/apache_httpd.py

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -161,79 +161,79 @@ def fetch_links(url):
161161

162162

163163
def get_weaknesses(cve_data):
164-
# """
165-
# Extract CWE IDs from CVE data.
164+
"""
165+
Extract CWE IDs from CVE data.
166166
167-
# Args:
168-
# cve_data (dict): The CVE data in a dictionary format.
167+
Args:
168+
cve_data (dict): The CVE data in a dictionary format.
169169
170-
# Returns:
171-
# List[int]: A list of unique CWE IDs.
170+
Returns:
171+
List[int]: A list of unique CWE IDs.
172172
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": "[email protected]",
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": [
221-
# ... {
222-
# ... "lang": "eng",
223-
# ... "value": "CWE-200 Exposure of Sensitive Information to an Unauthorized Actor"
224-
# ... }
225-
# ... ]
226-
# ... }
227-
# ... ]
228-
# ... }
229-
# ... }
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": "[email protected]",
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": [
221+
... {
222+
... "lang": "eng",
223+
... "value": "CWE-200 Exposure of Sensitive Information to an Unauthorized Actor"
224+
... }
225+
... ]
226+
... }
227+
... ]
228+
... }
229+
... }
230230
231-
# >>> get_weaknesses(mock_cve_data1)
232-
# [125]
231+
>>> get_weaknesses(mock_cve_data1)
232+
[125]
233233
234-
# >>> get_weaknesses(mock_cve_data2)
235-
# [190, 200]
236-
# """
234+
>>> get_weaknesses(mock_cve_data2)
235+
[190, 200]
236+
"""
237237

238238
alias = get_item(cve_data, "CVE_data_meta", "ID")
239239
cwe_id = []

vulnerabilities/importers/fireeye.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,12 @@ def md_list_to_dict(md_list):
151151
def get_weaknesses(cwe_data):
152152
"""
153153
Return the list of CWE IDs as integers from a list of weakness summaries, e.g., [379].
154-
Extract the CWE strings from a list of weakness descriptions,
155-
e.g., ["CWE-379: Creation of Temporary File in Directory with Insecure Permissions"], to obtain CWE IDs like CWE-379.
156-
Remove the "CWE-" prefix from each CWE string and convert it to an integer (e.g., 379).
157-
Then, check if the CWE ID exists in the CWE database.
154+
155+
>>> get_weaknesses([
156+
... "CWE-379: Creation of Temporary File in Directory with Insecure Permissions",
157+
... "CWE-362: Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')"
158+
... ])
159+
[379, 362]
158160
"""
159161
cwe_list = []
160162
for line in cwe_data:

0 commit comments

Comments
 (0)