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

Fetch compressed NIST cvedb files only. Fix #98

parent 5b8bb386
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -198,15 +198,15 @@ if __name__ == '__main__':
        # get the 'modified' file
        getfile = file_prefix + file_mod + file_suffix
        try:
            f = Configuration.getFile(Configuration.getCVEDict() + getfile)
            (f, r) = Configuration.getFile(Configuration.getCVEDict() + getfile, compressed = True)
        except:
            sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(Configuration.getCVEDict() + getfile))
        i = dbLayer.getInfo("cve")
        if i is not None:
            if f.headers['last-modified'] == i['last-modified']:
            if r.headers['last-modified'] == i['last-modified']:
                print("Not modified")
                sys.exit(0)
        dbLayer.setColUpdate("cve", f.headers['last-modified'])
        dbLayer.setColUpdate("cve", r.headers['last-modified'])

        # get your parser on !!
        parser = make_parser()
@@ -219,7 +219,8 @@ if __name__ == '__main__':
            # if so, update the entry.
            if x:
                if 'cvss' not in item:
                    item['cvss'] = defaultvalue['cvss']
                    #item['cvss'] = defaultvalue['cvss']
                    item['cvss'] = None
                if 'cwe' not in item:
                    item['cwe'] = defaultvalue['cwe']
                dbLayer.updateCVE(item)
@@ -228,7 +229,7 @@ if __name__ == '__main__':
        # get the 'recent' file
        getfile = file_prefix + file_rec + file_suffix
        try:
            f = Configuration.getFile(Configuration.getCVEDict() + getfile)
            (f, r) = Configuration.getFile(Configuration.getCVEDict() + getfile, compressed = True)
        except:
            sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(Configuration.getCVEDict() + getfile))
        parser = make_parser()
@@ -268,7 +269,7 @@ if __name__ == '__main__':
                parser.setContentHandler(ch)
                getfile = file_prefix + str(x) + file_suffix
                try:
                    f = Configuration.getFile(Configuration.getCVEDict() + getfile)
                    (f, r) = Configuration.getFile(Configuration.getCVEDict() + getfile, compressed = True)
                except:
                    sys.exit("Cannot open url %s. Bad URL or not connected to the internet?"%(Configuration.getCVEDict() + getfile))
                parser.parse(f)