summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranonym <anonym@riseup.net>2017-03-13 21:02:49 +0100
committeranonym <anonym@riseup.net>2017-03-13 21:02:49 +0100
commit97f1eee4eb43c63f6998694f6132515900051f1e (patch)
treebf4dc87d4af66b8b304e090517533dcf8ffc76f0
parent6797a6044933768cef81fc99976a6474ebe2b52f (diff)
Test suite: fixup on debugging info logging for PacketFu.
We still get "undefined method `ip_saddr' for nil:NilClass" because another instance of `ip_packet.ip_saddr` was forgotten and not dealt with. Refs: #11508
-rw-r--r--features/support/helpers/firewall_helper.rb16
1 files changed, 8 insertions, 8 deletions
diff --git a/features/support/helpers/firewall_helper.rb b/features/support/helpers/firewall_helper.rb
index 49e9853..25029a2 100644
--- a/features/support/helpers/firewall_helper.rb
+++ b/features/support/helpers/firewall_helper.rb
@@ -1,5 +1,10 @@
require 'packetfu'
+def looks_like_dhcp_packet?(protocol, sport, dport, ip_packet)
+ protocol == "udp" && sport == 68 && dport == 67 && ip_packet &&
+ ip_packet.ip_saddr == '0.0.0.0' && ip_packet.ip_daddr == "255.255.255.255"
+end
+
# Returns the unique edges (based on protocol, source/destination
# address/port) in the graph of all network flows.
def pcap_connections_helper(pcap_file, opts = {})
@@ -37,13 +42,8 @@ def pcap_connections_helper(pcap_file, opts = {})
raise "Found something that cannot be parsed"
end
- if protocol == "udp" and
- sport == 68 and
- dport == 67 and
- ip_packet.ip_saddr == '0.0.0.0' and
- ip_packet.ip_daddr == "255.255.255.255"
- next if opts[:ignore_dhcp]
- end
+ next if looks_like_dhcp_packet?(protocol, sport, dport, ip_packet) &&
+ opts[:ignore_dhcp]
packet_info = {
mac_saddr: eth_packet.eth_saddr,
@@ -53,7 +53,7 @@ def pcap_connections_helper(pcap_file, opts = {})
dport: dport,
}
# It seems *Packet.parse can return nil despite *Packet.can_parse?
- # returning true.
+ # returning true. (#11508)
if ip_packet
packet_info[:saddr] = ip_packet.ip_saddr
packet_info[:daddr] = ip_packet.ip_daddr