Skip to content

Commit dc7a8d3

Browse files
committed
Land rapid7#3324, msfconsole search timestamp fixes
2 parents 9fbda3e + bb6201d commit dc7a8d3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class Core
9797
# mode.
9898
DefangedProhibitedDataStoreElements = [ "MsfModulePaths" ]
9999

100+
# Constant for disclosure date formatting in search functions
101+
DISCLOSURE_DATE_FORMAT = "%Y-%m-%d"
100102
# Returns the list of commands supported by this command dispatcher
101103
def commands
102104
{
@@ -1477,7 +1479,7 @@ def cmd_search(*args)
14771479
next if not o
14781480

14791481
if not o.search_filter(match)
1480-
tbl << [ o.fullname, o.disclosure_date.to_s, o.rank_to_s, o.name ]
1482+
tbl << [ o.fullname, o.disclosure_date.nil? ? "" : o.disclosure_date.strftime(DISCLOSURE_DATE_FORMAT), o.rank_to_s, o.name ]
14811483
end
14821484
end
14831485
end
@@ -1492,7 +1494,7 @@ def cmd_search(*args)
14921494
def search_modules_sql(search_string)
14931495
tbl = generate_module_table("Matching Modules")
14941496
framework.db.search_modules(search_string).each do |o|
1495-
tbl << [ o.fullname, o.disclosure_date.to_s, RankingName[o.rank].to_s, o.name ]
1497+
tbl << [ o.fullname, o.disclosure_date.nil? ? "" : o.disclosure_date.strftime(DISCLOSURE_DATE_FORMAT), RankingName[o.rank].to_s, o.name ]
14961498
end
14971499
print_line(tbl.to_s)
14981500
end
@@ -3270,7 +3272,7 @@ def show_module_set(type, module_set, regex = nil, minrank = nil, opts = nil) #
32703272
end
32713273
end
32723274
if (opts == nil or show == true)
3273-
tbl << [ refname, o.disclosure_date||"", o.rank_to_s, o.name ]
3275+
tbl << [ refname, o.disclosure_date.nil? ? "" : o.disclosure_date.strftime(DISCLOSURE_DATE_FORMAT), o.rank_to_s, o.name ]
32743276
end
32753277
end
32763278
end

spec/lib/msf/ui/command_dispatcher/core_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def cell(table, row, column)
8282
end
8383

8484
it 'should have disclosure date in second column' do
85-
cell(printed_table, 0, 1).should include(module_detail.disclosure_date.to_s)
85+
cell(printed_table, 0, 1).should include(module_detail.disclosure_date.strftime("%Y-%m-%d"))
8686
end
8787

8888
it 'should have rank name in third column' do

0 commit comments

Comments
 (0)