Skip to content

Commit 764a87f

Browse files
committed
nil check and fix mock
1 parent 1abaef4 commit 764a87f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/msf/core/module/alert.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,13 @@ def alert_user
270270
# Temporarily set the prompt mode to false to ensure that there are not additional lines printed
271271
# A workaround for the prompting bug spotted in https://github.com/rapid7/metasploit-framework/pull/18761#issuecomment-1916645095
272272
def without_prompt(&block)
273-
previous_prompting_value = user_output.prompting
274-
user_output.prompting(false)
273+
if user_output
274+
previous_prompting_value = user_output.prompting?
275+
user_output.prompting(false)
276+
end
277+
275278
yield
276279
ensure
277-
user_output.prompting(previous_prompting_value)
280+
user_output.prompting(previous_prompting_value) if user_output
278281
end
279282
end

spec/support/shared/contexts/msf/ui_driver.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
let(:driver_output) do
1414
instance = double(
1515
Rex::Ui::Text::Output,
16-
prompting?: false
16+
prompting?: false,
17+
prompting: false
1718
)
1819

1920
capture_logging(instance)

0 commit comments

Comments
 (0)