-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditionally recalculate in ModuleSet #16368
Conditionally recalculate in ModuleSet #16368
Conversation
Recalculations are time consuming, so only do it if necessary.
28d3a5c
to
df04435
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me calling recalculate
only if there is a possibility something is missing is a nice optimization!
Also verified this works with ./tools/automation/cache/update_module_cache.sh
when automation needs to build the cache from scratch.
Improvement verified:
Post merge:
|
Release notesThis improves response time when a cache miss occurs for commands not provided by |
@@ -154,6 +154,7 @@ def load_and_create_module(options={}) | |||
) | |||
|
|||
module_set = module_set_for_type(module_type) | |||
module_set.recalculate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there's a way of performing this action once at a higher level within the test setup? Otherwise, if I understand correctly, we'll be adding an extra 1-2 seconds per payload test which calls load_and_create_module
? 👀
This updates the
Msf::ModuleSet#create
method to skip callingrecalculate
when nothing was loaded from the module cache and the module set is populated. If nothing was loaded, then it doesn't seem necessary to perform a recalculation. Recalculating payloads is computationally expensive and thus time consuming. Since this code is executed when an unknown command is run frommsfconsole
, recalculating the payloads slows down the response. This leads to an unpleasant user experience. When a module was loaded however it makes sense to perform the recalculation. The call toload_cached_module
will return false when the referenced name does not exist and nothing was loaded.This regression was introduced in #16186 because of the additional loop required by the adapters.
Verification
List the steps needed to make sure this thing works
msfconsole
repeat -n 3 time missing_command
Example Output
Before the patch
After the patch