diff --git a/.gitignore b/.gitignore index 7233e486..a9a56c57 100644 --- a/.gitignore +++ b/.gitignore @@ -12,10 +12,7 @@ target/ # REPL history files *.repl_history -# Temporary file of ipfs node example -/examples/ipfs_node/wasm/artifacts/ipfs_rpc_file - # Allowed Wasm files for examples !/examples/greeting/artifacts/*.wasm -!/examples/ipfs_node/artifacts/wasm_modules/*.wasm -!/examples/records/artifacts/wasm_modules/*.wasm +!/examples/ipfs_node/artifacts/*.wasm +!/examples/records/artifacts/*.wasm diff --git a/Cargo.lock b/Cargo.lock index cf31a750..a56e2dbf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -598,7 +598,7 @@ dependencies = [ [[package]] name = "fce-wit-generator" -version = "0.1.2" +version = "0.1.3" dependencies = [ "fce-wit-parser", "fluence-sdk-wit 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -630,7 +630,7 @@ dependencies = [ [[package]] name = "fcli" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "clap", @@ -652,7 +652,7 @@ dependencies = [ [[package]] name = "fluence-app-service" -version = "0.1.1" +version = "0.1.2" dependencies = [ "fluence-faas", "log", @@ -663,7 +663,7 @@ dependencies = [ [[package]] name = "fluence-faas" -version = "0.1.1" +version = "0.1.2" dependencies = [ "cmd_lib", "fce", @@ -768,7 +768,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "frepl" -version = "0.1.3" +version = "0.1.4" dependencies = [ "anyhow", "clap", diff --git a/crates/wit-generator/Cargo.toml b/crates/wit-generator/Cargo.toml index b73f1a89..ccf02df4 100644 --- a/crates/wit-generator/Cargo.toml +++ b/crates/wit-generator/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "fce-wit-generator" description = "Fluence FCE interface type helper crate" -version = "0.1.2" +version = "0.1.3" authors = ["Fluence Labs"] license = "Apache-2.0" edition = "2018" diff --git a/crates/wit-generator/src/instructions_generator/foreign_mod_instructions.rs b/crates/wit-generator/src/instructions_generator/foreign_mod_instructions.rs index 0c753eaf..fa217889 100644 --- a/crates/wit-generator/src/instructions_generator/foreign_mod_instructions.rs +++ b/crates/wit-generator/src/instructions_generator/foreign_mod_instructions.rs @@ -195,7 +195,7 @@ impl ForeignModInstructionGenerator for ParsedType { ParsedType::ByteVector => vec![ Instruction::ArgumentGet { index }, Instruction::ArgumentGet { index: index + 1 }, - Instruction::StringLiftMemory, + Instruction::ByteArrayLiftMemory, ], ParsedType::Record(record_name) => { let type_index = wit_resolver.get_record_type_id(record_name)?; diff --git a/examples/records/Config.toml b/examples/records/Config.toml index 5f0925a5..0ae47b66 100644 --- a/examples/records/Config.toml +++ b/examples/records/Config.toml @@ -1,4 +1,4 @@ -modules_dir = "artifacts/wasm_modules" +modules_dir = "artifacts/" [[module]] name = "effector" diff --git a/examples/records/artifacts/wasm_modules/effector.wasm b/examples/records/artifacts/effector.wasm similarity index 100% rename from examples/records/artifacts/wasm_modules/effector.wasm rename to examples/records/artifacts/effector.wasm diff --git a/examples/records/artifacts/wasm_modules/pure.wasm b/examples/records/artifacts/pure.wasm similarity index 100% rename from examples/records/artifacts/wasm_modules/pure.wasm rename to examples/records/artifacts/pure.wasm diff --git a/fluence-app-service/Cargo.toml b/fluence-app-service/Cargo.toml index 1bcd14d5..ea581ecc 100644 --- a/fluence-app-service/Cargo.toml +++ b/fluence-app-service/Cargo.toml @@ -1,13 +1,13 @@ [package] name = "fluence-app-service" description = "Fluence Application Service" -version = "0.1.1" +version = "0.1.2" authors = ["Fluence Labs"] license = "Apache-2.0" edition = "2018" [dependencies] -fluence-faas = { path = "../fluence-faas", version = "0.1.1" } +fluence-faas = { path = "../fluence-faas", version = "0.1.2" } log = "0.4.8" serde_json = "1.0.53" diff --git a/fluence-faas/Cargo.toml b/fluence-faas/Cargo.toml index 8011abdf..76759899 100644 --- a/fluence-faas/Cargo.toml +++ b/fluence-faas/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "fluence-faas" description = "Fluence FaaS" -version = "0.1.1" +version = "0.1.2" authors = ["Fluence Labs"] license = "Apache-2.0" edition = "2018" diff --git a/fluence-faas/src/misc/imports.rs b/fluence-faas/src/misc/imports.rs index 317e125a..82b17ccb 100644 --- a/fluence-faas/src/misc/imports.rs +++ b/fluence-faas/src/misc/imports.rs @@ -49,6 +49,7 @@ fn write_to_mem(context: &mut Ctx, address: usize, value: &[u8]) { .for_each(|(cell, byte)| cell.set(*byte)); } +#[rustfmt::skip] pub(super) fn create_host_import_func(host_cmd: S) -> DynamicFunc<'static> where S: Into, @@ -56,10 +57,8 @@ where use wasmer_core::Func; let allocate_func: Box>>> = Box::new(RefCell::new(None)); - let set_result_ptr_func: Box>>> = - Box::new(RefCell::new(None)); - let set_result_size_func: Box>>> = - Box::new(RefCell::new(None)); + let set_result_ptr_func: Box>>> = Box::new(RefCell::new(None)); + let set_result_size_func: Box>>> = Box::new(RefCell::new(None)); let host_cmd = host_cmd.into(); @@ -73,8 +72,18 @@ where let wasm_ptr = WasmPtr::::new(array_ptr as _); let result = match wasm_ptr.get_utf8_string(ctx.memory(0), array_size as _) { - Some(arg_value) => cmd_lib::run_fun!("{} {}", host_cmd, arg_value).unwrap(), - None => return vec![], + // TODO: prevent command injection + Some(arg_value) => match cmd_lib::run_fun!("{} {}", host_cmd, arg_value) { + Ok(result) => result, + Err(e) => { + log::error!("error occurred while calling `{} {}`: {:?} ", host_cmd, arg_value, e); + String::new() + }, + } + None => { + log::error!("error getting utf8 string from {} offset of {} bytes", array_ptr, array_size); + String::new() + } }; unsafe { diff --git a/tools/cli/Cargo.toml b/tools/cli/Cargo.toml index 5770bead..5c85e7a6 100644 --- a/tools/cli/Cargo.toml +++ b/tools/cli/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "fcli" description = "Fluence FCE command line tool" -version = "0.1.3" +version = "0.1.4" authors = ["Fluence Labs"] repository = "https://github.com/fluencelabs/fce/tools/cli" license = "Apache-2.0" @@ -12,7 +12,7 @@ name = "fce" path = "src/main.rs" [dependencies] -fce-wit-generator = { path = "../../crates/wit-generator", version = "0.1.2"} +fce-wit-generator = { path = "../../crates/wit-generator", version = "0.1.3"} fce-wit-parser = { path = "../../crates/wit-parser", version = "0.1.3" } anyhow = "1.0.31" diff --git a/tools/repl/Cargo.toml b/tools/repl/Cargo.toml index 949eab69..4a5d8c61 100644 --- a/tools/repl/Cargo.toml +++ b/tools/repl/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "frepl" description = "Fluence FCE REPL intended for testing purposes" -version = "0.1.3" +version = "0.1.4" authors = ["Fluence Labs"] repository = "https://github.com/fluencelabs/fce/tools/repl" license = "Apache-2.0" @@ -12,7 +12,7 @@ name = "fce-repl" path = "src/main.rs" [dependencies] -fluence-app-service = { path = "../../fluence-app-service", version = "0.1.1", features = ["raw-module-api"] } +fluence-app-service = { path = "../../fluence-app-service", version = "0.1.2", features = ["raw-module-api"] } anyhow = "1.0.31" clap = "2.33.1"