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
cargosubcommand - Hook up wasmtime to the subcommand
- Add support for manual paths in a
[tasks]section inCargo.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.
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.
[]
= "example"
= "0.1.0"
= "2021"
[]
= "0.4.0"
[]
= { = { = ["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.rs" } # define a custom path for the task
See Also
- Custom tasks in Cargo (Aaron Turon, 2018) - First proposed a
cargo tasksubcommand for custom tasks. matklad/cargo-xtask(Alex Kladov, 2019) - A convention-based implementation ofcargo task.dtolnay/watt(David Tolnay 2019) - Executing Rust procedural macros compiled as WebAssembly.
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: