diff options
author | Pawel Hajdan, Jr <phajdan.jr@gentoo.org> | 2011-10-25 18:35:21 +0200 |
---|---|---|
committer | Pawel Hajdan, Jr <phajdan.jr@gentoo.org> | 2011-10-25 18:35:55 +0200 |
commit | 149fe3801a3bb99caf635cfe26b31522171349d1 (patch) | |
tree | c86020e80716e6b38180267f5d21f96cf24341f0 | |
parent | Clean up: (diff) | |
download | chromium-tools-149fe3801a3bb99caf635cfe26b31522171349d1.tar.gz chromium-tools-149fe3801a3bb99caf635cfe26b31522171349d1.tar.bz2 chromium-tools-149fe3801a3bb99caf635cfe26b31522171349d1.zip |
Add tool to extract CVE numbers from a webpage.
Useful for filing the security bug based on release notes.
-rwxr-xr-x | extract-cves.py | 31 |
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:])) |