Skip to content

Commit 2368569

Browse files
committed
The tags column should be a virtual column
1 parent 1820187 commit 2368569

File tree

1 file changed

+7
-7
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+7
-7
lines changed

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ def cmd_hosts(*args)
326326
output = nil
327327
default_columns = ::Mdm::Host.column_names.sort
328328
default_columns << 'tags' # Special case
329-
virtual_columns = [ 'svcs', 'vulns', 'workspace' ]
329+
virtual_columns = [ 'svcs', 'vulns', 'workspace', 'tags' ]
330330

331-
col_search = [ 'address', 'mac', 'name', 'os_name', 'os_flavor', 'os_sp', 'purpose', 'info', 'comments', 'tags']
331+
col_search = [ 'address', 'mac', 'name', 'os_name', 'os_flavor', 'os_sp', 'purpose', 'info', 'comments']
332332

333333
default_columns.delete_if {|v| (v[-2,2] == "id")}
334334
while (arg = args.shift)
@@ -469,13 +469,13 @@ def cmd_hosts(*args)
469469
when "svcs"; host.services.length
470470
when "vulns"; host.vulns.length
471471
when "workspace"; host.workspace.name
472+
when "tags"
473+
found_tags = Mdm::Tag.includes(:hosts).where("hosts.workspace_id = ? and hosts.address = ?", framework.db.workspace.id, host.address).order("tags.id DESC")
474+
tag_names = []
475+
found_tags.each {|t| tag_names << t.name}
476+
found_tags * ", "
472477
end
473478
# Otherwise, it's just an attribute
474-
elsif n == 'tags'
475-
found_tags = Mdm::Tag.includes(:hosts).where("hosts.workspace_id = ? and hosts.address = ?", framework.db.workspace.id, host.address).order("tags.id DESC")
476-
tag_names = []
477-
found_tags.each {|t| tag_names << t.name}
478-
found_tags * ", "
479479
else
480480
host.attributes[n] || ""
481481
end

0 commit comments

Comments
 (0)