SVN: security/cve_reader.py

shadzik shadzik at pld-linux.org
Sat Oct 6 18:55:27 CEST 2007


Author: shadzik
Date: Sat Oct  6 18:55:27 2007
New Revision: 8796

Modified:
   security/cve_reader.py
Log:
- fixed bug in compRevs() function (this was rather critical)
- now we can display one auto-tag for each PLD line that resolves a given CVE


Modified: security/cve_reader.py
==============================================================================
--- security/cve_reader.py	(original)
+++ security/cve_reader.py	Sat Oct  6 18:55:27 2007
@@ -4,7 +4,7 @@
 # Basicly it parses commits.log and searches for "CVE" keyword, then it generates a .html file with simple table structure
 #
 # TODO
-# - display all auto-ac, auto-th and auto-ti tags if they resolve the same CVE
+# - rss(?)
 #
 import os
 import sys
@@ -73,12 +73,18 @@
 			f1.write("<td>%s</td>\n" % (revs[x]))
 			f1.write("<td>%s</td></tr>\n" % (revs[x]))
 		else:
-			rev_tag = resolved.split(":")
 			f1.write("<tr><td>%s</td>\n" % (date[x]))
-			f1.write("<td><a href=\"http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/%s?logsort=rev;only_with_tag=%s\">%s</a></td>\n" % (specs[x], rev_tag[0], specs[x]))
+			f1.write("<td>")
+			for i in range(len(resolved)):
+				rev_tag = resolved[i].split(":")
+				f1.write("<a href=\"http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SPECS/%s?logsort=rev;only_with_tag=%s\">%s</a><br/>" % (specs[x], rev_tag[0], specs[x]))
+			f1.write("</td>\n")
 			f1.write("<td>%s</td>\n" % (cves[x]))
 			f1.write("<td>%s</td>\n" % (revs[x]))
-			f1.write("<td>%s</td></tr>\n" % (resolved))
+			f1.write("<td>")
+			for i in range(len(resolved)):
+				f1.write("%s<br/>" % (resolved[i]))
+			f1.write("</td></tr>\n")
 		x = x-1
 	f1.close()
 	# write new file size
@@ -91,14 +97,34 @@
 # get cvs log entries (auto-tags) for specs
 def getCVSentry(spec, revision):
 	tags = []
+	match_tag = []
+	ac_tag = ""
+	th_tag = ""
+	ti_tag = ""
 	autotag = os.popen("cvs -d %s log -tr%s: %s%s |grep -A300 symbolic |grep auto" % (cvsroot, revision, cvsmodule, spec))
 	for l in autotag.xreadlines():
 		l = l.strip()
 		tags.append(l)
 	try:
-		tag_rev = tags[0].split(" ")
-		if compRevs(tag_rev[1], revision)==0:
-			return tags[0]
+		for i in range(len(tags)):
+			tag_rev = tags[i].split(" ")
+			if re.match('^auto-ac.*\:', tags[i]):
+				if compRevs(tag_rev[1], revision)==0:
+					if ac_tag=="":
+						ac_tag = tags[i]
+						match_tag.append(ac_tag)
+			elif re.match('^auto-th.*\:', tags[i]):
+				if compRevs(tag_rev[1], revision)==0:
+					if th_tag=="":
+						th_tag = tags[i]
+						match_tag.append(th_tag)
+			elif re.match('^auto-ti.*\:', tags[i]):
+				if compRevs(tag_rev[1], revision)==0:
+					if ti_tag=="":
+						ti_tag = tags[i]
+						match_tag.append(ti_tag)
+		if len(match_tag):
+			return match_tag
 		else:
 			return 0
 	except(IndexError):
@@ -139,8 +165,8 @@
 	rev2 = rev2.split(".")
 	if len(rev1) >= len(rev2):
 		for x in range(len(rev2)):
-			if (rev1[x]!=rev2[x]): 
-				if (rev1[x]>rev2[x]):
+			if int(rev1[x])!=int(rev2[x]): 
+				if int(rev1[x])>int(rev2[x]):
 					return 0
 					break
 				else:
@@ -148,8 +174,8 @@
 					break
 	elif len(rev1) < len(rev2):
 		for x in range(len(rev1)):
-			if (rev1[x]!=rev2[x]):
-				if (rev1[x]>rev2[x]):
+			if int(rev1[x])!=int(rev2[x]):
+				if int(rev1[x])>int(rev2[x]):
 					return 0
 					break
 				else:


More information about the pld-cvs-commit mailing list