Author: gilbert-guest Date: 2009-08-24 01:48:47 +0000 (Mon, 24 Aug 2009) New Revision: 12669 Modified: bin/inject-embedded-code-copies Log: cleanup of inject-embedded-code-copies, copyright notice added Modified: bin/inject-embedded-code-copies ==================================================================--- bin/inject-embedded-code-copies 2009-08-24 00:59:44 UTC (rev 12668) +++ bin/inject-embedded-code-copies 2009-08-24 01:48:47 UTC (rev 12669) @@ -1,4 +1,20 @@ #!/usr/bin/python +# +# inject embedded code copy data into the secure-testing cve list +# +# Copyright (C) 2009 Michael S Gilbert +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. import os import sys @@ -8,8 +24,8 @@ sys.stderr.write( ''usage: %s <embedded code copies file> <cve list>\n'' % sys.argv[0] ) sys.exit( 1 ) -todo_note = ''\tTODO: check embedded %s code copy [- %s %s]'' -todo_note2 = ''\tTODO: check original source code [- %s <unfixed>]; embedded by %s'' +todo_note = ''\tTODO: check embedded %s code copy [- %s %s]\n'' +todo_note2 = ''\tTODO: check original source code [- %s <unfixed>]; embedded by %s\n'' fname_embed = sys.argv[1] fname_cve = sys.argv[2] @@ -24,7 +40,6 @@ origlist = [] embedlist = [] typelist = [] -nembeds = 0 found_begin = False fembed = open( fname_embed , ''r'' ) line = fembed.readline() @@ -50,8 +65,6 @@ ftemp = open( fname_temp , ''w'' ) lines = [] -cvelines = 0 -maxlines = 1000 changed = False fcve = open( fname_cve , ''r'' ) line = fcve.readline() @@ -66,7 +79,7 @@ package = lines[n].lstrip( ''\t- '' ).split( '' '' )[0] # inject TODOs for packages that embed affected versions - if package in origlist: + while package in origlist: found_entry = False index = origlist.index( package ) for m in range( 0 , len( lines ) ): @@ -78,7 +91,8 @@ found_entry = True if not found_entry: changed = True - ftemp.write( todo_note % ( package , embedlist[index] , typelist[index] ) + ''\n'' ) + ftemp.write( todo_note % ( package , embedlist[index] , typelist[index] ) ) + origlist[index] = '''' # inject TODOs for original sources that are embeded in affected packages # while package in embedlist: @@ -93,14 +107,13 @@ # found_entry = True # if not found_entry: # changed = True -# ftemp.write( todo_note2 % ( origlist[index] , package ) + ''\n'' ) +# ftemp.write( todo_note2 % ( origlist[index] , package ) ) # embedlist[index] = '''' ftemp.write( line ) lines = [] nlines = 0 - cvelines += 1 line = fcve.readline() fcve.close() ftemp.close()