From ae6314b80171143c63f2f48944ae097a1b9deaa1 Mon Sep 17 00:00:00 2001 From: Josh Heinrichs Date: Mon, 18 Aug 2025 18:51:13 -0600 Subject: [PATCH] Make os and arch available as constants I bumped the mem limit because I couldn't have large when dos. It feels like that shouldn't be necessary. --- src/lang.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/lang.rs b/src/lang.rs index e9306ad..3c645df 100644 --- a/src/lang.rs +++ b/src/lang.rs @@ -97,9 +97,9 @@ impl ShadowLang { // "Maximum size of value stack, in values" // This also puts a cap on the size of string literals in a single function invocation. // The default limit of 256 then means a limit of 256 bytes of string per invocation. - // We'll increase this to 8k, in case people want to embed an RSA cert or something (don't + // We'll increase this to 64k, in case people want to embed an RSA cert or something (don't // construe this as an endorsement of that plan). - restrictions.memory_limit = 8192; + restrictions.memory_limit = 65536; let interp = ketos::Builder::new() .restrict(restrictions) @@ -113,6 +113,18 @@ impl ShadowLang { .scope() .add_constant(shadowenv_name, Value::Foreign(rc_wrapper.clone())); + let system_os_name = interp.scope().add_name("system/os"); + interp.scope().add_constant( + system_os_name, + >::into(std::env::consts::OS.to_string()), + ); + + let system_arch_name = interp.scope().add_name("system/arch"); + interp.scope().add_constant( + system_arch_name, + >::into(std::env::consts::ARCH.to_string()), + ); + ketos_fn2! { interp.scope() => "path-concat" => fn path_concat(...) -> String }