[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r18321: {torflow} Tighten the constraints yet more. Associate attributes with (torflow/trunk/NetworkScanners)



Author: mikeperry
Date: 2009-01-29 10:05:09 -0500 (Thu, 29 Jan 2009)
New Revision: 18321

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

Tighten the constraints yet more. Associate attributes with
their tag. Only allow them to vary if they varied in that
same tag before.



Modified: torflow/trunk/NetworkScanners/libsoat.py
===================================================================
--- torflow/trunk/NetworkScanners/libsoat.py	2009-01-29 14:50:59 UTC (rev 18320)
+++ torflow/trunk/NetworkScanners/libsoat.py	2009-01-29 15:05:09 UTC (rev 18321)
@@ -292,14 +292,16 @@
     return ret
 
   def _get_attributes(self):
-    attrs_old = [tag.attrs for tag in self.soup_old.findAll()]
-    attrs_new = [tag.attrs for tag in self.soup_new.findAll()]
+    attrs_old = [(tag.name, tag.attrs) for tag in self.soup_old.findAll()]
+    attrs_new = [(tag.name, tag.attrs) for tag in self.soup_new.findAll()]
     attr_old = []
-    for attr_list in attrs_old:
-      attr_old.extend(attr_list) 
+    for (tag, attr_list) in attrs_old:
+      for attr in attr_list:
+        attr_old.append((tag, attr)) 
     attr_new = []
-    for attr_list in attrs_new:
-      attr_new.extend(attr_list)
+    for (tag, attr_list) in attrs_new:
+      for attr in attr_list:
+        attr_old.append((tag, attr)) 
     return (attr_old, attr_new)
     
   def changed_attributes(self):
@@ -347,7 +349,7 @@
     out = "Tags:\n"+"\n".join(tags)
     attrs = self.changed_attributes()
     out += "\n\nAttrs:\n"
-    for a in attrs:
+    for (tag, a) in attrs:
       out += a[0]+"="+a[1]+"\n"
     content = self.changed_content()
     out += "\n\nContent:\n"+"\n".join(map(str, content))

Modified: torflow/trunk/NetworkScanners/soat.py
===================================================================
--- torflow/trunk/NetworkScanners/soat.py	2009-01-29 14:50:59 UTC (rev 18320)
+++ torflow/trunk/NetworkScanners/soat.py	2009-01-29 15:05:09 UTC (rev 18321)
@@ -989,10 +989,15 @@
           changed_tags[t.name] = sets.Set([])
         for attr in t.attrs:
           changed_tags[t.name].add(attr[0])
-    for attr in old_vs_new.changed_attributes():
+    for (tag, attr) in old_vs_new.changed_attributes():
+      if tag not in changed_attributes:
+        changed_attributes[tag] = {}
+      changed_attributes[tag][attr[0]] = 1 
+    for (tag, attr) in new_vs_old.changed_attributes():
       changed_attributes[attr[0]] = 1 
-    for attr in new_vs_old.changed_attributes():
-      changed_attributes[attr[0]] = 1 
+      if tag not in changed_attributes:
+        changed_attributes[tag] = {}
+      changed_attributes[tag][attr[0]] = 1 
     
     changed_content = bool(old_vs_new.changed_content() or old_vs_new.changed_content())
 
@@ -1005,9 +1010,14 @@
            for attr in t.attrs:
              if attr[0] not in changed_tags[t.name]:
                false_positive = False
-    for attr in new_vs_tor.changed_attributes():
-      if attr[0] not in changed_attributes:
-        false_positive=False
+    for (tag, attr) in new_vs_tor.changed_attributes():
+      if tag in changed_attributes:
+        if attr[0] not in changed_attributes[tag]:
+          false_positive=False
+      else:
+        if not false_positive:
+          plog("ERROR", "False positive contradiction at "+exit_node+" for "+address)
+          false_positive = False
 
     if new_vs_tor.changed_content() and not changed_content:
       false_positive = False

Modified: torflow/trunk/NetworkScanners/soatstats.py
===================================================================
--- torflow/trunk/NetworkScanners/soatstats.py	2009-01-29 14:50:59 UTC (rev 18320)
+++ torflow/trunk/NetworkScanners/soatstats.py	2009-01-29 15:05:09 UTC (rev 18321)
@@ -112,7 +112,6 @@
       new_vs_tor = SoupDiffer(BeautifulSoup(open(result.tags, "r").read()), 
                 BeautifulSoup(open(result.exit_tags, 
                                "r").read()))
-
       changed_tags = {}
       changed_attributes = {}
       # I'm an evil man and I'm going to CPU hell..
@@ -128,10 +127,15 @@
             changed_tags[t.name] = sets.Set([])
           for attr in t.attrs:
             changed_tags[t.name].add(attr[0])
-      for attr in old_vs_new.changed_attributes():
+      for (tag, attr) in old_vs_new.changed_attributes():
+        if tag not in changed_attributes:
+          changed_attributes[tag] = {}
+        changed_attributes[tag][attr[0]] = 1 
+      for (tag, attr) in new_vs_old.changed_attributes():
         changed_attributes[attr[0]] = 1 
-      for attr in new_vs_old.changed_attributes():
-        changed_attributes[attr[0]] = 1 
+        if tag not in changed_attributes:
+          changed_attributes[tag] = {}
+        changed_attributes[tag][attr[0]] = 1 
       
       changed_content = bool(old_vs_new.changed_content() or old_vs_new.changed_content())
   
@@ -144,13 +148,18 @@
              for attr in t.attrs:
                if attr[0] not in changed_tags[t.name]:
                  false_positive = False
-      for attr in new_vs_tor.changed_attributes():
-        if attr[0] not in changed_attributes:
-          false_positive=False
+      for (tag, attr) in new_vs_tor.changed_attributes():
+        if tag in changed_attributes:
+          if attr[0] not in changed_attributes[tag]:
+            false_positive=False
+        else:
+          if not false_positive:
+            plog("ERROR", "False positive contradiction at "+exit_node+" for "+address)
+            false_positive = False
   
       if new_vs_tor.changed_content() and not changed_content:
         false_positive = False
-  
+ 
       print false_positive      
 
   print ""