Git Product home page Git Product logo

http-shell-executor's Introduction

HTTP Shell Executor

A simple server serving shell script. You can use it as a simple script based CI/CD server.

Usage

./http-shell-executor --help
./http-shell-executor --listen 0.0.0.0:8000

Serving

With the default configuration, static files are served from ./public/ and serving at / using GET method, and dynamic scripts are served from ./scripts/ and serving at / with POST method.

Static files are serving with Content-Type header which is detected by file extension. Dynamic scripts' headers are always Content-Type: text/event-stream; charset=utf-8.

Streaming support. If your script not finished, it would convert to a streaming mode.

Generated homepage not support. Please use static homepage + Fetch API.

Scripting

Script must start with shebang. You can also use an binary executable.

Example

example can be found in public/ and scripts/ dir.

Run

./http-shell-executor

You may like jq.

http-shell-executor's People

Contributors

ganlvtech avatar

Watchers

 avatar  avatar  avatar

http-shell-executor's Issues

absolutize_from not sanitize url contains %2E%2E

let clean_path = match PathBuf::from(&path).absolutize_from(&config.scripts_path) {

We can use Path::components to remove relative path.

https://github.com/tower-rs/tower-http/blob/053f5a5c939dde38cb93404b579854bc8f2fad88/tower-http/src/services/fs/serve_dir.rs#L136-L161

// https://github.com/tower-rs/tower-http/blob/053f5a5c939dde38cb93404b579854bc8f2fad88/tower-http/src/services/fs/serve_dir.rs#L136-L161
fn build_and_validate_path(base_path: &Path, requested_path: &str) -> anyhow::Result<PathBuf> {
    let path = requested_path.trim_start_matches('/');

    let path_decoded = urlencoding::decode(path)?.into_owned();
    let path_decoded = Path::new(&path_decoded);

    let mut full_path = base_path.to_path_buf();
    for component in path_decoded.components() {
        match component {
            Component::Normal(comp) => {
                // protect against paths like `/foo/c:/bar/baz` (#204)
                if Path::new(&comp)
                    .components()
                    .all(|c| matches!(c, Component::Normal(_)))
                {
                    full_path.push(comp)
                } else {
                    return Err(anyhow!("Bad path component"));
                }
            }
            Component::CurDir => {}
            Component::Prefix(_) | Component::RootDir | Component::ParentDir => return Err(anyhow!("RootDir and ParentDir is not allowed")),
        }
    }
    Ok(full_path)
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.