commit:     f1b0fc1adfd405ff9ebb5738959ce4966371f936
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 15 16:10:49 2016 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Thu Sep 15 16:10:49 2016 +0000
URL:        
https://gitweb.gentoo.org/proj/chromium-tools.git/commit/?id=f1b0fc1a

extract-cves: simplify output

This allows for easy copy/paste into the bugzilla alias field.

 extract-cves.py | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/extract-cves.py b/extract-cves.py
index 4ccfbf7..a1dc5ee 100755
--- a/extract-cves.py
+++ b/extract-cves.py
@@ -9,25 +9,13 @@ try:
 except ImportError:
   from urllib2 import urlopen
 
-CVE_PATTERN = re.compile('CVE-(\d{4})-(\d+)')
+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))
+  cves = set(CVE_PATTERN.findall(str(response.read())))
+  print(','.join(cves))
   return 0
 
 

Reply via email to