Skip to content

Commit

Permalink
Added better unit testing for DNS
Browse files Browse the repository at this point in the history
darcs-hash:20090523001054-f1522-54b7bcbc0e028f0cf35e09655c4d23b8de49720c.gz
  • Loading branch information
scudette committed May 23, 2009
1 parent 946d57f commit 63d7141
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/plugins/NetworkForensics/ProtocolHandlers/DNS.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ class DNSScanner(StreamScannerFactory):

def process_stream(self, stream, factories):
forward_stream, reverse_stream = self.stream_to_server(stream, "DNS")
print "forward_stream %s, reverse_stream %s" % (forward_stream, reverse_stream)
if reverse_stream:
fd = self.fsfd.open(inode_id=reverse_stream)
## We assume maximum length for DNS (this might be too
Expand Down Expand Up @@ -238,6 +237,12 @@ def test01DNS(self):
argv=["*", ## Inodes (All)
"DNSScanner",
]) ## List of Scanners
dbh = DB.DBO(self.test_case)
dbh.execute("select * from dns where name = 'www.google.com.'")
self.assert_(dbh.fetch())
dbh.execute("select count(*) as c from dns where name like '%google%'")
row = dbh.fetch()
self.assertEqual(row['c'], 14)

if __name__=='__main__':
test_str = 'Q\xcf\x81\x80\x00\x01\x00\x03\x00\x06\x00\x06\x04mail\x06google\x03com\x00\x00\x01\x00\x01\xc0\x0c\x00\x05\x00\x01\x00\x00\x001\x00\x0f\ngooglemail\x01l\xc0\x11\xc0-\x00\x01\x00\x01\x00\x00\x01\x1e\x00\x04B\xf9S\x13\xc0-\x00\x01\x00\x01\x00\x00\x01\x1e\x00\x04B\xf9SS\xc08\x00\x02\x00\x01\x00\x01\x03\xee\x00\x04\x01e\xc08\xc08\x00\x02\x00\x01\x00\x01\x03\xee\x00\x04\x01g\xc08\xc08\x00\x02\x00\x01\x00\x01\x03\xee\x00\x04\x01a\xc08\xc08\x00\x02\x00\x01\x00\x01\x03\xee\x00\x04\x01b\xc08\xc08\x00\x02\x00\x01\x00\x01\x03\xee\x00\x04\x01c\xc08\xc08\x00\x02\x00\x01\x00\x01\x03\xee\x00\x04\x01d\xc08\xc0\x88\x00\x01\x00\x01\x00\x01=\xcd\x00\x04\xd8\xef5\t\xc0\x98\x00\x01\x00\x01\x00\x01=\xcd\x00\x04@\xe9\xb3\t\xc0\xa8\x00\x01\x00\x01\x00\x01=\xcd\x00\x04@\xe9\xa1\t\xc0\xb8\x00\x01\x00\x01\x00\x01=\xcd\x00\x04@\xe9\xb7\t\xc0h\x00\x01\x00\x01\x00\x01=\xcd\x00\x04Bf\x0b\t\xc0x\x00\x01\x00\x01\x00\x01=\xcd\x00\x04@\xe9\xa7\t'
Expand Down

0 comments on commit 63d7141

Please sign in to comment.