@@ -40,6 +40,8 @@ def rm(self, path):
4040 self .entries .pop (path )
4141
4242 def write (self , path , val ):
43+ if len (path ) > 64 :
44+ raise DummyQubesDBError (0 , 'Error' )
4345 self .entries [path ] = val
4446
4547 def multiread (self , prefix ):
@@ -65,6 +67,8 @@ def read_watch(self):
6567 except IndexError :
6668 return None
6769
70+ class DummyQubesDBError (Exception ):
71+ "Raised by QubesDB"
6872
6973class FirewallWorker (qubesagent .firewall .FirewallWorker ):
7074 def __init__ (self ):
@@ -159,6 +163,23 @@ def test_701_dns_info(self):
159163 self .obj .apply_rules ('10.137.0.1' , [{'action' : 'drop' }])
160164 self .assertIsNone (self .obj .qdb .read ('/dns/10.137.0.1/ripe.net' ))
161165
166+ def test_702_dns_info_qubesdb_path_length_crash (self ):
167+ self .obj .conntrack_get_connections = Mock (return_value = [])
168+ rules = [
169+ {'action' : 'accept' , 'proto' : 'tcp' ,
170+ 'dstports' : '443-443' , 'dsthost' : 'www.google.com' },
171+ {'action' : 'accept' , 'proto' : 'tcp' ,
172+ 'dstports' : '443-443' , 'dsthost' : 'prod-dynamite-prod-05-us-signaler-pa.clients6.google.com' },
173+ {'action' : 'drop' },
174+ ]
175+ self .obj .apply_rules ('10.137.0.22' , rules )
176+ self .assertIsNotNone (self .obj .qdb .read ('/dns/10.137.0.22/www.google.com' ))
177+ # Unfortunately, this is assertIsNone until the QubesDB path length limit is raised.
178+ self .assertIsNone (self .obj .qdb .read ('/dns/10.137.0.22/prod-dynamite-prod-05-us-signaler-pa.clients6.google.com' ))
179+ self .obj .apply_rules ('10.137.0.22' , [{'action' : 'drop' }])
180+ self .assertIsNone (self .obj .qdb .read ('/dns/10.137.0.22/www.google.com' ))
181+ self .assertIsNone (self .obj .qdb .read ('/dns/10.137.0.22/prod-dynamite-prod-05-us-signaler-pa.clients6.google.com' ))
182+
162183class TestNftablesWorker (TestCase , WorkerCommon ):
163184 def setUp (self ):
164185 super (TestNftablesWorker , self ).setUp ()
0 commit comments