Commit 3bfaf6d9 authored by Alexandre Dulaunoy's avatar Alexandre Dulaunoy
Browse files

Minimal getref method to list all known NIST references

TODO: Lookup table per vendor with their respective URL
parent 8f83d072
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ class last:

    def __init__(self, collection="cves", rankinglookup=False,
                 namelookup=False, vfeedlookup=False,
                 capeclookup=False, subscorelookup=False):
                 capeclookup=False, subscorelookup=False, reflookup=False):

        self.collectionname = collection
        self.rankinglookup = rankinglookup
@@ -47,6 +47,8 @@ class last:
            self.vfeed = connectdb['vfeed']
        if capeclookup:
            self.capec = connectdb['capec']
        if reflookup:
            self.ref = Configuration.getRedisRefConnection()

    def getcapec(self, cweid=None):
        if cweid is None or not self.capeclookup:
@@ -58,6 +60,12 @@ class last:
            capec.append(f)
        return capec

    def getref(self, cveid=None):
        if cveid is None or not self.ref:
            return False
        ref = self.ref.smembers(cveid)
        return ref

    def getcpe(self, cpeid=None):

        if not(self.namelookup):
@@ -188,5 +196,7 @@ def test_last():
    l = last(rankinglookup=False, vfeedlookup=True, capeclookup=True)
    print (l.getcve("CVE-2015-0597"))
    print (l.getcapec("200"))
    l = last(reflookup=True)
    print(l.getref("CVE-2015-0597"))
if __name__ == "__main__":
    test_last()