feed.items.append(item)
    else:
        print('<div class="cve"><table><tbody>')
        print('<tr class="alt">')
        print("<td>" + str(x["id"]) + " - " + html.escape(x["summary"][:90]) +
              "...</td>")
        print("</tr>")
        print("<tr><td>CVSS: " + str(x["cvss"]) + " Published: " +
              str(x["Published"]) + "</td></tr>")
        print("<tr>")
        print("<td> Summary: " + html.escape(x["summary"]) + "</td>")
        print("</tr>")
        print("<tr><td>Vulnerable configuration:</td></tr>")
        print("<tr><td><ul>")
        for v in x["vulnerable_configuration"]:
            sys.stdout.write("<li>" + cvelist.getcpe(v) + "</li>")
        print("</ul></td></tr>")
        if x.get("ranking"):
            print("<tr><td>Ranking:" + str(x["ranking"]) + "</td></tr>")
        print("<tr><td>References:<td></tr>")
        print("<tr><td><ul>")
        for r in x["references"]:
            sys.stdout.write('<li><a href="' + str(r) + '">' + str(r) +
                             "</a></li>")
        print("</ul></tr></td>")
        print("</tbody></table></div><br/>")
if args.f == "rss1":
    print(feed.format_rss1_string())
elif args.f == "atom":
    print(feed.format_atom_string())
elif args.f == "html":
Esempio n. 2
0
else:
    ix = open_dir(indexpath)


def dumpallcveid(entry=None):
    return getCVEIDs if not entry else getCVEIDs(int(entry))


def getcve(cveid=None):
    if cveid is None:
        return False
    return getCVE(cveid)


for cveid in tqdm(dumpallcveid(entry=args.l), desc="Processing"):
    try:
        writer = ix.writer()
    except:
        logger.error("Index is locked. Another db_fulltext process running?")
        sys.exit(1)
    item = getcve(cveid=cveid)
    title = item["summary"][0:70]
    if args.n:
        for v in item["vulnerable_configuration"]:
            cpe = c.getcpe(cpeid=v).strip("\n")
            item["summary"] += " " + cpe
    if args.v:
        logger.debug("Indexing CVE-ID " + str(cveid) + " " + title)
    writer.update_document(title=title, path=cveid, content=item["summary"])
    writer.commit()