-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add System.shell/2 #10965
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
Add System.shell/2 #10965
Conversation
lib/elixir/lib/system.ex
Outdated
| **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, |
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.
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.
lib/elixir/lib/system.ex
Outdated
| end | ||
|
|
||
| @doc ~S""" | ||
| Executes the given `command` in the current OS shell. |
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.
| 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
| """ | ||
| @spec shell(binary, keyword) :: {Collectable.t(), exit_status :: non_neg_integer} |
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.
| """ | |
| @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} |
lib/elixir/lib/system.ex
Outdated
| 'sh -c "' ++ command ++ '"' | ||
|
|
||
| {:win32, osname} -> | ||
| command = '"' ++ String.to_charlist(command) ++ '"' |
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.
no escaping on windows?
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.
According to the OTP source, no, but we shouldn't be quoting either. So I will update. Thanks! :)
|
💚 💙 💜 💛 ❤️ |
No description provided.