aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRobert Buchholz <rbu@gentoo.org>2007-10-28 19:17:09 +0000
committerRobert Buchholz <rbu@gentoo.org>2007-10-28 19:17:09 +0000
commit9104ff67ba1198a4e0e283de1fb1e029b576afb4 (patch)
tree4316425641ff535068e717adc197bb8f26eae33d /bin
parentNOTFORUS (diff)
downloadsecurity-9104ff67ba1198a4e0e283de1fb1e029b576afb4.tar.gz
security-9104ff67ba1198a4e0e283de1fb1e029b576afb4.tar.bz2
security-9104ff67ba1198a4e0e283de1fb1e029b576afb4.zip
Fix todo replacement by adding "append" option that does not replace.
svn path=/; revision=71
Diffstat (limited to 'bin')
-rwxr-xr-xbin/check-todo-issues26
1 files changed, 18 insertions, 8 deletions
diff --git a/bin/check-todo-issues b/bin/check-todo-issues
index 0768733..ce81166 100755
--- a/bin/check-todo-issues
+++ b/bin/check-todo-issues
@@ -28,10 +28,11 @@ def filterstring(strng):
class EntryEditor:
- def __init__(self, issue_regex, todo_regex, list_only, list_lines, bugreporter):
+ def __init__(self, issue_regex, todo_regex, replace_line, list_only, list_lines, bugreporter):
self.datafile = "./data/CVE/list"
self.issue_regex = issue_regex
self.todo_regex = todo_regex
+ self.replace_line = replace_line
self.editor = os.environ.get('EDITOR', os.environ.get('VISUAL', "nano"))
self.cvedb = CVEData()
@@ -178,10 +179,15 @@ class EntryEditor:
return product
def update_entry_todo(self, entry, replacement):
- import re
- matcher = re.compile(self.todo_regex)
- for idx, line in enumerate(entry):
- entry[idx] = matcher.sub(replacement, line)
+ replacement = "%s\n" % (replacement.rstrip())
+ if self.replace_line:
+ import re
+ matcher = re.compile(self.todo_regex)
+ for idx, line in enumerate(entry):
+ if matcher.match(line):
+ entry[idx] = replacement
+ else:
+ entry.append(replacement)
self.recently_saved = False
@@ -525,7 +531,7 @@ def miniusage():
def usage(programname):
""" Print usage information """
- print "Usage: %s [-h] [-l [-n <X>]] [-i <regex>] [-t <regex>] [-T]" % (programname)
+ print "Usage: %s [-h] [-l [-n <X>]] [-i <regex>] [-t <regex>] [-T] [-a]" % (programname)
print '''
This script reads entries from data/CVE/list and prints all items marked "TODO: check".
@@ -535,6 +541,7 @@ Parameters:
-n X When listing, only display X lines of description (default: 10)
-i regex Use regex to select issues (default: 'CVE-200[3-9]')
-t regex Use regex to select TODOs (default: '^\s+TODO: check$')
+ -a Append line instead of replacing (applies to NOT-FOR-US, BUG)
-T Same as -t '^\s+TODO: check' (note the missing $)
-u email Username for Bugzilla (PyBugz) interface
-p pass Password for Bugzilla (PyBugz) interface
@@ -552,13 +559,14 @@ def main():
import getopt
try:
optlist, list = getopt.getopt(sys.argv[1:],
- 'ln:hi:t:Tu:p:')
+ 'ln:hi:t:Tau:p:')
except getopt.GetoptError:
usage(sys.argv[0])
sys.exit(2)
issue_regex = '^CVE-200[3-9]'
todo_regex = '^\s+TODO: check$'
+ replace_line = True
bugz_password = None
bugz_username = None
list_only = False
@@ -578,6 +586,8 @@ def main():
if opt == '-T':
# no $ at the end
todo_regex = '^\s+TODO: check'
+ if opt == '-a':
+ replace_line = False
if opt == '-p':
bugz_password = arg
if opt == '-u':
@@ -585,7 +595,7 @@ def main():
os.chdir(setup_paths())
bugreporter = BugReporter(bugz_username, bugz_password)
- EntryEditor(issue_regex, todo_regex, list_only, list_lines, bugreporter)
+ EntryEditor(issue_regex, todo_regex, replace_line, list_only, list_lines, bugreporter)
if __name__ == "__main__":