{"action":"created","issue":{"url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/5859","labels_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/5859/labels{/name}","comments_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/5859/comments","events_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/5859/events","html_url":"https://github.com/rapid7/metasploit-framework/pull/5859","id":101500011,"number":5859,"title":"Fix #5817 by allow to compare ipv4 vs ipv6 addresses on tables","user":{"login":"jvazquez-r7","id":1742838,"avatar_url":"https://avatars.githubusercontent.com/u/1742838?v=3","gravatar_id":"","url":"https://api.github.com/users/jvazquez-r7","html_url":"https://github.com/jvazquez-r7","followers_url":"https://api.github.com/users/jvazquez-r7/followers","following_url":"https://api.github.com/users/jvazquez-r7/following{/other_user}","gists_url":"https://api.github.com/users/jvazquez-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/jvazquez-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvazquez-r7/subscriptions","organizations_url":"https://api.github.com/users/jvazquez-r7/orgs","repos_url":"https://api.github.com/users/jvazquez-r7/repos","events_url":"https://api.github.com/users/jvazquez-r7/events{/privacy}","received_events_url":"https://api.github.com/users/jvazquez-r7/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rapid7/metasploit-framework/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/rapid7/metasploit-framework/labels/library","name":"library","color":"fad8c7"}],"state":"open","locked":false,"assignee":{"login":"bcook-r7","id":10031469,"avatar_url":"https://avatars.githubusercontent.com/u/10031469?v=3","gravatar_id":"","url":"https://api.github.com/users/bcook-r7","html_url":"https://github.com/bcook-r7","followers_url":"https://api.github.com/users/bcook-r7/followers","following_url":"https://api.github.com/users/bcook-r7/following{/other_user}","gists_url":"https://api.github.com/users/bcook-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/bcook-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcook-r7/subscriptions","organizations_url":"https://api.github.com/users/bcook-r7/orgs","repos_url":"https://api.github.com/users/bcook-r7/repos","events_url":"https://api.github.com/users/bcook-r7/events{/privacy}","received_events_url":"https://api.github.com/users/bcook-r7/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-08-17T20:09:22Z","updated_at":"2015-08-19T16:51:27Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rapid7/metasploit-framework/pulls/5859","html_url":"https://github.com/rapid7/metasploit-framework/pull/5859","diff_url":"https://github.com/rapid7/metasploit-framework/pull/5859.diff","patch_url":"https://github.com/rapid7/metasploit-framework/pull/5859.patch"},"body":"After review the backtrace provided on https://github.com/rapid7/metasploit-framework/issues/5817 I was reviewing the `Rex::Ui::Text::Table#sort_rows` method. Since we haven't data to test the exception provided by  #5817 my first bet is which the problem could be due to IPv4 vs IPv6 addresses, since in this case the `<=>` operator will return nil.\r\n\r\nIn order to reproduce (from master) the next steps can be followed:\r\n\r\n```\r\nmsf > workspace test_hosts\r\n[*] Workspace: test_hosts\r\nmsf > hosts\r\n\r\nHosts\r\n=====\r\n\r\naddress  mac  name  os_name  os_flavor  os_sp  purpose  info  comments\r\n-------  ---  ----  -------  ---------  -----  -------  ----  --------\r\n\r\nmsf > hosts -a 2a01:0111:f406:0402:0000:0000:0000:0014\r\n[*] Time: 2015-08-17 19:59:46 UTC Host: host=2a01:111:f406:402::14\r\nmsf > hosts\r\n\r\nHosts\r\n=====\r\n\r\naddress                mac  name  os_name  os_flavor  os_sp  purpose  info  comments\r\n-------                ---  ----  -------  ---------  -----  -------  ----  --------\r\n2a01:111:f406:402::14\r\n\r\nmsf > hosts -a 172.16.158.1\r\n[*] Time: 2015-08-17 19:59:56 UTC Host: host=172.16.158.1\r\nmsf > hosts\r\n\r\n[-] Error while running command hosts: comparison of Array with Array failed\r\n\r\nCall stack:\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/rex/ui/text/table.rb:197:in `sort!'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/rex/ui/text/table.rb:197:in `sort_rows'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/rex/ui/text/table.rb:112:in `to_s'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:499:in `block in cmd_hosts'\r\n/Users/jvazquez/.rvm/gems/ruby-2.1.6@metasploit-framework/gems/activerecord-4.0.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:294:in `with_connection'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/msf/ui/console/command_dispatcher/db.rb:312:in `cmd_hosts'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:427:in `run_command'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:389:in `block in run_single'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:383:in `each'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:383:in `run_single'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/rex/ui/text/shell.rb:203:in `run'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'\r\n/Users/jvazquez/Projects/Code/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'\r\n./msfconsole:48:in `<main>'\r\n```\r\n\r\nAssuming it is the exception triggered #5817 the patch here tries to manage ipv4 vs ipv6 comparisions on `Rex::Ui::Text::Table`.\r\n\r\nVerification\r\n------------\r\n\r\n- [ ] Create a new workspace\r\n\r\n```\r\nmsf > workspace -a test_hosts\r\n[*] Added workspace: test_hosts\r\n\r\n```\r\n\r\n- [ ] Add an ipv4 host\r\n\r\n```\r\nmsf > hosts -a 172.16.158.1\r\n[*] Time: 2015-08-17 20:02:06 UTC Host: host=172.16.158.1\r\n\r\n```\r\n\r\n- [ ] Add an ipv6 host\r\n\r\n```\r\nmsf > hosts -a 2a01:0111:f406:0402:0000:0000:0000:0014\r\n[*] Time: 2015-08-17 20:02:13 UTC Host: host=2a01:111:f406:402::14\r\n```\r\n\r\n- [ ] Run the `hosts` command. VERIFY: no exception is raised and hosts with ipv4 addresses are showed before the hosts with ipv6 addresses.\r\n\r\n```\r\nmsf > hosts\r\n\r\nHosts\r\n=====\r\n\r\naddress                mac  name  os_name  os_flavor  os_sp  purpose  info  comments\r\n-------                ---  ----  -------  ---------  -----  -------  ----  --------\r\n172.16.158.1\r\n2a01:111:f406:402::14\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/comments/132692493","html_url":"https://github.com/rapid7/metasploit-framework/pull/5859#issuecomment-132692493","issue_url":"https://api.github.com/repos/rapid7/metasploit-framework/issues/5859","id":132692493,"user":{"login":"bcook-r7","id":10031469,"avatar_url":"https://avatars.githubusercontent.com/u/10031469?v=3","gravatar_id":"","url":"https://api.github.com/users/bcook-r7","html_url":"https://github.com/bcook-r7","followers_url":"https://api.github.com/users/bcook-r7/followers","following_url":"https://api.github.com/users/bcook-r7/following{/other_user}","gists_url":"https://api.github.com/users/bcook-r7/gists{/gist_id}","starred_url":"https://api.github.com/users/bcook-r7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcook-r7/subscriptions","organizations_url":"https://api.github.com/users/bcook-r7/orgs","repos_url":"https://api.github.com/users/bcook-r7/repos","events_url":"https://api.github.com/users/bcook-r7/events{/privacy}","received_events_url":"https://api.github.com/users/bcook-r7/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T16:51:27Z","updated_at":"2015-08-19T16:51:27Z","body":"LGTM, thanks @jvazquez-r7 \r\n```\r\naddress  mac  name  os_name  os_flavor  os_sp  purpose  info  comments\r\n-------  ---  ----  -------  ---------  -----  -------  ----  --------\r\n1.2.2.4\r\n1.2.3.4\r\n1::1234\r\n1::1235\r\n```"}}