command-as-a-service

command module
v0.0.0-...-7a0fbb4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2019 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

command-as-a-service

It does...

command-as-a-service executes the command with options specified in the url, with STDIN from HTTP request body, and returns STDOUT in HTTP response body.

It does not...

  • authenticate request
  • limit rate

future work

see GitHub project : https://github.com/hrkt/command-as-a-service/projects

How to run

  1. edit app-settings.json

see: "app-settings.json" paragraph in this README.

  1. execute server.
$ make run
  1. make HTTP POST request
$ curl "http://localhost:8080/bin/date"
2019年 7月27日 土曜日 15時27分43秒 JST

Please point the command you want to execcute with url-path same as filesystem-path.

i.e.

URL                                Executed
http://localhost:8080/bin/date ==> /bin/date

Options for the command are given by query parameter.

i.e.

URL                                Executed
http://localhost:8080/usr/bin/sort?-rn ==> /bin/sort -rn

Standard input for the command can be passed throw Request body.

i.e.

URL
$ curl "http://localhost:8080/usr/bin/sort?-r&-n" --data-binary @testdata/test.txt 

prerequisites

  • dep as dependency manager
  • linux, *nix like platforms - ("endless" shows error message on windows platform, at this point of moment)

app-settings.json

specify "whitelist", "port". enable "dangerousMode"(that does not use whitelist. In other worrds, you can execute 'rm -rf ' via http request), if it is needed.

{
    "dangerousMode": false,
    "port": 8080,
    "whitelist": [
        "/bin/date",
        "/bin/echo",
        "/bin/hostname",
        "/bin/sleep",
        :
        :
    ]
}

usage

run in dev mode

$ make run

run in release mode

$ make release-run

build

$ make run

test

$ make test

format

$ make fmt

build container

$ make build-container

run container

$ make run-container

License

MIT

CI

CircleCI

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址