Git Product home page Git Product logo

gosafe's Introduction

gosafe

A Go tool to safely compile and run Go programs by only allowing importing of whitelisted packages.

Caveats

If you are not careful, running in parallell might let the child processes execute arbitrary code: zond#1

Why

To enable running any piece of Go code (even if it comes from unknown sources) with ease and safety.

How

Use Compiler.Allow to allow given packages, then run code with Compiler.Run or Compiler.RunFile.

See https://github.com/zond/gosafe/blob/master/examples/example.go

Communicating with child processes

Use child.Stdin(), child.Stdout() and child.Stderr() in https://github.com/zond/gosafe/blob/master/child/child.go to communicate with the child processes via structured data.

On demand child processes

Use gosafe.Compiler#Command, gosafe.Compiler#CommandFile and gosafe.Cmd#Handle to create child process handlers that will stay dormant until needed (when gosafe.Cmd#Handle is called), and die again after a customizable timeout without new messages.

See https://github.com/zond/gosafe/tree/master/examples/spinner for an example.

On demand child processes with transparent method calling and callbacks to the mother process

Use child.NewServer, child.Server#Register and child.Server#Start to create child processes serving many different types of calls from the parent process.

Then use gosafe.Cmd#Register to register callbacks that the child processes can use to access data outside their runtime (such as private persistence providers for example) before responding with their final return value.

See https://github.com/zond/gosafe/blob/master/examples/server/server.go for an example.

Documentation

http://go.pkgdoc.org/github.com/zond/gosafe

gosafe's People

Contributors

fwal avatar zond 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.