-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
57 lines (50 loc) · 1.73 KB
/
Copy pathrun.py
File metadata and controls
57 lines (50 loc) · 1.73 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
from subprocess import Popen, PIPE, call
import json
import sys
domain = sys.argv[1]
call(['./testssl.sh', '--quiet', '--fast', '--jsonfile-pretty=file.json', domain])
p = Popen(['cat', 'file.json'],
stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
result = json.loads(out.decode("utf-8"))
vulnerabilities = result['scanResult'][0]['vulnerabilities']
res = []
for vuln in vulnerabilities:
if vuln['severity'] == 'OK' or vuln['severity'] == 'INFO':
continue
res.append({
'title': vuln['id'],
'description': vuln['finding'],
'solution': "Update your ssl certs or contact us for support",
'status': vuln['severity'].lower().capitalize(),
'tool': 'testssl.sh',
'color': '#ec8b44',
'group': "Online Services Results"
})
serverDefaults = result['scanResult'][0]['serverDefaults']
days = [x for x in serverDefaults if x['id'] == 'cert_expirationStatus']
if (len(days) > 0):
day = int(days[0]['finding'].split(' ')[0])
if (day < 60):
res.append({
'title': 'The certificate will expire soon',
'description': 'The certificate will expire in less then {} days'.format(day),
'solution': "Update your ssl certs or contact us for support",
'status': 'High',
'tool': 'testssl.sh',
'position': 'top',
'color': '#ec8b44',
'group': "Online Services Results"
})
elif (day < 1500):
res.append({
'title': 'The certificate will expire',
'description': 'The certificate will expire in {} days'.format(day),
'solution': "Update your ssl certs or contact us for support",
'status': 'Low',
'tool': 'testssl.sh',
'position': 'top',
'color': '#ec8b44',
'group': "Online Services Results"
})
print(json.dumps(res))