Permalink
Browse files

bug fix

  • Loading branch information...
1 parent b0e3c29 commit 9efb9f68561adf0315cfaf065fc3e9883ae317bb @oguzy committed Aug 13, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 ovizart/api/serializer.py
View
@@ -21,6 +21,8 @@ def to_json(self, data, options=None):
if flow['protocol'] == "http":
# get the start and end time for this flow
start, end = self.get_start_end(flow)
+ if not start:
+ continue
type, description = self.get_http_info(flow)
tmp = dict()
tmp['flow_id'] = flow['id']
@@ -36,6 +38,8 @@ def to_json(self, data, options=None):
if flow['protocol'] == "dns":
start, end = self.get_start_end(flow)
+ if not start:
+ continue
type, description = self.get_dns_info(flow)
tmp = dict()
tmp['flow_id'] = flow['id']
@@ -51,6 +55,8 @@ def to_json(self, data, options=None):
if flow['protocol'] == "smtp":
start, end = self.get_start_end(flow)
+ if not start:
+ continue
type, description = self.get_smtp_info(flow)
tmp = dict()
tmp['flow_id'] = flow['id']
@@ -66,6 +72,8 @@ def to_json(self, data, options=None):
if flow['protocol'] == "unknown":
start, end = self.get_start_end(flow)
+ if not start:
+ continue
type, description = "unknown", ""
tmp = dict()
tmp['flow_id'] = flow['id']
@@ -95,7 +103,10 @@ def from_json(self, content):
# TODO: for udp, packet details are not saved
def get_start_end(self, flow):
packets = PacketDetails.objects.filter(src_ip=flow['src_ip'], sport=flow['sport'], dst_ip=flow['dst_ip'], dport=flow['dport']).order_by('timestamp')
- return packets[0].timestamp, packets[len(packets)-1].timestamp
+ if packets:
+ return packets[0].timestamp, packets[len(packets)-1].timestamp
+ else:
+ return False, False
def get_http_info(self, flow):

0 comments on commit 9efb9f6

Please sign in to comment.