forked from adulau/cve-search
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump_last.py
59 lines (47 loc) · 1.67 KB
/
dump_last.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3.1
# -*- coding: utf-8 -*-
#
# Dump last CVE entries in RSS 1,RSS 2 or Atom format.
#
# Software is free software released under the "Modified BSD license"
#
# Copyright (c) 2012-2013 Alexandre Dulaunoy - [email protected]
import sys
import time
import datetime
import argparse
sys.path.append("./lib/")
import cves
argParser = argparse.ArgumentParser(description='Dump last CVE entries in RSS/Atom format ')
argParser.add_argument('-f', type=str, help='Output format (rss1,rss2,atom)',default='rss1')
argParser.add_argument('-l', type=int, help='Last n items (default:10)', default=10)
args = argParser.parse_args()
if args.l:
last = args.l
else:
last = 10
ref = "http://adulau.github.com/cve-search/"
cves = cves.last(rankinglookup = False, namelookup = False)
from feedformatter import Feed
feed = Feed()
feed.feed['title'] = "cve-search Last "+str(last)+" CVE entries generated on "+str(datetime.datetime.now())
feed.feed['link'] = "http://adulau.github.com/cve-search/"
feed.feed['author'] = "Generated with cve-search available at http://adulau.github.com/cve-search/"
feed.feed['description'] = ""
for x in cves.get(limit=last):
item = {}
item['title'] = str(x['id']) + " " + x['summary'][90:]
item['description'] = x['summary']
item['pubDate'] = time.localtime()
item['guid'] = x['id']
if x['references']:
item["link"] = str(x['references'][0])
else:
item["link"] = "http://web.nvd.nist.gov/view/vuln/detail?vulnId=" + x['id']
feed.items.append(item)
if args.f == "rss1":
print (feed.format_rss1_string())
elif args.f == "atom":
print (feed.format_atom_string())
else:
print (feed.format_rss2_string())