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

Normalize newlines in CommandShell#run_single #11309

Merged
merged 2 commits into from Feb 1, 2019

Conversation

Projects
None yet
4 participants
@wvu-r7
Copy link
Contributor

wvu-r7 commented Jan 24, 2019

Lines from normal interaction will include a trailing newline, while lines from resource scripting will not.

resource (test.rc)> whoami
[*] Received: "whoami"
[*] Sent:     "whoami\n"

wvu
whoami
[*] Received: "whoami\n"
[*] Sent:     "whoami\n\n"
wvu
resource (test.rc)> whoami
[*] Received: "whoami"
[*] Sent:     "whoami\n"

wvu
whoami
[*] Received: "whoami\n"
[*] Sent:     "whoami\n"
wvu

Functionally, behavior should not change with this patch except in special cases such as here documents.

cat <<EOF
[*] Received: "cat <<EOF\n"
[*] Sent:     "cat <<EOF\n\n"
hello,
[*] Received: "hello,\n"
[*] Sent:     "hello,\n\n"
world
[*] Received: "world\n"
[*] Sent:     "world\n\n"
EOF
[*] Received: "EOF\n"
[*] Sent:     "EOF\n\n"

hello,

world

cat <<EOF
[*] Received: "cat <<EOF\n"
[*] Sent:     "cat <<EOF\n"
hello,
[*] Received: "hello,\n"
[*] Sent:     "hello,\n"
world
[*] Received: "world\n"
[*] Sent:     "world\n"
EOF
[*] Received: "EOF\n"
[*] Sent:     "EOF\n"
hello,
world

Updates #11271.

Normalize newlines in CommandShell#run_single
Lines from normal interaction will include a trailing newline, while
lines from resource scripting will not.

@wvu-r7 wvu-r7 requested a review from acammack-r7 Jan 24, 2019

@wchen-r7 wchen-r7 self-assigned this Jan 28, 2019

Chomp user input alone
[1] pry(main)> "\r\n".chomp("\n")
=> ""
[2] pry(main)>

Meh.

@wchen-r7 wchen-r7 merged commit 92e846d into rapid7:master Feb 1, 2019

3 checks passed

Metasploit Automation - Sanity Test Execution Successfully completed all tests.
Details
Metasploit Automation - Test Execution Successfully completed all tests.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

wchen-r7 added a commit that referenced this pull request Feb 1, 2019

@wchen-r7

This comment has been minimized.

Copy link
Contributor

wchen-r7 commented Feb 1, 2019

Release Notes

This fix normalizes newlines in CommandShell#run_single.

msjenkins-r7 added a commit that referenced this pull request Feb 1, 2019

@wvu-r7 wvu-r7 deleted the wvu-r7:bug/resource branch Feb 1, 2019

@gdavidson-r7 gdavidson-r7 added the rn-fix label Feb 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment