summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extract-cves.py')
-rwxr-xr-xextract-cves.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/extract-cves.py b/extract-cves.py
new file mode 100755
index 0000000..8769511
--- /dev/null
+++ b/extract-cves.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+
+import re
+import sys
+import urllib2
+
+
+CVE_PATTERN = re.compile('CVE-(\d{4})-(\d+)')
+
+
+def main(argv):
+ response = urllib2.urlopen(argv[0])
+ cves = CVE_PATTERN.findall(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:]))