Commit fcc34699 authored by Alexandre Dulaunoy's avatar Alexandre Dulaunoy
Browse files

Verbose mode added as an option

parent 3f7e12e0
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -7,9 +7,9 @@
#
# Copyright (c) 2015 	Alexandre Dulaunoy - a@foo.be

# Imports
import os
import sys
import argparse
import re
from lxml.html import fromstring
runPath = os.path.dirname(os.path.realpath(__file__))
@@ -19,10 +19,18 @@ from urllib.request import urlopen
import zipfile
import shutil
verbose = False

from lib.Config import Configuration

RefUrl = Configuration.getRefURL()

argparser = argparse.ArgumentParser(description='Populate/update the NIST ref database')
argparser.add_argument('-v', action='store_true', help='verbose output', default=False)
args = argparser.parse_args()

if args.v:
    verbose = True

# connect to db
db = Configuration.getMongoConnection()
info = db.info
@@ -67,7 +75,7 @@ for e in x.namelist():
        rows = page.xpath("//table//tr//*")
        current = None

#Import each tables into Redis
# Import each table into Redis
        for e in rows:
            if not e.text:
                continue
@@ -86,6 +94,8 @@ for e in x.namelist():
# SET
# CVEID -> SET of REF
# REF is VENDOR:THEIRID
# K/V
# l:VENDOR -> URL

#update database info after successful program-run
# Update database info after successful program-run
info.update({'db': 'ref'}, {"$set": {'last-modified': u.headers['last-modified']}}, upsert=True)