[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r18410: {torflow} Fix some unicode issues and only move false failures for fal (torflow/trunk/NetworkScanners)
Author: mikeperry
Date: 2009-02-06 05:45:29 -0500 (Fri, 06 Feb 2009)
New Revision: 18410
Modified:
torflow/trunk/NetworkScanners/libsoat.py
torflow/trunk/NetworkScanners/soat.py
Log:
Fix some unicode issues and only move false failures for
false positives to the new dir.
Modified: torflow/trunk/NetworkScanners/libsoat.py
===================================================================
--- torflow/trunk/NetworkScanners/libsoat.py 2009-02-06 10:28:54 UTC (rev 18409)
+++ torflow/trunk/NetworkScanners/libsoat.py 2009-02-06 10:45:29 UTC (rev 18410)
@@ -319,6 +319,10 @@
results.append(result)
return results
+ def getResult(self, file):
+ fh = open(file, 'r')
+ return pickle.load(fh)
+
def safeFilename(self, str):
'''
remove characters illegal in some systems
@@ -326,10 +330,20 @@
'''
replaced = (str.replace('/','_').replace('\\','_').replace('?','_').replace(':','_').
replace('|','_').replace('*','_').replace('<','_').replace('>','_').replace('"',''))
- return replaced[:200]
+ return str(replaced[:200].decode('ascii', 'ignore'))
def resultFilename(self, result):
# XXX: Check existance and make a secondary name if exists.
+ address = ''
+ if result.__class__.__name__ == 'HtmlTestResult' or result.__class__.__name__ == 'HttpTestResult':
+ address = self.safeFilename(result.site[7:])
+ elif result.__class__.__name__ == 'SSLTestResult':
+ address = self.safeFilename(result.site[8:])
+ elif 'TestResult' in result.__class__.__name__:
+ address = self.safeFilename(result.site)
+ else:
+ raise Exception, 'This doesn\'t seems to be a result instance.'
+
dir = data_dir+result.proto.lower()+'/'
if result.false_positive:
dir += 'falsepositive/'
@@ -340,20 +354,10 @@
elif result.status == TEST_FAILURE:
dir += 'failed/'
- return dir+address+'.result.'+result.exit_node[1:]
+ return str((dir+address+'.result.'+result.exit_node[1:]).decode('ascii', 'ignore'))
def saveResult(self, result):
''' generic method for saving test results '''
- address = ''
- if result.__class__.__name__ == 'HtmlTestResult' or result.__class__.__name__ == 'HttpTestResult':
- address = self.safeFilename(result.site[7:])
- elif result.__class__.__name__ == 'SSLTestResult':
- address = self.safeFilename(result.site[8:])
- elif 'TestResult' in result.__class__.__name__:
- address = self.safeFilename(result.site)
- else:
- raise Exception, 'This doesn\'t seems to be a result instance.'
-
result_file = open(self.resultFilename(result), 'w')
pickle.dump(result, result_file)
result_file.close()
Modified: torflow/trunk/NetworkScanners/soat.py
===================================================================
--- torflow/trunk/NetworkScanners/soat.py 2009-02-06 10:28:54 UTC (rev 18409)
+++ torflow/trunk/NetworkScanners/soat.py 2009-02-06 10:45:29 UTC (rev 18410)
@@ -402,14 +402,15 @@
if r.site == address:
kill_results.append(r)
for r in kill_results:
- # Save this new result file in false positive dir
- # and remove old one
- try:
- os.unlink(self.datahandler.resultFilename(r))
- except:
- pass
- r.mark_false_positive(reason)
- self.datahandler.saveResult(r)
+ if r.status == TEST_FAILURE:
+ # Save this new result file in false positive dir
+ # and remove old one
+ try:
+ os.unlink(self.datahandler.resultFilename(r))
+ except:
+ pass
+ r.mark_false_positive(reason)
+ self.datahandler.saveResult(r)
self.results.remove(r)
def register_exit_failure(self, address, exit_node):