/svcizer

Recklessly turns a shell command into an HTTP endpoint

Primary LanguageRubyMIT LicenseMIT

svcizer

Recklessly turns a shell command into a plain HTTP endpoint. There is no security.

Usage

svcize <cmd> <args>

Now you have an HTTP server running on port 8080, which you can hit with GET requests.

  • The request body will be passed to stdin.

  • STDOUT and STDERR from cmd will be dumped to the response body.

  • If the command returns 0, the server will return 200 OK. If the command returns non-zero, the server will return 503 Internal Server Error.

  • If you really care, the actual exit code is stuffed into the Exit-Status header.

  • HTTP headers and query parameters will be passed as environment variables. Yes, this means you can overwrite $PATH. Do it if you want. There is no security.

  • Any environment variable can be substituted into an argument by using %var%:

    `svcize ls %p%`
    

    Now we can pass in an argument with the p query parameter:

    $ curl "http://localhost:8080?p=."
    Gemfile
    Gemfile.lock
    LICENSE
    README.md
    svcize
    

That's it. The end.

Potential FAQ

"Security?"

There is no security.

"Cookies?"

Delicious. But no.

"What about...?"

You probably can't. This is a super basic tool for building the most micro of web services.

"How do I perform maximum evil?"

svcize bash -c %cmd%