File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed
lib/msf/ui/console/command_dispatcher
spec/lib/msf/ui/console/command_dispatcher Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,7 @@ def active?
86
86
def cmd_workspace_help
87
87
print_line "Usage:"
88
88
print_line " workspace List workspaces"
89
+ print_line " workspace -v List workspaces verbosely"
89
90
print_line " workspace [name] Switch workspace"
90
91
print_line " workspace -a [name] ... Add workspace(s)"
91
92
print_line " workspace -d [name] ... Delete workspace(s)"
@@ -111,6 +112,8 @@ def cmd_workspace(*args)
111
112
delete_all = true
112
113
when '-r' , '--rename'
113
114
renaming = true
115
+ when '-v'
116
+ verbose = true
114
117
else
115
118
names ||= [ ]
116
119
names << arg
@@ -178,12 +181,21 @@ def cmd_workspace(*args)
178
181
end
179
182
else
180
183
workspace = framework . db . workspace
184
+
185
+ unless verbose
186
+ framework . db . workspaces . each do |ws |
187
+ pad = ( ws == workspace ) ? '* ' : ' '
188
+ print_line ( "#{ pad } #{ ws . name } " )
189
+ end
190
+ return
191
+ end
192
+
181
193
col_names = %w{ current name hosts services vulns creds loots notes }
182
194
183
195
tbl = Rex ::Text ::Table . new (
184
196
'Header' => 'Workspaces' ,
185
197
'Columns' => col_names ,
186
- 'SortIndex' => 1
198
+ 'SortIndex' => - 1
187
199
)
188
200
189
201
# List workspaces
Original file line number Diff line number Diff line change 542
542
db . cmd_workspace "-D"
543
543
@output = [ ]
544
544
end
545
+
545
546
describe "<no arguments>" do
546
547
it "should list default workspace" do
547
548
db . cmd_workspace
549
+ expect ( @output ) . to match_array [
550
+ "* default"
551
+ ]
552
+ end
553
+
554
+ it "should list all workspaces" do
555
+ db . cmd_workspace ( "-a" , "foo" )
556
+ @output = [ ]
557
+ db . cmd_workspace
558
+ expect ( @output ) . to match_array [
559
+ " default" ,
560
+ "* foo"
561
+ ]
562
+ end
563
+ end
564
+
565
+ describe "-v" do
566
+ it "should list default workspace verbosely" do
567
+ db . cmd_workspace ( "-v" )
548
568
expect ( @output ) . to match_array [
549
569
"" ,
550
570
"Workspaces" ,
555
575
]
556
576
end
557
577
558
- it "should list all workspaces" do
578
+ it "should list all workspaces verbosely " do
559
579
db . cmd_workspace ( "-a" , "foo" )
560
580
@output = [ ]
561
- db . cmd_workspace
581
+ db . cmd_workspace ( "-v" )
562
582
expect ( @output ) . to match_array [
563
583
"" ,
564
584
"Workspaces" ,
613
633
expect ( @output ) . to match_array [
614
634
"Usage:" ,
615
635
" workspace List workspaces" ,
636
+ " workspace -v List workspaces verbosely" ,
616
637
" workspace [name] Switch workspace" ,
617
638
" workspace -a [name] ... Add workspace(s)" ,
618
639
" workspace -d [name] ... Delete workspace(s)" ,
You can’t perform that action at this time.
0 commit comments