-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathissues_report.py
More file actions
52 lines (38 loc) · 1.67 KB
/
Copy pathissues_report.py
File metadata and controls
52 lines (38 loc) · 1.67 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
import requests
import json
import argparse
import csv
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_report():
endpoint_url = API_ROOT % "issues/report"
parser = argparse.ArgumentParser(description='Returns the report of issues in the csv format.')
parser.add_argument('-se', '-csvSeparator', type=str, choices=['Comma', 'Semicolon', 'Pipe', 'Tab'], help='Gets or sets the csv separator.')
parser.add_argument('-s', '-severity', type=str, choices=['BestPractice', 'Information', 'Low', 'Medium', 'High', 'Critical'], help='Gets or sets the vulnerabilitys severity.')
parser.add_argument('-w', '-webSiteName', type=str, help='Gets or sets the websites name.')
parser.add_argument('-wg', '-webSiteGroupName', type=str, help='Gets or sets the website groups name.')
args = parser.parse_args()
parameters = {
'csvSeparator': args.se,
'severity': args.s,
'webSiteName': args.w,
'webSiteGroupName': args.wg
}
response = requests.get(endpoint_url, params=parameters, auth=AUTH)
if (response.status_code == 200):
with open('Issues_Report.csv', 'w', encoding='utf8') as wf:
wf.write(response.text)
print("Response: %s - %s" % (response.status_code, response.reason))
print("The issues report has been saved into the 'Issues_Report.csv' file.")
else:
print("Response: %s - %s" % (response.status_code, response.reason))
print(response.text)
def main():
issues_report()
if __name__ == '__main__':
main()