@@ -80,6 +80,7 @@ def vulnTest():
8080
8181 retVal = True
8282 count = 0
83+ cleanups = []
8384
8485 while True :
8586 address , port = "127.0.0.1" , random .randint (10000 , 65535 )
@@ -130,22 +131,27 @@ def _thread():
130131
131132 handle , config = tempfile .mkstemp (suffix = ".conf" )
132133 os .close (handle )
134+ cleanups .append (config )
133135
134136 handle , database = tempfile .mkstemp (suffix = ".sqlite" )
135137 os .close (handle )
138+ cleanups .append (database )
136139
137140 with sqlite3 .connect (database ) as conn :
138141 c = conn .cursor ()
139142 c .executescript (vulnserver .SCHEMA )
140143
141144 handle , request = tempfile .mkstemp (suffix = ".req" )
142145 os .close (handle )
146+ cleanups .append (request )
143147
144148 handle , log = tempfile .mkstemp (suffix = ".log" )
145149 os .close (handle )
150+ cleanups .append (log )
146151
147152 handle , multiple = tempfile .mkstemp (suffix = ".lst" )
148153 os .close (handle )
154+ cleanups .append (multiple )
149155
150156 content = "POST / HTTP/1.0\n User-Agent: foobar\n Host: %s:%s\n \n id=1\n " % (address , port )
151157 with open (request , "w+" ) as f :
@@ -207,6 +213,12 @@ def _thread():
207213 else :
208214 logger .error ("vuln test final result: FAILED" )
209215
216+ for filename in cleanups :
217+ try :
218+ os .remove (filename )
219+ except :
220+ pass
221+
210222 return retVal
211223
212224def smokeTest ():
0 commit comments