gate

package module
v0.0.0-...-0e4e454 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2020 License: BSD-3-Clause Imports: 0 Imported by: 0

README

Gate

Run untrusted code from anonymous sources. Instead of sending messages composed of passive data, send programs which can react to their environment. Migrate or duplicate running applications across hosts and computer architectures. See Introduction to Gate.

Foundations

WebAssembly is the interchange format of the user programs. However, the APIs are different from the browsers' usual WebAssembly environments. See low-level C API or the higher-level Rust crate for details.

The sandboxing and containerization features of the Linux kernel provide layers of security in addition to WebAssembly. See Security for details.

Gate services are akin to syscalls, but they work differently. New services can be added easily, and available services are discovered at run time. See Service implementation for details.

Building blocks

Gate appears as Go packages and programs. The execution mechanism is implemented in C and assembly, and needs to be built separately (see below). It's highly Linux-dependent. x86-64 and ARM64 are supported.

Important Go packages:

  • wag: The WebAssembly compiler (implemented in a separate repository).

  • gate/runtime: Core functionality. Interface to the execution mechanism.

  • gate/image: Low-level executable building and instance management.

  • gate/build: High-level executable building and snapshot restoration.

  • gate/server/webserver: HTTP server component which executes your code on purpose. It has a RESTful API, but some actions can be invoked also via websocket.

  • gate/service: Service implementation support and built-in services.

Programs:

  • gate: Command-line client for local daemon and remote servers. Uses SSH keys (Ed25519) for authentication.

  • gated: D-Bus daemon for running and managing instances and wasm modules locally.

  • gate-server: Standalone web server which can serve the public or require authentication.

  • gate-runtimed: For optionally preconfiguring the execution environment, e.g. as a system service.

  • gate-run: Run programs locally. (Being superseded by gate.)

See the complete list of Go packages.

Objectives

While code is data, most of the time data cannot be treated as code for safety reasons. Change that at the Internet level. Data encapsulated in code can describe and transform itself.

Application portability. Migrate processes between mobile devices and servers when circumstances change: user presence, resource availability or demand, continuity etc.

Overhead needs to be low enough so that the system can be practical. Low startup latency for request processing. Low memory overhead for high density of continually running programs.

Work in progress

  • Linux x86-64 host support
  • Android host support
  • Support for WebAssembly version 1
  • Planned security measures have been implemented
  • HTTP server for running programs
  • Client can communicate with the program it runs on the server
  • Speculative execution security issue mitigations
  • Pluggable authentication
  • Load programs from IPFS
  • Reconnect to program instance
  • Snapshot
  • Restore
  • Programs can discover and communicate with their peers on a server
  • Full ARM64 host support
  • milestone/1
  • Clone programs locally or remotely (with or without snapshotting)
  • milestone/2
  • Expose program instance at some type of internet endpoint to implement ad-hoc servers
  • Mechanism for implementing services in a programmer-friendly way
  • Useful resource control policies need more thought (cgroup configuration etc.)
  • Stable APIs
  • Additional security measures (such as a SELinux profile)
  • Non-Linux host support

User program support:

  • Low-level C API
  • Rust support (out of date)
  • Improved Rust support
  • Go support
  • Approach for splitting WebAssembly app between browser (UI) and server (state)

Build requirements

The non-Go components can be built with make. They require:

  • Linux
  • musl-tools (musl-gcc), unless CC make variable is overridden
  • pkg-config
  • uidmap (shadow-utils)
  • protobuf-compiler
  • libc-dev
  • libsystemd-dev, unless CGROUP_BACKEND=none is specified for make

make bin builds the programs using the Go 1.11 module mechanism. (Individual packages may be buildable with older Go versions.)

Running the D-Bus enabled programs (gate and gated) requires:

  • dbus-user-session

Additional requirements for make check:

  • libgtest-dev
  • python

See Makefile for more targets.

The capabilities targets grant capabilities for the installed container binary (lib). That requires:

  • libcap2-bin

See also

Documentation

Overview

Package gate contains general documentation for its subpackages. See https://github.com/tsavola/gate for information about the Gate project.

Errors

Error strings may contain sensitive details. Some errors returned by Gate implement this interface:

interface {
	PublicError() string
}

The public error string is intended to be exposed to the client (if the API was called via a server endpoint). If there is no PublicError method, it's an internal error with no public explanation.

Directories

Path Synopsis
cmd
Package facile exposes a simplified API to core functionality.
Package facile exposes a simplified API to core functionality.
internal
bus
sys
Package sys contains syscall wrappers.
Package sys contains syscall wrappers.
packetio
Package packetio provides streaming utilities.
Package packetio provides streaming utilities.
abi
scope
database/sql
Package sql implements an AccessTracker backed by an SQL database.
Package sql implements an AccessTracker backed by an SQL database.
monitor
Package monitor implements server.Monitor.
Package monitor implements server.Monitor.
source
http
Package http can download objects from HTTP server.
Package http can download objects from HTTP server.
ipfs
Package ipfs can download objects via IPFS API server.
Package ipfs can download objects via IPFS API server.
Package trap enumerates trap identifiers.
Package trap enumerates trap identifiers.
Package webapi contains definitions useful for accessing the HTTP and websocket APIs.
Package webapi contains definitions useful for accessing the HTTP and websocket APIs.

Jump to

Keyboard shortcuts

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