[or-cvs] r18495: {torflow} Make the attribute-based false positive filters only care ab (torflow/trunk/NetworkScanners)

mikeperry at seul.org mikeperry at seul.org
Wed Feb 11 17:51:06 UTC 2009


Author: mikeperry
Date: 2009-02-11 12:51:06 -0500 (Wed, 11 Feb 2009)
New Revision: 18495

Modified:
   torflow/trunk/NetworkScanners/libsoat.py
   torflow/trunk/NetworkScanners/soat.py
Log:

Make the attribute-based false positive filters only care
about relevant attributes. Also improve some failure
reporting.



Modified: torflow/trunk/NetworkScanners/libsoat.py
===================================================================
--- torflow/trunk/NetworkScanners/libsoat.py	2009-02-11 17:23:11 UTC (rev 18494)
+++ torflow/trunk/NetworkScanners/libsoat.py	2009-02-11 17:51:06 UTC (rev 18495)
@@ -84,8 +84,7 @@
     return os.path.normpath(os.path.join(new_data_root, *split_file[1:]))
 
   def rebase(self, new_data_root):
-    if 'filename' in self.__dict__: # XXX: Kill this...
-      self.filename = self._rebase(self.filename, new_data_root)
+    self.filename = self._rebase(self.filename, new_data_root)
  
   def mark_false_positive(self, reason):
     self.false_positive=True
@@ -668,7 +667,8 @@
           return True
         else:
           for attr in t.attrs:
-            if attr[0] not in tag_attr_map[t.name]:
+            if attr[0] not in tag_attr_map[t.name] \
+                and attr[0] in attrs_to_check_map:
               return True
     return False
 
@@ -680,7 +680,8 @@
           ret += " New Tag: "+str(t)+"\n"
         else:
           for attr in t.attrs:
-            if attr[0] not in tag_attr_map[t.name]:
+            if attr[0] not in tag_attr_map[t.name] \
+                 and attr[0] in attrs_to_check_map:
               ret += " New Attr "+attr[0]+": "+str(t)+"\n"
     return ret
 
@@ -732,7 +733,8 @@
         (returned from changed_attributes_by_tag) """
     for (tag, attr) in self.changed_attributes():
       if tag in attrs_by_tag:
-        if attr[0] not in attrs_by_tag[tag]:
+        if attr[0] not in attrs_by_tag[tag] \
+            and attr[0] in attrs_to_check_map:
           return True
       else:
         return True
@@ -742,7 +744,8 @@
     ret = ""
     for (tag, attr) in self.changed_attributes():
       if tag in attrs_by_tag:
-        if attr[0] not in attrs_by_tag[tag]:
+        if attr[0] not in attrs_by_tag[tag] \
+            and attr[0] in attrs_to_check_map:
           ret += " New Attr "+attr[0]+": "+tag+" "+attr[0]+'="'+attr[1]+'"\n'
       else:
         ret += " New Tag: "+tag+" "+attr[0]+'="'+attr[1]+'"\n'
@@ -866,7 +869,6 @@
     return self._difference_checker(other_cnts) 
 
   def show_differences(self, other_string):
-    ret = ""
     if not HAVE_PYPY:
       return "PyPy import not present. Not diffing javascript"
     other_cnts = self._count_ast_elements(other_string)

Modified: torflow/trunk/NetworkScanners/soat.py
===================================================================
--- torflow/trunk/NetworkScanners/soat.py	2009-02-11 17:23:11 UTC (rev 18494)
+++ torflow/trunk/NetworkScanners/soat.py	2009-02-11 17:51:06 UTC (rev 18495)
@@ -136,26 +136,26 @@
   except urllib2.HTTPError, e:
     plog('NOTICE', "HTTP Error during request of "+address+": "+str(e))
     traceback.print_exc()
-    return (e.code, [], "", str(e)) 
+    return (e.code, [], "", e.__class__.__name__+str(e)) 
   except (ValueError, urllib2.URLError):
     plog('WARN', 'The http-request address ' + address + ' is malformed')
     traceback.print_exc()
     return (0, [], "", "")
   except socks.Socks5Error, e:
-    if e.value[0] == 1 or e.value[0] == 6: # Timeout or 'general'
+    if e.value[0] == 6: #  or e.value[0] == 1: # Timeout or 'general'
       plog('NOTICE', 'An error occured while negotiating socks5 with Tor: '+str(e))
       traceback.print_exc()
       return (0, [], "", "")
     else:
       plog('WARN', 'An unknown SOCKS5 error occured for '+address+": "+str(e))
       traceback.print_exc()
-      return (666, [], "", str(e))
+      return (666, [], "", e.__class__.__name__+str(e))
   except KeyboardInterrupt:
     raise KeyboardInterrupt
   except Exception, e:
     plog('WARN', 'An unknown HTTP error occured for '+address+": "+str(e))
     traceback.print_exc()
-    return (666, [], "", str(e))
+    return (666, [], "", e.__class__.__name__+str(e))
 
   return (reply.code, new_cookies, mime_type, content)
 
@@ -712,9 +712,9 @@
     
     if not ((mime_type == mime_type_new or not mime_type) \
                and mime_type_new == pmime_type):
+      if not mime_type: mime_type = "text/disk"
       plog("WARN", "Mime type change: 1st: "+mime_type+", 2nd: "+mime_type_new+", Tor: "+pmime_type)
       # TODO: If this actually happens, store a result.
-      mime_type = 'text/html'; 
 
     # Dirty dirty dirty...
     return (mime_type_new, pcontent, psha1sum, content, sha1sum, content_new, 
@@ -1077,7 +1077,7 @@
       plog('WARN','An error occured while opening an ssl connection to '+address+": "+str(e))
       return e
     except socks.Socks5Error, e:
-      if e.value[0] == 1 or e.value[0] == 6: # Timeout or 'general'
+      if e.value[0] == 6: #  or e.value[0] == 1: # Timeout or 'general'
         plog('NOTICE', 'An error occured while negotiating socks5 for '+address+': '+str(e))
         return -1
       else:
@@ -1225,7 +1225,7 @@
     if isinstance(cert, Exception):
       plog('ERROR', 'SSL failure with exception '+str(cert)+' for: '+address+' via '+exit_node)
       result = SSLTestResult(exit_node, address, ssl_file_name, TEST_FAILURE, 
-                             FAILURE_MISCEXCEPTION+str(cert)) 
+              FAILURE_MISCEXCEPTION+":"+cert.__class__.__name__+str(cert)) 
       self.results.append(result)
       self.datahandler.saveResult(result)
       self.register_exit_failure(address, exit_node)
@@ -1237,7 +1237,7 @@
     except OpenSSL.crypto.Error, e:
       plog('ERROR', 'SSL failure with exception '+str(e)+' for: '+address+' via '+exit_node)
       result = SSLTestResult(exit_node, address, ssl_file_name, TEST_FAILURE, 
-                             FAILURE_MISCEXCEPTION+str(e)) 
+              FAILURE_MISCEXCEPTION+":"+e.__class__.__name__+str(e)) 
       self.results.append(result)
       self.datahandler.saveResult(result)
       self.register_exit_failure(address, exit_node)



More information about the tor-commits mailing list