forked from shimonShouei/NvdScannerRezilion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
40 lines (34 loc) · 1.3 KB
/
main.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
from db import collection
from installed_softwares import InstalledSoftware
from xmlParser import CpeXmlParser
from matching_cve_cpe import MatcherCveCpe
from download_db import DownloadDb
import download_db
import socket
def execute():
print('Initializing the scan & matching process...')
print("Downloading CVE data...")
DownloadDb()
print("Downloading CPE data...")
download_db.download_file()
download_db.unzip_file('official-cpe-dictionary_v2.3.xml.zip', directory_to_extract=None)
print('Getting installed softwares...')
i_s = InstalledSoftware()
i_s.dump_software_lst_to_json(["Publisher", 'DisplayVersion', 'DisplayName'])
print('Parsing the CPE data...')
b = CpeXmlParser('official-cpe-dictionary_v2.3.xml')
b.csv_creator('official-cpe-dictionary_v2.3.xml')
c = MatcherCveCpe()
res_json = c.match_cve_cpe()
return {'_id': socket.gethostname(),
'_data': res_json}
# Run this to scan & upload to the mongoDB cloud database
# Scan result will also be saved at json_final_res.json
if __name__ == '__main__':
c = execute()
comp_name = str(socket.gethostname())
if collection.find_one({'_id': comp_name}) == None:
collection.insert_one(c)
else:
collection.delete_one({'_id': comp_name})
collection.insert_one(c)