Skip to content

Conversation

@josevalim
Copy link
Member

No description provided.

**Important**: Use this function with care. In particular, **never
pass user input to this function**, as the user would be able to
execute any code directly on the machine. Generally speaking,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to mention that this is a "command injection" vulnerability, so the reader has a keyword to search for and better understand the implications.

end

@doc ~S"""
Executes the given `command` in the current OS shell.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Executes the given `command` in the current OS shell.
Executes the given `command` in the OS shell.

"current" makes me think that it will read the "SHELL" env var or something similar

Comment on lines +902 to +903
"""
@spec shell(binary, keyword) :: {Collectable.t(), exit_status :: non_neg_integer}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""
@spec shell(binary, keyword) :: {Collectable.t(), exit_status :: non_neg_integer}
"""
@doc since: "1.13.0"
@spec shell(binary, keyword) :: {Collectable.t(), exit_status :: non_neg_integer}

'sh -c "' ++ command ++ '"'

{:win32, osname} ->
command = '"' ++ String.to_charlist(command) ++ '"'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no escaping on windows?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the OTP source, no, but we shouldn't be quoting either. So I will update. Thanks! :)

@josevalim josevalim merged commit 2a8aa3c into master May 5, 2021
@josevalim josevalim deleted the jv-system-shell branch May 5, 2021 19:04
@josevalim
Copy link
Member Author

💚 💙 💜 💛 ❤️

josevalim added a commit that referenced this pull request May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants