Function module

Source
pub fn module(_stdio: bool) -> Result<Module, ContextError>
Expand description

Construct the ret2api::bucket module.

§Usage

    let mut context = Context::with_default_modules()?;
    context.install(ret2script::modules::bucket::module(true)?)?;

§Examples

pub fn check(bucket, ...) {
  let files = bucket.list(".")?; // get current directory files.
  let file = bucket.open("flag.txt")?; // get a file object.
  let (flag, flag_len) = file.get_str()?; // get file content as string.
  let (bin, bin_len) = bucket.open("flag.png")?.get_bytes()?; // get file content as bytes
}

# Limitations

Bucket instance could not constructed from rune script, it must be constructed in Rust and
passed to rune functions.

For security reasons, bucket has builtin path traversal detections, any read operation that
exlude bucket root will be treated as error.