ensure the database cache is always updated, present accurate reporting on search

bug/bundler_fix
Brent Cook 2015-09-22 12:56:26 -05:00
parent 0cc6b53d59
commit 66b453edd6
3 changed files with 12 additions and 16 deletions

View File

@ -112,7 +112,6 @@ module Msf::ModuleManager::Cache
else else
framework.db.update_all_module_details framework.db.update_all_module_details
end end
refresh_cache_from_database(self.module_paths) refresh_cache_from_database(self.module_paths)
end end
end end
@ -131,11 +130,7 @@ module Msf::ModuleManager::Cache
# @return [true] if migrations have been run # @return [true] if migrations have been run
# @return [false] otherwise # @return [false] otherwise
def framework_migrated? def framework_migrated?
if framework.db and framework.db.migrated framework.db && framework.db.migrated
true
else
false
end
end end
# @!attribute [rw] module_info_by_path # @!attribute [rw] module_info_by_path

View File

@ -1543,13 +1543,17 @@ class Core
end end
} }
if framework.db and framework.db.migrated and framework.db.modules_cached if framework.db
search_modules_sql(match) if framework.db.migrated && framework.db.modules_cached
return search_modules_sql(match)
return
else
print_warning("Module database cache not built yet, using slow search")
end
else
print_warning("Database not connected, using slow search")
end end
print_warning("Database not connected or cache not built, using slow search")
tbl = generate_module_table("Matching Modules") tbl = generate_module_table("Matching Modules")
[ [
framework.exploits, framework.exploits,

View File

@ -213,11 +213,8 @@ class Driver < Msf::Ui::Driver
end end
if framework.db.active && !opts['DeferModuleLoads'] if framework.db.active && !opts['DeferModuleLoads']
if self.framework.modules.cache_empty? framework.threads.spawn("ModuleCacheRebuild", true) do
self.framework.threads.spawn("ModuleCacheRebuild", true) do framework.modules.refresh_cache_from_module_files
self.framework.modules.refresh_cache_from_module_files
end
print_status("The initial module cache will be built in the background, this can take 2-5 minutes...")
end end
end end