forked from adulau/cve-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcve_refs.py
executable file
·68 lines (56 loc) · 1.97 KB
/
cve_refs.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Lookup NIST CVE Reference Key/Maps from a CVE
#
# This file is part of the cve-search project.
#
# Software is free software released under the "Modified BSD license"
#
# Copyright (c) 2015-2016 Alexandre Dulaunoy - [email protected]
import os
import sys
import argparse
runPath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(runPath, ".."))
from lib.Config import Configuration
try:
r = Configuration.getRedisRefConnection()
except:
sys.exit(1)
argparser = argparse.ArgumentParser(description='Lookup the NIST ref database')
argparser.add_argument('-c', help='CVE id to lookup', default=False)
argparser.add_argument('-u', action='store_true', help='Enable URL expansion', default=False)
argparser.add_argument('-v', action='store_true', help='verbose output', default=False)
args = argparser.parse_args()
if not args.c:
sys.exit("CVE id missing")
ref_urls = {"MS": "https://technet.microsoft.com/library/security/",
"SECUNIA": "http://secunia.com/advisories/",
"SREASON": "http://securityreason.com/security_alert",
"CERT": "http://www.cert.org/advisories",
"BID": "http://www.securityfocus.com/bid/",
"AIXAPART": "",
"ALLAIRE": "",
"APPLE": "",
"ASCEND": "",
"ATSTAKE": "",
"AUSCERT": "",
"BEA": "",
"BINDVIEW": "",
"SECTRACK": "http://www.securitytracker.com/id/",
"MANDRIVA": "http://www.mandriva.com/security/advisories?name="}
refs = r.smembers(args.c)
if not refs:
sys.exit("{} has no NIST references".format(args.c))
for ref in refs:
if args.u:
(provider, refid) = ref.split(":", 1)
if provider in ref_urls.keys():
print ("{}{}".format(ref_urls[provider], refid))
elif provider == 'CONFIRM':
print ("{}".format(refid))
else:
print (ref)
else:
print (ref)