Skip to content

Commit 255782b

Browse files
committedMay 22, 2018
Add rvss command line tool
1 parent 8059da5 commit 255782b

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
 

‎cvsslib/command2.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from cvsslib.vector import detect_vector, calculate_vector, VectorError
2+
from cvsslib import cvss2, cvss3
3+
import argparse
4+
5+
6+
def main():
7+
parser = argparse.ArgumentParser(description="Calculate RVSS scores from a vector")
8+
parser.add_argument('vector')
9+
parser.add_argument('-v', default=None, dest="version", type=int, help="RVSS version to use (default: autodetect)")
10+
args = parser.parse_args()
11+
12+
module = None
13+
14+
if args.version is not None:
15+
module = {2: cvss2, 3: cvss3}[args.version]
16+
else:
17+
module = detect_vector(args.vector)
18+
19+
try:
20+
results = calculate_vector(args.vector, module)
21+
except VectorError as e:
22+
print("Error parsing vector: {0}".format(e.message))
23+
else:
24+
print("Base Score:\t{0}".format(results[0]))
25+
print("Temporal:\t{0}".format(results[1]))
26+
print("Environment:\t{0}".format(results[2]))
27+
28+
29+
if __name__ == "__main__":
30+
main()

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
'(https://github.com/ctxis/cvsslib) for examples and documentation.',
2424
install_requires=requirements,
2525
entry_points={
26-
'console_scripts': ['cvss=cvsslib.command:main'],
26+
'console_scripts': ['cvss=cvsslib.command:main', 'rvss=cvsslib.command2:main'],
2727
},
2828
classifiers=[
2929
'Framework :: Django',

0 commit comments

Comments
 (0)
Please sign in to comment.