Author: shadzik
Date: Wed Aug  5 19:14:37 2009
New Revision: 10451

Modified:
   security/cve_reader.py
Log:
- add getCVEdesc function and try to use it in RSS feed


Modified: security/cve_reader.py
==============================================================================
--- security/cve_reader.py      (original)
+++ security/cve_reader.py      Wed Aug  5 19:14:37 2009
@@ -11,6 +11,8 @@
 import readline
 import time
 import datetime
+from pyquery import PyQuery as pq
+import urllib2
 
 import PyRSS2Gen
 try:
@@ -227,6 +229,17 @@
                # Huh, new entry is the youngest one
                rootnode.insert(len(rootnode), package)
 
+# get cve description
+def getCVEdesc(cveID):
+       html = 
urllib2.urlopen("http://cve.mitre.org/cgi-bin/cvename.cgi?name=%s"; % 
cveID).read()
+       html = pq(html)
+       line = 0
+       for i in html("td"):
+               if line == 55:
+                       return i.text
+               line = line + 1
+
+
 # returns index (tag position) in the node which is a list
 def getTagIndex(node, tag):
        item = ""
@@ -326,10 +339,12 @@
                
                # retrives CVEs
                cves = ""
+               cvedesc = ""
                idx = getTagIndex(rootnode[item], 'cves')
                
                for i in range(len(rootnode[item][idx])):
                        cves += "<a 
href=\"http://cve.mitre.org/cgi-bin/cvename.cgi?name=%s\";>%s</a> " % 
(rootnode[item][idx][i].text, rootnode[item][idx][i].text)
+                       cvedesc += getCVEdesc(rootnode[item][idx][i].text)
                        
                # date[0] - year; date[1] - month; date[2] - day
                date = pkg['date'].split('/')
@@ -337,7 +352,7 @@
                rssitem.insert(0,
                        PyRSS2Gen.RSSItem(
                                title = "New CVE fixes for %s" % pkg['spec'],
-                               description = "%s on rev. %s resolves: %s" % 
(pkg['spec'], pkg['revision'], cves),
+                               description = "%s on rev. %s resolves: 
%s\n\nDescriptions:\n%s" % (pkg['spec'], pkg['revision'], cves, cvedesc),
                                pubDate = datetime.datetime(int(date[0]), 
int(date[1]), int(date[2]), 0, 0, 0),
                                guid = 
PyRSS2Gen.Guid("http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/%s?rev=%s"; % 
(pkg['spec'], pkg['revision']))
                        )
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to