feat: use json verify json
This commit is contained in:
7
__enclave/virt_enclave/Cargo.lock
generated
7
__enclave/virt_enclave/Cargo.lock
generated
@@ -521,6 +521,12 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "json"
|
||||||
|
version = "0.12.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kernel32-sys"
|
name = "kernel32-sys"
|
||||||
version = "0.2.2"
|
version = "0.2.2"
|
||||||
@@ -1421,6 +1427,7 @@ name = "virt_enclave"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"hex",
|
"hex",
|
||||||
|
"json",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"quick-js",
|
"quick-js",
|
||||||
"ring",
|
"ring",
|
||||||
|
|||||||
@@ -16,3 +16,4 @@ rust_util = "0.6"
|
|||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
tokio = { version = "0.2", features = ["full"] }
|
tokio = { version = "0.2", features = ["full"] }
|
||||||
warp = "0.2"
|
warp = "0.2"
|
||||||
|
json = "0.12"
|
||||||
|
|||||||
@@ -46,11 +46,9 @@ impl QuickJSContext {
|
|||||||
'_'
|
'_'
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
// TODO check JSON valid
|
if let Err(e) = json::parse(params) {
|
||||||
// let v: Option<Vec<EmptyObject>> = serde_json::from_str(params).ok();
|
return Err(rust_util::new_box_error(&format!("Params is not valid JSON array: {}", e)));
|
||||||
// if v.is_none() {
|
}
|
||||||
// return Err(rust_util::new_box_error("Params is not valid JSON array!"));
|
|
||||||
// }
|
|
||||||
self.context.eval(&format!("__PUBLIC_{}.apply(null, {})", f, params)).map_err(|e| e.into())
|
self.context.eval(&format!("__PUBLIC_{}.apply(null, {})", f, params)).map_err(|e| e.into())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user