Skip to content

Commit 6de986b

Browse files
committed
Fix cache invalidation bug in tab completion
We use active_module instead of cmd_use to invalidate @cache_payloads, since the ivar is no longer shared between cmd_set and cmd_use. Fixes rapid7#8483. See rapid7#7655.
1 parent e0fee9e commit 6de986b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,8 @@ def commands
139139
def initialize(driver)
140140
super
141141

142-
@dscache = {}
143142
@cache_payloads = nil
144143
@previous_module = nil
145-
@module_name_stack = []
146144
@history_limit = 100
147145
end
148146

@@ -2288,7 +2286,11 @@ def option_values_dispatch(o, str, words)
22882286
# Provide valid payload options for the current exploit
22892287
#
22902288
def option_values_payloads
2291-
return @cache_payloads if @cache_payloads
2289+
if @cache_payloads && active_module == @previous_module
2290+
return @cache_payloads
2291+
else
2292+
@previous_module = active_module
2293+
end
22922294

22932295
@cache_payloads = active_module.compatible_payloads.map { |refname, payload|
22942296
refname

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def initialize(driver)
4848
super
4949

5050
@dscache = {}
51-
@cache_payloads = nil
5251
@previous_module = nil
5352
@module_name_stack = []
5453
@dangerzone_map = nil
@@ -645,7 +644,6 @@ def cmd_use(*args)
645644
active_module.datastore.update(@dscache[active_module.fullname])
646645
end
647646

648-
@cache_payloads = nil
649647
mod.init_ui(driver.input, driver.output)
650648

651649
# Update the command prompt

0 commit comments

Comments
 (0)