Skip to content
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

Added handling of —permit-arguments option #64

Merged
merged 1 commit into from
Oct 5, 2015

Conversation

QuentinPerez
Copy link
Contributor

Hi,
I do this PR to handle parameters with the permit-arguments flag.

Example:

$> gotty --permit-arguments vim

You can pass argument like this : http://server.exmple.com:8080/?params=file1&params=file2

@jcoste
Copy link

jcoste commented Sep 23, 2015

Hello,
I was working on a pull request with the same need. It would be nice to be able to pass multiple parameters instead of one like this : http://server.exmple.com:8080/?Params=options&Params=filename

In the code, you juste have to change :
params := query.Query().Get("Params")
by :
params := query.Query()["Params"]

and :
cmd := exec.Command(app.command[0], argv)
by :
cmd := exec.Command(app.command[0], argv...)

Hope this help.

@QuentinPerez
Copy link
Contributor Author

Thanks @jcoste

I added your code 😊

@moul
Copy link
Contributor

moul commented Sep 24, 2015

Fix #33

@moul
Copy link
Contributor

moul commented Sep 24, 2015

What do you think about renaming Params to params which is more _http_ish ?

@moul
Copy link
Contributor

moul commented Sep 24, 2015

👍

@aimxhaisse
Copy link

👌

@cerisier
Copy link

👍

@QuentinPerez QuentinPerez force-pushed the handle_arguments branch 2 times, most recently from 1d03804 to e3455ef Compare September 28, 2015 16:17
@yudai
Copy link
Owner

yudai commented Sep 30, 2015

Hi, thank you for the PR and sorry for the delay to reply.

I'm still not sure wether this approach is safe or not. If the given file to VIM is "/proc" or something, the command might leak secret information. To avoid security risks by restricting possible parameters, we may implement regular expression filters or white lists, but that makes gotty really complicated. So I'm feeling like when you need dynamic configuration of the gotty command, writing a custom wrapper script/application might be a better way like https://github.com/Arno0x/TermGate.

Could you present some actual use cases for which you need this feature?

@moul
Copy link
Contributor

moul commented Sep 30, 2015

This feature mimics the tty.js shellArgs argument which can be a list of predefined arguments or a hook function: https://github.com/chjj/tty.js/blob/master/lib/tty.js#L443-L445


Thanks to this dynamic shellArgs, we can host this service to give access to customer ttys with urls like:

tty.js executes a custom program we wrote which parses (and check) arguments


I don't understand how using TermGate would be more secure, is TermGate blacklisting /proc argument when the base program is vim ? :)

TermGate:

  • Cons:
    • removes the easiness of configuration we have in GoTTY
    • adds dependencies on PHP + a web server
    • manual webserver configuration
    • requires sudo
    • sets -w by default
    • forks 1 GoTTY instance per connection
  • Pros:
    • it handles arguments (as this PR)

In my opinion, giving access to vim/emacs/bash/tmux without argument is already a huge security risk

The GoTTY user needs to take care of the program he gives access to, and if he wants to allow parameters passing, he also needs to think about security issues it involves

A message in the README.md file about why is it risky to give access to the filesystem or shell execution would be great though

@yudai
Copy link
Owner

yudai commented Oct 1, 2015

@moul TermGate is just an example that shows you can implement arguments in a wrapper. If you want, you can implement some logic to filter arguments in your wrapper.

@jcoste
Copy link

jcoste commented Oct 1, 2015

Like @moul I find this PR very useful. The Gotty user is responsible of the program he gives acces to. And @QuentinPerez puts a flag to enable this mechanism! It's not enabled by default.

I don't want to develop a wrapper around Gotty like TermGate if this little PR can do the job.

@yudai
Copy link
Owner

yudai commented Oct 2, 2015

Thank you for the comments. Ok, I'm now thinking this option would be useful for many use cases.
However, I'm feeling like writing a lot of parameter= is a little bit bothering. Is there any better way to provide arguments in the URL?

@QuentinPerez
Copy link
Contributor Author

Hi @yudai,

I can propose you other ways, what do you think about:

?arg[]=AAA&arg[]=BBB&arg[]=CCC%20CCC
?args=[“AAA”,”BBB”,”CCC%20CCC”]

Or if you have another way, feel free to propose 😄

@yudai
Copy link
Owner

yudai commented Oct 5, 2015

hi @QuentinPerez, I checked some specs to find a standard way to send arrays in URL arguments, however it looks there is no formal way for it.
I think arg=AAA&arg=BBB&... (without []) is the best way. The name parameter sounds inconsistent with the parameter name permit-arguments.

@QuentinPerez QuentinPerez force-pushed the handle_arguments branch 2 times, most recently from 30efee2 to 15ba854 Compare October 5, 2015 06:40
@QuentinPerez
Copy link
Contributor Author

I updated the PR 😉

@yudai yudai force-pushed the master branch 2 times, most recently from f32f08a to 7715f93 Compare October 5, 2015 07:31
@yudai
Copy link
Owner

yudai commented Oct 5, 2015

Could you rebase to the master? There are some conflicts.

@QuentinPerez
Copy link
Contributor Author

Done

yudai added a commit that referenced this pull request Oct 5, 2015
Added handling of —permit-arguments option
@yudai yudai merged commit 6edf5b4 into yudai:master Oct 5, 2015
@yudai
Copy link
Owner

yudai commented Oct 5, 2015

Thanks! Merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants