diff --git a/Cargo.toml b/Cargo.toml index ec5f641..ca4d32e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,11 +10,11 @@ default-run = "opa-eval" [dependencies] anyhow = "1" serde = { version = "1", features = ["derive"] } -serde_json = "1.0.18" # This is the earliest version which supports 128-bit integers +serde_json = "1.0.117" thiserror = "1" -tokio = { version = "1.5", features = ["sync", "macros"] } -tracing = "0.1.27" -wasmtime = { version = ">=16, <21", default-features = false, features = ["async"] } +tokio = { version = "1.38", features = ["sync", "macros"] } +tracing = "0.1.40" +wasmtime = { version = ">=16", default-features = false, features = ["async"] } # Loader tokio-tar = { version = "0.3", optional = true } @@ -24,7 +24,7 @@ futures-util = { version = "0.3", optional = true } # CLI camino = { version = "1", optional = true } clap = { version = "4", features = ["derive"], optional = true } -tracing-forest = { version = "0.1.4", optional = true } +tracing-forest = { version = "0.1.6", optional = true } tracing-subscriber = { version = "0.3", features = ["env-filter"], optional = true } # Builtins @@ -32,33 +32,33 @@ base64 = { version = "0.22", optional = true } digest = { version = "0.10", optional = true } hex = { version = "0.4", optional = true } hmac = { version = "0.12", optional = true } -json-patch = { version = ">=0.2.3, <1.3.0", optional = true, default-features = false } +json-patch = { version = ">=0.2.3", optional = true, default-features = false } md-5 = { version = "0.10", optional = true } rand = { version = "0.8", optional = true } semver = { version = "1", optional = true } sha1 = { version = "0.10", optional = true } sha2 = { version = "0.10", optional = true } -sprintf = { version = "0.2", optional = true } +sprintf = { version = "0.3", optional = true } parse-size = { version = "1", features = ["std"], optional = true } -serde_yaml = { version = "0.9.1", optional = true } +serde_yaml = { version = "0.9.34", optional = true } form_urlencoded = { version = "1", optional = true } urlencoding = { version = "2", optional = true } -chrono = { version = "0.4.31", optional = true, default-features = false, features = ["std", "clock"] } -chrono-tz = { version = ">=0.6, <0.10.0", optional = true } +chrono = { version = "0.4.38", optional = true, default-features = false, features = ["std", "clock"] } +chrono-tz = { version = ">=0.6", optional = true } chronoutil = { version = "0.2", optional = true } -duration-str = { version = "0.7", optional = true, default-features = false } +duration-str = { version = "0.11", optional = true, default-features = false } [dev-dependencies.tokio] -version = "1.5" +version = "1.38" features = ["macros", "fs", "rt", "rt-multi-thread"] [dev-dependencies] -wasmtime = { version = ">=16, <21", default-features = false, features = ["cranelift"] } +wasmtime = { version = ">=16", default-features = false, features = ["cranelift"] } insta = { version = "1", features = ["yaml"] } [build-dependencies] # psm's (used by wasmtime) build-script uses a feature introduced in cc 1.0.2 -cc = "1.0.2" +cc = "1.0.99" indexmap = ">=1.9.1" [features] diff --git a/src/builtins/impls/time.rs b/src/builtins/impls/time.rs index c6aadac..a2b4701 100644 --- a/src/builtins/impls/time.rs +++ b/src/builtins/impls/time.rs @@ -96,7 +96,9 @@ pub fn now_ns(ctx: &mut C) -> i64 { /// Returns the duration in nanoseconds represented by a string. #[tracing::instrument(name = "time.parse_duration_ns", err)] pub fn parse_duration_ns(duration: String) -> Result { - Ok(duration_str::parse(duration.as_str())?.as_nanos()) + Ok(duration_str::parse(duration.as_str()) + .map_err(|e| anyhow!("{e}"))? + .as_nanos()) } /// Returns the time in nanoseconds parsed from the string in the given format. diff --git a/src/policy.rs b/src/policy.rs index 30b8ce2..995c502 100644 --- a/src/policy.rs +++ b/src/policy.rs @@ -262,10 +262,10 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap2_async( + linker.func_wrap_async( "env", "opa_builtin0", - move |caller: Caller<'_, _>, builtin_id: i32, _ctx: i32| { + move |caller: Caller<'_, _>, (builtin_id, _ctx): (i32, i32)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins @@ -280,10 +280,10 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap3_async( + linker.func_wrap_async( "env", "opa_builtin1", - move |caller: Caller<'_, _>, builtin_id: i32, _ctx: i32, param1: i32| { + move |caller: Caller<'_, _>, (builtin_id, _ctx, param1): (_, i32, _)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins @@ -298,14 +298,10 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap4_async( + linker.func_wrap_async( "env", "opa_builtin2", - move |caller: Caller<'_, _>, - builtin_id: i32, - _ctx: i32, - param1: i32, - param2: i32| { + move |caller: Caller<'_, _>, (builtin_id, _ctx, param1, param2): (_, i32, _, _)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins @@ -320,15 +316,10 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap5_async( + linker.func_wrap_async( "env", "opa_builtin3", - move |caller: Caller<'_, _>, - builtin_id: i32, - _ctx: i32, - param1: i32, - param2: i32, - param3: i32| { + move |caller: Caller<'_, _>, (builtin_id, _ctx, param1, param2, param3): (_, i32, _, _, _)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins @@ -343,16 +334,11 @@ impl Runtime { { let eventually_builtins = eventually_builtins.clone(); - linker.func_wrap6_async( + linker.func_wrap_async( "env", "opa_builtin4", move |caller: Caller<'_, _>, - builtin_id: i32, - _ctx: i32, - param1: i32, - param2: i32, - param3: i32, - param4: i32| { + (builtin_id, _ctx, param1, param2, param3, param4): (_, i32, _, _, _, _)| { let eventually_builtins = eventually_builtins.clone(); Box::new(async move { eventually_builtins