Skip to content

Commit 66b453e

Browse files
author
Brent Cook
committed
ensure the database cache is always updated, present accurate reporting on search
1 parent 0cc6b53 commit 66b453e

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

lib/msf/core/module_manager/cache.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def refresh_cache_from_module_files(module_class_or_instance = nil)
112112
else
113113
framework.db.update_all_module_details
114114
end
115-
116115
refresh_cache_from_database(self.module_paths)
117116
end
118117
end
@@ -131,11 +130,7 @@ def refresh_cache_from_database(allowed_paths=[""])
131130
# @return [true] if migrations have been run
132131
# @return [false] otherwise
133132
def framework_migrated?
134-
if framework.db and framework.db.migrated
135-
true
136-
else
137-
false
138-
end
133+
framework.db && framework.db.migrated
139134
end
140135

141136
# @!attribute [rw] module_info_by_path

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,13 +1543,17 @@ def cmd_search(*args)
15431543
end
15441544
}
15451545

1546-
if framework.db and framework.db.migrated and framework.db.modules_cached
1547-
search_modules_sql(match)
1548-
return
1546+
if framework.db
1547+
if framework.db.migrated && framework.db.modules_cached
1548+
search_modules_sql(match)
1549+
return
1550+
else
1551+
print_warning("Module database cache not built yet, using slow search")
1552+
end
1553+
else
1554+
print_warning("Database not connected, using slow search")
15491555
end
15501556

1551-
print_warning("Database not connected or cache not built, using slow search")
1552-
15531557
tbl = generate_module_table("Matching Modules")
15541558
[
15551559
framework.exploits,

lib/msf/ui/console/driver.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,8 @@ def initialize(prompt = DefaultPrompt, prompt_char = DefaultPromptChar, opts = {
213213
end
214214

215215
if framework.db.active && !opts['DeferModuleLoads']
216-
if self.framework.modules.cache_empty?
217-
self.framework.threads.spawn("ModuleCacheRebuild", true) do
218-
self.framework.modules.refresh_cache_from_module_files
219-
end
220-
print_status("The initial module cache will be built in the background, this can take 2-5 minutes...")
216+
framework.threads.spawn("ModuleCacheRebuild", true) do
217+
framework.modules.refresh_cache_from_module_files
221218
end
222219
end
223220

0 commit comments

Comments
 (0)