-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathissues_allissues.py
More file actions
73 lines (52 loc) · 2.64 KB
/
Copy pathissues_allissues.py
File metadata and controls
73 lines (52 loc) · 2.64 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
import requests
import json
import argparse
file = open("config.json", "r")
data = json.load(file)
file.close()
USER_ID = data['USER_ID']
API_TOKEN = data['API_TOKEN']
API_ROOT = data['API_ROOT']
AUTH = (USER_ID, API_TOKEN)
def issues_allissues():
endpoint_url = API_ROOT % "issues/allissues"
parser = argparse.ArgumentParser(description='Gets the list of all issues.')
parser.add_argument('-s', '-severity', type=str, choices=['BestPractice', 'Information', 'Low', 'Medium', 'High', 'Critical'], help='The vulnerability severity')
parser.add_argument('-w', '-webSiteName', type=str, help='The websites name')
parser.add_argument('-wg', '-webSiteGroupName', type=str, help='The website groups name')
parser.add_argument('-st', '-sortType', type=str, choices=['Ascending', 'Descending'], default="Ascending", help='Sort by ascending and descending according to LastSeenDate. Default parameter ascending.')
parser.add_argument('-l', '-lastSeenDate', type=str, help='You can use the date format defined in your account. You can visit /account/changesettings to view the current format.')
parser.add_argument('-r', '-rawDetails', type=str, choices=['true', 'false'], default='true', help='If you want the vulnerability data response(Remedy, Description etc.) to return without raw html, this field must be set false.')
args = parser.parse_args()
parameters = {
'severity': args.s,
'webSiteName': args.w,
'webSiteGroupName': args.wg,
'page': 1,
'pageSize': 200,
'sortType:': args.st,
'lastSeenDate': args.l,
'rawDetails': args.r
}
response = requests.get(endpoint_url, params=parameters, auth=AUTH)
if (response.status_code == 200):
json_response = response.json()
json_list = json_response['List']
with open('Issues_AllIssues.json', 'w') as outfile:
json.dump(json_list, outfile, indent=4)
while json_response['HasNextPage'] is True:
parameters['page'] += 1
response = requests.get(endpoint_url, params=parameters, auth=AUTH)
json_response = response.json()
json_list += json_response['List']
with open('Issues_AllIssues.json', 'w') as outfile:
json.dump(json_list, outfile, indent=4)
print("Response: %s - %s" % (response.status_code, response.reason))
print("The issues list is saved into the 'Issues_AllIssues.json' file.")
else:
print("Response: %s - %s" % (response.status_code, response.reason))
print(response.text)
def main():
issues_allissues()
if __name__ == '__main__':
main()