예제 #1
0
runPath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(os.path.join(runPath, ".."))

from lib.CVEs import CveHandler
from lib.DatabaseLayer import getCVEIDs


argParser = argparse.ArgumentParser(description='Dump database in JSON format')
argParser.add_argument('-r', default=False, action='store_true', help='Include ranking value')
argParser.add_argument('-v', default=False, action='store_true', help='Include via4 map')
argParser.add_argument('-c', default=False, action='store_true', help='Include CAPEC information')
argParser.add_argument('-l', default=False, type=int, help='Limit output to n elements (default: unlimited)')
args = argParser.parse_args()

rankinglookup = args.r
via4lookup = args.v
capeclookup = args.c

cves = CveHandler(rankinglookup=rankinglookup, via4lookup=via4lookup, capeclookup=capeclookup)

for cveid in getCVEIDs(limit=args.l):
    item = cves.getcve(cveid=cveid)
    if 'cvss' in item:
        if type(item['cvss']) == str:
            item['cvss'] = float(item['cvss'])
    date_fields = ['cvss-time', 'Modified', 'Published']
    for field in date_fields:
        if field in item:
            item[field] = str(item[field])
    print(json.dumps(item, sort_keys=True, default=json_util.default))
예제 #2
0
    # Serach multiple products in one query
    for cpe in vSearch:
        search_product(cpe)
    if htmlOutput:
        print("</body></html>")
    sys.exit(0)

# Search text in summary
if summary_text:
    import lib.CVEs as cves

    l = cves.last(rankinglookup=rankinglookup,
                  namelookup=namelookup,
                  capeclookup=capeclookup)

    for cveid in getCVEIDs(limit=nlimit):
        item = l.getcve(cveid=cveid)
        if "cvss" in item:
            if type(item["cvss"]) == str:
                item["cvss"] = float(item["cvss"])
        date_fields = ["cvss-time", "Modified", "Published"]
        for field in date_fields:
            if field in item:
                item[field] = str(item[field])
        if summary_text.upper() in item["summary"].upper():
            if not last_ndays:
                if vOutput:
                    printCVE_id(item)
                else:
                    print(
                        json.dumps(item,
예제 #3
0
def dumpallcveid(entry=None):
    return getCVEIDs if not entry else getCVEIDs(int(entry))