[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. 0.51
David Steele
dsteele at gmail.com
Wed May 15 10:09:53 UTC 2013
The following commit has been merged in the master branch:
commit 81f60717660d74b5fd4de48a4f7918182c87955c
Author: David Steele <dsteele at gmail.com>
Date: Wed Apr 17 21:03:05 2013 -0400
detect_well_known_errors - Validate known_problem field names.
Only load known problem configuration files with correct fields
defined.
diff --git a/debian/changelog b/debian/changelog
index 650608e..55efd4f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -66,6 +66,7 @@ piuparts (0.51) UNRELEASED; urgency=low
- Replace the known_problem COMMAND with PATTERN and EXCLUDE_PATTERN,
and replace grep shell calls with python re modules calls, for a
10x speedup.
+ - Validate field names, and only use valid known problem conf files.
- Minor HTML syntax fix.
- Minor template integration.
diff --git a/master-bin/detect_well_known_errors b/master-bin/detect_well_known_errors
index 16b3f87..d50e3f6 100755
--- a/master-bin/detect_well_known_errors
+++ b/master-bin/detect_well_known_errors
@@ -109,8 +109,19 @@ class Problem():
self.name = os.path.basename(probpath)
self.short_name = os.path.splitext( self.name )[0]
+ self.tags_are_valid = True
+
+ self.required_tags = [ "PATTERN", "WHERE", "ISSUE",
+ "HEADER", "HELPTEXT"]
+ self.optional_tags = ["EXCLUDE_PATTERN", "EXPLAIN", "PRIORITY"]
+
+
self.init_problem()
+ for tag in self.required_tags:
+ if not tag in self.__dict__:
+ self.tags_are_valid = False
+
self.inc_re = re.compile( self.PATTERN )
if "EXCLUDE_PATTERN" in self.__dict__:
@@ -118,6 +129,9 @@ class Problem():
else:
self.exc_re = None
+ def valid(self):
+ return self.tags_are_valid
+
def init_problem(self):
"""Load problem file parameters (HELPTEXT="foo" -> self.HELPTEXT)"""
@@ -138,7 +152,10 @@ class Problem():
or re.search( '^\".+\"$', value, re.MULTILINE|re.DOTALL ):
value = value[1:-1]
- self.__dict__[name] = value
+ if name in self.required_tags or name in self.optional_tags:
+ self.__dict__[name] = value
+ else:
+ self.tags_are_valid = False
self.WHERE = self.WHERE.split(" ")
@@ -503,8 +520,15 @@ def detect_well_known_errors( config, problem_list, recheck, recheck_failed ):
def create_problem_list( pdir ):
- pfiles = [x for x in sorted(os.listdir(pdir)) if x.endswith(".conf")]
- plist = [Problem(os.path.join(pdir,x)) for x in pfiles]
+ plist = []
+
+ for pfile in [x for x in sorted(os.listdir(pdir)) if x.endswith(".conf")]:
+ prob = Problem(os.path.join(pdir,pfile))
+
+ if prob.valid():
+ plist.append(prob)
+ else:
+ print "Keyword error in %s - skipping" % pfile
return plist
--
piuparts git repository
More information about the Piuparts-commits
mailing list