blob: 4ccfbf7da680c0c75c8504502ffd3c495ea9a9c2 (
plain)
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
|
#!/usr/bin/env python
from __future__ import print_function
import re
import sys
try:
from urllib.request import urlopen
except ImportError:
from urllib2 import urlopen
CVE_PATTERN = re.compile('CVE-(\d{4})-(\d+)')
def main(argv):
response = urlopen(argv[0])
cves = CVE_PATTERN.findall(str(response.read()))
years = {}
for year, no in cves:
if year not in years:
years[year] = []
years[year].append(no)
result = []
for year in sorted(years.keys()):
nos = years[year]
if len(nos) == 1:
result.append('CVE-%s-%s' % (year, nos[0]))
else:
result.append('CVE-%s-{%s}' % (year, ','.join(sorted(nos))))
print(' '.join(result))
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))
|