Skip to content

Commit 83ef454

Browse files
committed
Land rapid7#7829, workspace is now in a table
2 parents b86c1f0 + 360ad26 commit 83ef454

File tree

2 files changed

+36
-6
lines changed
  • lib/msf/ui/console/command_dispatcher
  • spec/lib/msf/ui/console/command_dispatcher

2 files changed

+36
-6
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,31 @@ def cmd_workspace(*args)
177177
return
178178
end
179179
else
180+
workspace = framework.db.workspace
181+
col_names = %w{current name hosts services vulns creds loots notes}
182+
183+
tbl = Rex::Text::Table.new(
184+
'Header' => 'Workspaces',
185+
'Columns' => col_names,
186+
'SortIndex' => 1
187+
)
188+
180189
# List workspaces
181-
framework.db.workspaces.each do |s|
182-
pad = (s.name == framework.db.workspace.name) ? "* " : " "
183-
print_line("#{pad}#{s.name}")
190+
framework.db.workspaces.each do |ws|
191+
tbl << [
192+
ws == workspace ? '*' : '',
193+
ws.name,
194+
ws.hosts.count,
195+
ws.services.count,
196+
ws.vulns.count,
197+
ws.core_credentials.count,
198+
ws.loots.count,
199+
ws.notes.count
200+
]
184201
end
202+
203+
print_line
204+
print_line(tbl.to_s)
185205
end
186206
}
187207
end

spec/lib/msf/ui/console/command_dispatcher/db_spec.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,12 @@
546546
it "should list default workspace" do
547547
db.cmd_workspace
548548
expect(@output).to match_array [
549-
"* default"
549+
"",
550+
"Workspaces",
551+
"==========",
552+
"current name hosts services vulns creds loots notes",
553+
"------- ---- ----- -------- ----- ----- ----- -----",
554+
"* default 0 0 0 0 0 0"
550555
]
551556
end
552557

@@ -555,8 +560,13 @@
555560
@output = []
556561
db.cmd_workspace
557562
expect(@output).to match_array [
558-
" default",
559-
"* foo"
563+
"",
564+
"Workspaces",
565+
"==========",
566+
"current name hosts services vulns creds loots notes",
567+
"------- ---- ----- -------- ----- ----- ----- -----",
568+
" default 0 0 0 0 0 0",
569+
"* foo 0 0 0 0 0 0"
560570
]
561571
end
562572
end

0 commit comments

Comments
 (0)