feat: use json verify json

This commit is contained in:
2020-11-07 23:52:11 +08:00
parent 8bc89e80bb
commit cad9dfe606
3 changed files with 11 additions and 5 deletions

View File

@@ -521,6 +521,12 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "json"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
[[package]]
name = "kernel32-sys"
version = "0.2.2"
@@ -1421,6 +1427,7 @@ name = "virt_enclave"
version = "0.1.0"
dependencies = [
"hex",
"json",
"lazy_static",
"quick-js",
"ring",

View File

@@ -16,3 +16,4 @@ rust_util = "0.6"
lazy_static = "1.4"
tokio = { version = "0.2", features = ["full"] }
warp = "0.2"
json = "0.12"

View File

@@ -46,11 +46,9 @@ impl QuickJSContext {
'_'
}).collect();
// TODO check JSON valid
// let v: Option<Vec<EmptyObject>> = serde_json::from_str(params).ok();
// if v.is_none() {
// return Err(rust_util::new_box_error("Params is not valid JSON array!"));
// }
if let Err(e) = json::parse(params) {
return Err(rust_util::new_box_error(&format!("Params is not valid JSON array: {}", e)));
}
self.context.eval(&format!("__PUBLIC_{}.apply(null, {})", f, params)).map_err(|e| e.into())
}
}