cargo-task-wasm 0.1.1

A task runner for Cargo
cargo-task-wasm-0.1.1 is not a library.

About

This project provides a new cargo task subcommand that can be used to run project-local tasks inside a secure WebAssembly sandbox. It looks for files in a tasks/ subdirectory of your project's root, and compiles those to Wasm Components. This is an attempt at formalizing cargo-xtask pattern into a secure, first-class workflow.

Roadmap

  • Sketch out a repository layout or whatever workflow example
  • Create a new cargo subcommand
  • Hook up wasmtime to the subcommand
  • Add support for manual paths in a [tasks] section in Cargo.toml
  • Figure out how to configure capabilities for the tasks
  • Add support for compiling cargo deps as part of subcommands
  • Add support for installing tasks from crates.io

Installation

The cargo task subcommand compiles Rust to Wasm Components targeting WASI 0.2. In order to do that a working WASI 0.2 toolchain needs to be present on the host system.

$ rustup +beta target add wasip2  # Install the WASI 0.2 target
$ cargo install cargo-task-wasm   # Install the `cargo task` subcommand

Usage

Usage: cargo task <TASK_NAME> [ARGS]...

Arguments:
  <TASK_NAME>  The name of the task to run
  [ARGS]...    Optional arguments to pass to the task

Options:
  -h, --help     Print help
  -V, --version  Print version

Configuration

Permissions

Tasks in cargo task follow the principle of least privilege. By default they only get access to the working directory, and can access any additional command line arguments passed to it. Additional permissions can be configured via a [tasks] section in Cargo.toml.

[package]
name = "example"
version = "0.1.0"
edition = "2021"

[task-dependencies]
wstd = "0.4.0"

[tasks]
env = { permissions = { inherit-env = ["FOO"] } }   # inherit specific env vars

Paths

By default the cargo task subcommand will look for commands in the tasks/ directory of the workspace. However, it is also able to find tasks located in other locations by specifying custom paths.

[tasks]
print = { path = "tasks/print.rs" }   # define a custom path for the task

See Also

Safety

This crate uses #![deny(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

License