-
Notifications
You must be signed in to change notification settings - Fork 0
/
bounty-calc.py
49 lines (40 loc) · 1.2 KB
/
bounty-calc.py
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
#/usr/bin/env python3
import sys
rating_scale = [
("Low", (0.1, 3.9)),
("Medium", (4.0, 6.9)),
("High", (7.0, 8.9)),
("Critical", (9.0, 10.0)),
]
bounty_scale = [
("Low", 0),
("Medium", 999000),
("High", 1999000),
("Critical", 29990000)
]
def format_currency_idr(amount):
return "IDR {:,.0f}".format(amount)
def get_severity(score):
for severity, (lower, upper) in rating_scale:
if lower <= score <= upper:
return severity
return None
def get_bounty(score):
severity = get_severity(score)
for rating_severity, (lower, upper) in rating_scale:
if rating_severity == severity:
for bounty_severity, higher in bounty_scale:
if bounty_severity == severity:
bounty = higher * (score / upper)
return format_currency_idr(bounty)
if __name__ == '__main__':
if len(sys.argv) < 2:
err = "No CVSS score provided!\n\n"
err += "Usage:\n python %s N.N\n" % (sys.argv[0])
exit(err)
score = float(sys.argv[1])
print("""
CVSS score : %g
Severity : %s
Bounty : %s
""" % (score, get_severity(score), get_bounty(score)))