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
Support CTRL + Z for interactive SQL REPL #18773
Support CTRL + Z for interactive SQL REPL #18773
Conversation
Thanks. |
def _fallback | ||
stop_words = %w[stop s exit e end quit q].freeze | ||
line_buffer = [] | ||
while (line = ::Readline.readline(prompt = line_buffer.empty? ? 'SQL >> ' : 'SQL *> ', add_history = true)) |
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.
Just a reminder for the future to use our history manager to ensure it's stored in a context-specific manner.
lib/rex/ui/text/input/readline.rb
Outdated
finished = false | ||
begin | ||
prompt_proc_before = ::Reline.prompt_proc | ||
::Reline.prompt_proc = proc { |line_buffer| line_buffer.each_with_index.map { |_line, i| i > 0 ? 'SQL *> ' : 'SQL >> ' } } |
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.
lib/rex/ui/text/input/readline
is meant to be a reusable module shared by multiple modules, and used in multiple contexts. I don't think it makes sense to have any of this SQL-specific logic here - as it stops the method from be used in any other scenario other than SQL prompts 👀
f114670
to
4039ae1
Compare
finished || multiline_input.split.last&.end_with?(';') | ||
end | ||
rescue ::StandardError => e | ||
elog('Failed to get multi-line SQL query from user', e) |
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.
Not a blocker; this error handling might happen a bit too transparently for the average user 🤔
Release NotesFixes an issue were |
This PR ensures that you can correctly CTRL + Z and CTRL + C out of an interactive REPL shell inside the PostgreSQL session type.
Verification
List the steps needed to make sure this thing works
msfconsole
postgres_login
sessions -i -1
shell