Code Monkey home page Code Monkey logo

shrink's Introduction

shrink

This is a crude, experimental HTTP web service around Straightjacket and Nashorn.

It exposes an /execute endpoint that you can POST to with any JavaScript code snippet you want. Shrink then runs the script in a Straightjacket sandbox, exposing any Java packages you choose to allow.

This is just a simple proof of concept and is not production ready. Letting other people run scripts on your server has obvious security implications, so only run this in friendly environments.

Running the Server

To start the server, just run the main method of com.andyhawkes.shrink.Server. The server will listen on http://localhost:4567.

Using the Shrink UI

Navigate to http://localhost:4567 in your browser. Fill in a snippet of JavaScript (which must declare at least one function). Then enter the name of the function you want to execute, up to 3 optional arguments, and a comma-separated list of Java classes or packages that should be exposed to the script's classloader. Submitting this will send a POST to Shrink's /execute endpoint.

Calling the Shrink Service Directly

You can also run scripts with your HTTP client of choice. For instance, curl:

$ curl -X POST --data '{"script":"function hello() { return \"hello\"; }","function":"hello","arguments":[],"exposedJavaClasses":[""]}' http://localhost:4567/execute

shrink's People

Contributors

azhawkes avatar

Watchers

 avatar  avatar

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.