Commit 43b2e42c authored by Alexandre Dulaunoy's avatar Alexandre Dulaunoy
Browse files

Merge pull request #95 from psychedelys/master

move sme './tmp/' to config file.
parents 15dc17d0 c7e77967
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8,6 +8,8 @@ RefDB: 12
Host: localhost
Port: 27017
DB: cvedb
[dbmgt]
Tmpdir: ./tmp/
[FulltextIndex]
Indexdir: ./indexdir/
[Sources]
+6 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ class Configuration():
               'logging': True,           'logfile': "../log/cve-search.log",
               'maxLogSize': '100MB',     'backlog': 5,
               'Indexdir': './indexdir',
               'Tmpdir': './tmp',
               'includeCapec': True,      'includeD2Sec': True,
               'includeVFeed': True,      'includeVendor': True,
               'includeCWE': True,
@@ -258,6 +259,11 @@ class Configuration():
    def getBacklog(cls):
        return cls.readSetting("Logging", "Backlog", cls.default['backlog'])

    # Indexing
    @classmethod
    def getTmpdir(cls):
        return cls.readSetting("dbmgt", "Tmpdir", cls.default['Tmpdir'])

    # Indexing
    @classmethod
    def getIndexdir(cls):
+1 −1
Original line number Diff line number Diff line
#!/usr/local/bin/python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Import script of cpe (Common Platform Enumeration) definition
+6 −5
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ def minimalist_xldate_as_datetime(xldate, datemode):

# dictionary
msbulletinurl = Configuration.getMSBULLETINDict()
tmppath = Configuration.getTmpdir()

# connect to db
db = Configuration.getMongoConnection()
@@ -39,13 +40,13 @@ if i is not None:
        print("Not modified")
        sys.exit(0)

if not os.path.exists('./tmp'):
    os.mkdir('./tmp')
with open('./tmp/BulletinSearch.xls', 'wb') as fp:
if not os.path.exists(tmppath):
    os.mkdir(tmppath)
with open(tmppath+'/BulletinSearch.xls', 'wb') as fp:
    shutil.copyfileobj(f, fp)
     
# parse xlsx and store in database
wb = xlrd.open_workbook('./tmp/BulletinSearch.xls')
wb = xlrd.open_workbook(tmppath+'/BulletinSearch.xls')
sh = wb.sheet_by_name('Bulletin Search')
header = [s.replace('\n', ' ') for s in sh.row_values(0)]
bulletin = {}
@@ -92,7 +93,7 @@ for rownum in range(sh.nrows-1):

#update database info after successful program-run
info.update({'db': 'ms'}, {"$set": {'last-modified': f.headers['last-modified']}}, upsert=True)
shutil.rmtree('./tmp')
# shutil.rmtree('./tmp')



+5 −4
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ verbose = False
from lib.Config import Configuration

RefUrl = Configuration.getRefURL()
tmppath = Configuration.getTmpdir()

argparser = argparse.ArgumentParser(description='Populate/update the NIST ref database')
argparser.add_argument('-v', action='store_true', help='verbose output', default=False)
@@ -46,10 +47,10 @@ if i is not None:
        sys.exit(0)

# Create temp file and download and unpack database
if not os.path.exists('./tmp'):
    os.mkdir('./tmp')
if not os.path.exists(tmppath):
    os.mkdir(tmppath)

with open('./tmp/allrefmaps.zip', 'wb') as fp:
with open(tmppath+'/allrefmaps.zip', 'wb') as fp:
    shutil.copyfileobj(u, fp)

try:
@@ -58,7 +59,7 @@ except:
    sys.exit(1)


x = zipfile.ZipFile('./tmp/allrefmaps.zip')
x = zipfile.ZipFile(tmppath+'/allrefmaps.zip')
for e in x.namelist():
    filename = e
    with x.open(filename) as infile:
Loading