From 4f84f278c9ece7e0717ea9c2de21e28a6281bf85 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sat, 23 Nov 2024 20:46:34 +0100 Subject: [PATCH 01/17] Add RustPython integration He-he :-) --- libsysinspect/Cargo.toml | 3 + libsysinspect/src/lib.rs | 1 + libsysinspect/src/pylang/mod.rs | 2 + libsysinspect/src/pylang/pvm.rs | 109 ++++++++++++++++++++++++++ libsysinspect/src/pylang/pylib/mod.rs | 0 sysminion/src/minion.rs | 1 + 6 files changed, 116 insertions(+) create mode 100644 libsysinspect/src/pylang/mod.rs create mode 100644 libsysinspect/src/pylang/pvm.rs create mode 100644 libsysinspect/src/pylang/pylib/mod.rs diff --git a/libsysinspect/Cargo.toml b/libsysinspect/Cargo.toml index d41eba60..7b29a002 100644 --- a/libsysinspect/Cargo.toml +++ b/libsysinspect/Cargo.toml @@ -20,6 +20,9 @@ prettytable-rs = "0.10.0" rand = "0.8.5" regex = "1.10.6" rsa = { version = "0.9.6", features = ["pkcs5", "sha1", "sha2"] } +rustpython = { version = "0.4.0", features = ["freeze-stdlib"] } +rustpython-pylib = { version = "0.4.0", features = ["freeze-stdlib"] } +rustpython-vm = { version = "0.4.0", features = ["freeze-stdlib"] } serde = { version = "1.0.210", features = ["derive"] } serde_json = "1.0.128" serde_yaml = "0.9.34" diff --git a/libsysinspect/src/lib.rs b/libsysinspect/src/lib.rs index dd96d683..f5c1a88d 100644 --- a/libsysinspect/src/lib.rs +++ b/libsysinspect/src/lib.rs @@ -14,6 +14,7 @@ pub mod logger; pub mod mdescr; pub mod modlib; pub mod proto; +pub mod pylang; pub mod reactor; pub mod rsa; pub mod tmpl; diff --git a/libsysinspect/src/pylang/mod.rs b/libsysinspect/src/pylang/mod.rs new file mode 100644 index 00000000..0fb2cf45 --- /dev/null +++ b/libsysinspect/src/pylang/mod.rs @@ -0,0 +1,2 @@ +pub mod pvm; +pub mod pylib; diff --git a/libsysinspect/src/pylang/pvm.rs b/libsysinspect/src/pylang/pvm.rs new file mode 100644 index 00000000..8c9c869d --- /dev/null +++ b/libsysinspect/src/pylang/pvm.rs @@ -0,0 +1,109 @@ +/* +Python virtual machine + */ + +use crate::SysinspectError; +use rustpython_vm::compiler::Mode::Exec; +use rustpython_vm::VirtualMachine; +use rustpython_vm::{Interpreter, Settings}; +use std::{ + fs, + path::{Path, PathBuf}, + sync::Arc, +}; + +pub struct PyVm { + itp: Interpreter, + libpath: String, + modpath: String, +} + +impl PyVm { + pub fn new(libpath: Option, modpath: Option) -> Self { + let mut cfg = Settings::default(); + let libpath = libpath.unwrap_or("/usr/share/sysinspect/lib".to_string()); + cfg.path_list.push(libpath.to_string()); + + let itp = rustpython::InterpreterConfig::new() + .init_stdlib() + .settings(cfg) + /* + .init_hook(Box::new(|vm| { + vm.add_native_module("rust_py_module".to_owned(), Box::new(rust_py_module::make_module)); + })) + */ + .interpreter(); + + Self { itp, libpath: libpath.to_string(), modpath: modpath.unwrap_or("/usr/share/sysinspect/modules/".to_string()) } + } + + /// Load main script of a module by a regular namespace + fn load_script(&self, ns: &str) -> String { + // XXX: empty string is also python code! + fs::read_to_string(PathBuf::from(&self.modpath).join(format!("{ns}.py"))).unwrap_or_default() + } + + fn load_pylib(&self, vm: &VirtualMachine) -> Result<(), SysinspectError> { + match vm.import("sys", 0) { + Ok(sysmod) => match sysmod.get_attr("path", vm) { + Ok(syspath) => { + if let Err(err) = vm.call_method(&syspath, "append", (&self.libpath,)) { + return Err(SysinspectError::ModuleError(format!("{:?}", err))); + } + } + Err(err) => { + return Err(SysinspectError::ModuleError(format!("{:?}", err))); + } + }, + Err(err) => { + return Err(SysinspectError::ModuleError(format!("{:?}", err))); + } + }; + Ok(()) + } + + pub fn as_ptr(&self) -> Arc<&Self> { + Arc::new(self) + } + + /// Call a light Python module + pub fn call(self: Arc<&Self>, namespace: &str) -> Result<(), SysinspectError> { + self.itp.enter(|vm| { + let lpth = Path::new(&self.libpath); + if !lpth.exists() || !lpth.is_dir() { + return Err(SysinspectError::ModuleError(format!("Directory {} does not exist", &self.libpath))); + } + self.load_pylib(vm)?; + + let code_obj = match vm.compile(&self.load_script(namespace), Exec, "".to_owned()) { + Ok(src) => src, + Err(err) => { + return Err(SysinspectError::ModuleError(format!("Unable to compile source code for {namespace}: {err}"))); + } + }; + + log::debug!("Prepared to launch dispatcher for python script"); + + let scope = vm.new_scope_with_builtins(); + if let Err(err) = vm.run_code_obj(code_obj, scope.clone()) { + return Err(SysinspectError::ModuleError(format!("Error running \"{namespace}\" Python module: {:?}", err))); + } + + let dispatcher_function = scope.globals.get_item("dispatch", vm).expect("Failed to find `dispatch` function"); + let result = match dispatcher_function.call((), vm) { + Ok(r) => r, + Err(err) => { + vm.print_exception(err); + return Ok(()); + } + }; + + if let Ok(py_str) = result.downcast::() { + println!("{}", py_str.as_str()); + } else { + println!("error: no string return"); + } + Ok(()) + }) + } +} diff --git a/libsysinspect/src/pylang/pylib/mod.rs b/libsysinspect/src/pylang/pylib/mod.rs new file mode 100644 index 00000000..e69de29b diff --git a/sysminion/src/minion.rs b/sysminion/src/minion.rs index ace97e61..b986930e 100644 --- a/sysminion/src/minion.rs +++ b/sysminion/src/minion.rs @@ -9,6 +9,7 @@ use libsysinspect::{ rqtypes::RequestType, MasterMessage, MinionMessage, ProtoConversion, }, + pylang::{self, pvm::PyVm}, rsa, traits::{self, systraits::SystemTraits}, util::dataconv, From 416550649760fe0f4a4bfd3def5baa7d48a7c113 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sat, 23 Nov 2024 20:47:02 +0100 Subject: [PATCH 02/17] Add vendored openssl for static builds on musl --- Cargo.lock | 1646 ++++++++++++++++++++++++++++++++++++++++++++++++---- Cargo.toml | 5 +- 2 files changed, 1529 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7196b22c..a2fceac7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,7 +30,7 @@ dependencies = [ "actix-service", "actix-utils", "ahash", - "base64", + "base64 0.22.1", "bitflags 2.6.0", "brotli", "bytes", @@ -65,7 +65,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" dependencies = [ "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -182,7 +182,7 @@ dependencies = [ "actix-router", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -200,6 +200,12 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + [[package]] name = "aes" version = "0.8.4" @@ -263,6 +269,15 @@ dependencies = [ "libc", ] +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + [[package]] name = "anstream" version = "0.6.18" @@ -312,12 +327,44 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "anyhow" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" + +[[package]] +name = "ascii" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" + +[[package]] +name = "atomic" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994" +dependencies = [ + "bytemuck", +] + [[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + [[package]] name = "autocfg" version = "1.4.0" @@ -326,9 +373,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "aws-lc-rs" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdd82dba44d209fddb11c190e0a94b78651f95299598e472215667417a03ff1d" +checksum = "fe7c2840b66236045acd2607d5866e274380afd87ef99d6226e961e2cb47df45" dependencies = [ "aws-lc-sys", "mirai-annotations", @@ -338,9 +385,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df7a4168111d7eb622a31b214057b8509c0a7e1794f44c546d742330dc793972" +checksum = "ad3a619a9de81e1d7de1f1186dcba4506ed661a0e483d84410fdef0ee87b2f96" dependencies = [ "bindgen", "cc", @@ -366,6 +413,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.22.1" @@ -396,7 +449,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools", + "itertools 0.12.1", "lazy_static", "lazycell", "log", @@ -406,7 +459,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.87", + "syn 2.0.89", "which", ] @@ -422,6 +475,15 @@ version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + [[package]] name = "block-buffer" version = "0.10.4" @@ -461,6 +523,17 @@ dependencies = [ "alloc-stdlib", ] +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata 0.1.10", +] + [[package]] name = "bstr" version = "1.11.0" @@ -477,6 +550,12 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +[[package]] +name = "bytemuck" +version = "1.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a" + [[package]] name = "byteorder" version = "1.5.0" @@ -498,6 +577,16 @@ dependencies = [ "bytes", ] +[[package]] +name = "caseless" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808dab3318747be122cb31d36de18d4d1c81277a76f8332a02b81a3d73463d7f" +dependencies = [ + "regex", + "unicode-normalization", +] + [[package]] name = "cbc" version = "0.1.2" @@ -533,6 +622,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "cfg_aliases" version = "0.2.1" @@ -597,6 +692,21 @@ dependencies = [ "libloading", ] +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags 1.3.2", + "strsim 0.8.0", + "textwrap 0.11.0", + "unicode-width", + "vec_map", +] + [[package]] name = "clap" version = "4.5.21" @@ -615,7 +725,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim", + "strsim 0.11.1", ] [[package]] @@ -624,6 +734,15 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" +[[package]] +name = "clipboard-win" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15efe7a882b08f34e38556b14f2fb3daa98769d06c7f0c1b076dfd0d983bc892" +dependencies = [ + "error-code", +] + [[package]] name = "cmake" version = "0.1.51" @@ -690,9 +809,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" +checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" dependencies = [ "libc", ] @@ -731,6 +850,12 @@ version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -786,7 +911,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -819,7 +944,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -869,7 +994,19 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", +] + +[[package]] +name = "dns-lookup" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5766087c2235fec47fafa4cfecc81e494ee679d0fd4a59887ea0919bfb0e4fc" +dependencies = [ + "cfg-if", + "libc", + "socket2", + "windows-sys 0.48.0", ] [[package]] @@ -878,6 +1015,12 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "ed25519" version = "2.2.3" @@ -927,6 +1070,23 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "env_logger" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +dependencies = [ + "atty", + "log", + "termcolor", +] + [[package]] name = "equivalent" version = "1.0.1" @@ -943,12 +1103,35 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "error-code" +version = "3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5d9305ccc6942a704f4335694ecd3de2ea531b114ac2d51f5f843750787a92f" + +[[package]] +name = "exitcode" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193" + [[package]] name = "fastrand" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +[[package]] +name = "fd-lock" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" +dependencies = [ + "cfg-if", + "rustix 0.38.41", + "windows-sys 0.52.0", +] + [[package]] name = "fiat-crypto" version = "0.2.9" @@ -957,11 +1140,12 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", + "libz-sys", "miniz_oxide", ] @@ -1073,7 +1257,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1125,6 +1309,25 @@ dependencies = [ "version_check", ] +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "unicode-width", +] + [[package]] name = "getrandom" version = "0.2.15" @@ -1132,8 +1335,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -1155,9 +1360,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" dependencies = [ "aho-corasick", - "bstr", + "bstr 1.11.0", "log", - "regex-automata", + "regex-automata 0.4.9", "regex-syntax", ] @@ -1193,9 +1398,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e" dependencies = [ "atomic-waker", "bytes", @@ -1210,12 +1415,48 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.3.9" @@ -1234,6 +1475,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hexf-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" + [[package]] name = "hmac" version = "0.12.1" @@ -1320,14 +1567,14 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.6", + "h2 0.4.7", "http 1.1.0", "http-body", "httparse", @@ -1551,7 +1798,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -1585,7 +1832,7 @@ dependencies = [ "globset", "log", "memchr", - "regex-automata", + "regex-automata 0.4.9", "same-file", "walkdir", "winapi-util", @@ -1604,7 +1851,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.1", "serde", ] @@ -1644,6 +1891,18 @@ version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" +[[package]] +name = "is-macro" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d57a3e447e24c22647738e4607f1df1e0ec6f72e16182c4cd199f647cdfb0e4" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "is-terminal" version = "0.4.13" @@ -1661,6 +1920,15 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.12.1" @@ -1672,9 +1940,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "jobserver" @@ -1694,6 +1962,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "junction" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72bbdfd737a243da3dfc1f99ee8d6e166480f17ab4ac84d7c34aacd73fc7bd16" +dependencies = [ + "scopeguard", + "windows-sys 0.52.0", +] + [[package]] name = "keccak" version = "0.1.5" @@ -1703,6 +1981,12 @@ dependencies = [ "cpufeatures", ] +[[package]] +name = "lalrpop-util" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" + [[package]] name = "language-tags" version = "0.3.2" @@ -1724,11 +2008,41 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "lexical-parse-float" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" +dependencies = [ + "lexical-parse-integer", + "lexical-util", + "static_assertions", +] + +[[package]] +name = "lexical-parse-integer" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" +dependencies = [ + "lexical-util", + "static_assertions", +] + +[[package]] +name = "lexical-util" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc" +dependencies = [ + "static_assertions", +] + [[package]] name = "libc" -version = "0.2.162" +version = "0.2.164" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" [[package]] name = "libloading" @@ -1756,18 +2070,29 @@ dependencies = [ "libc", ] +[[package]] +name = "libsqlite3-sys" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c10584274047cb335c23d3e61bcef8e323adae7c5c8c760540f73610177fc3f" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "libsysinspect" version = "0.2.0" dependencies = [ - "base64", + "base64 0.22.1", "chrono", "colored", "hex", "indexmap", "lazy_static", "log", - "nix", + "nix 0.29.0", "once_cell", "pem", "pest", @@ -1776,18 +2101,32 @@ dependencies = [ "rand", "regex", "rsa", + "rustpython", + "rustpython-pylib", + "rustpython-vm", "serde", "serde_json", "serde_yaml", "sha2", - "sysinfo 0.32.0", + "sysinfo", "tera", - "textwrap", + "textwrap 0.16.1", "tokio", "unicode-segmentation", "walkdir", ] +[[package]] +name = "libz-sys" +version = "1.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "linux-raw-sys" version = "0.3.8" @@ -1840,39 +2179,147 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] -name = "memchr" -version = "2.7.4" +name = "lz4_flex" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" +dependencies = [ + "twox-hash", +] [[package]] -name = "memoffset" -version = "0.9.1" +name = "mac_address" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +checksum = "8836fae9d0d4be2c8b4efcdd79e828a2faa058a90d005abf42f91cac5493a08e" dependencies = [ - "autocfg", + "nix 0.28.0", + "winapi", ] [[package]] -name = "merlin" -version = "3.0.0" +name = "malachite" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +checksum = "5616515d632967cd329b6f6db96be9a03ea0b3a49cdbc45b0016803dad8a77b7" dependencies = [ - "byteorder", - "keccak", - "rand_core", - "zeroize", + "malachite-base", + "malachite-nz", + "malachite-q", ] [[package]] -name = "mime" -version = "0.3.17" +name = "malachite-base" +version = "0.4.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - -[[package]] +checksum = "46059721011b0458b7bd6d9179be5d0b60294281c23320c207adceaecc54d13b" +dependencies = [ + "hashbrown 0.14.5", + "itertools 0.11.0", + "libm", + "ryu", +] + +[[package]] +name = "malachite-bigint" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17703a19c80bbdd0b7919f0f104f3b0597f7de4fc4e90a477c15366a5ba03faa" +dependencies = [ + "derive_more", + "malachite", + "num-integer", + "num-traits", + "paste", +] + +[[package]] +name = "malachite-nz" +version = "0.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1503b27e825cabd1c3d0ff1e95a39fb2ec9eab6fd3da6cfa41aec7091d273e78" +dependencies = [ + "itertools 0.11.0", + "libm", + "malachite-base", +] + +[[package]] +name = "malachite-q" +version = "0.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a475503a70a3679dbe3b9b230a23622516742528ba614a7b2490f180ea9cb514" +dependencies = [ + "itertools 0.11.0", + "malachite-base", + "malachite-nz", +] + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "merlin" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58c38e2799fc0978b65dfff8023ec7843e2330bb462f19198840b34b6582397d" +dependencies = [ + "byteorder", + "keccak", + "rand_core", + "zeroize", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] name = "minimal-lexical" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1906,6 +2353,15 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9be0862c1b3f26a88803c4a49de6889c10e608b3ee9344e6ef5b45fb37ad3d1" +[[package]] +name = "mt19937" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12ca7f22ed370d5991a9caec16a83187e865bc8a532f889670337d5a5689e3a1" +dependencies = [ + "rand_core", +] + [[package]] name = "native-tls" version = "0.2.12" @@ -1955,14 +2411,48 @@ version = "0.2.0" dependencies = [ "libsysinspect", "neli", - "nix", + "nix 0.29.0", "serde", "serde_json", "serde_yaml", - "sysinfo 0.32.0", + "sysinfo", "tokio", ] +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "libc", + "memoffset", +] + +[[package]] +name = "nix" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "cfg_aliases 0.1.1", + "libc", + "memoffset", +] + [[package]] name = "nix" version = "0.29.0" @@ -1971,7 +2461,7 @@ checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.6.0", "cfg-if", - "cfg_aliases", + "cfg_aliases 0.2.1", "libc", "memoffset", ] @@ -2012,6 +2502,15 @@ dependencies = [ "zeroize", ] +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -2048,6 +2547,37 @@ dependencies = [ "libm", ] +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.9", + "libc", +] + +[[package]] +name = "num_enum" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e613fc340b2220f734a8595782c551f1250e969d87d3be1ae0579e8d4065179" +dependencies = [ + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.89", +] + [[package]] name = "object" version = "0.36.5" @@ -2086,7 +2616,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2095,6 +2625,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.4.1+3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faa4eac4138c62414b5622d1b31c5c304f34b406b013c079c2bbc652fdd6678c" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.104" @@ -2103,10 +2642,27 @@ checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] +[[package]] +name = "optional" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978aa494585d3ca4ad74929863093e87cac9790d81fe7aba2b3dc2890643a0fc" + +[[package]] +name = "page_size" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "parking_lot" version = "0.11.2" @@ -2186,7 +2742,7 @@ version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e459365e590736a54c3fa561947c84837534b8e9af6fc5bf781307e82658fae" dependencies = [ - "base64", + "base64 0.22.1", "serde", ] @@ -2236,7 +2792,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2344,6 +2900,17 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +[[package]] +name = "pmutil" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3894e5d549cccbe44afecf72922f277f603cd4bb0219c8342631ef18fffbe004" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "pocket-resources" version = "0.3.2" @@ -2372,7 +2939,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" dependencies = [ "proc-macro2", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -2398,14 +2965,23 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "sysinfo 0.32.0", + "sysinfo", +] + +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -2421,7 +2997,7 @@ dependencies = [ "flate2", "hex", "procfs-core", - "rustix 0.38.40", + "rustix 0.38.41", ] [[package]] @@ -2441,6 +3017,12 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1190fd18ae6ce9e137184f207593877e70f39b015040156b1e05081cdfe3733a" +[[package]] +name = "puruspe" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3804877ffeba468c806c2ad9057bbbae92e4b2c410c2f108baaa0042f241fa4c" + [[package]] name = "quote" version = "1.0.37" @@ -2450,6 +3032,22 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + [[package]] name = "rand" version = "0.8.5" @@ -2537,10 +3135,16 @@ checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", - "regex-automata", + "regex-automata 0.4.9", "regex-syntax", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "regex-automata" version = "0.4.9" @@ -2570,12 +3174,12 @@ version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ - "base64", + "base64 0.22.1", "bytes", "encoding_rs", "futures-core", "futures-util", - "h2 0.4.6", + "h2 0.4.7", "http 1.1.0", "http-body", "http-body-util", @@ -2596,7 +3200,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "sync_wrapper", - "system-configuration", + "system-configuration 0.6.1", "tokio", "tokio-native-tls", "tower-service", @@ -2607,6 +3211,28 @@ dependencies = [ "windows-registry", ] +[[package]] +name = "result-like" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccc7ce6435c33898517a30e85578cd204cbb696875efb93dec19a2d31294f810" +dependencies = [ + "result-like-derive", +] + +[[package]] +name = "result-like-derive" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fabf0a2e54f711c68c50d49f648a1a8a37adcb57353f518ac4df374f0788f42" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "syn 1.0.109", + "syn-ext", +] + [[package]] name = "ring" version = "0.17.8" @@ -2692,9 +3318,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.40" +version = "0.38.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" +checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" dependencies = [ "bitflags 2.6.0", "errno", @@ -2705,9 +3331,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.16" +version = "0.23.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +checksum = "7f1a745511c54ba6d4465e8d5dfbd81b45791756de28d4981af70d6dca128f1e" dependencies = [ "aws-lc-rs", "log", @@ -2745,12 +3371,419 @@ dependencies = [ "untrusted", ] +[[package]] +name = "rustpython" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef4653f77eb5866c7ba903bd0480bcfa9f6d41f73156895b1813687f8dbd026" +dependencies = [ + "atty", + "cfg-if", + "clap 2.34.0", + "dirs-next", + "env_logger", + "libc", + "log", + "rustpython-compiler", + "rustpython-parser", + "rustpython-pylib", + "rustpython-stdlib", + "rustpython-vm", + "rustyline", +] + +[[package]] +name = "rustpython-ast" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cdaf8ee5c1473b993b398c174641d3aa9da847af36e8d5eb8291930b72f31a5" +dependencies = [ + "is-macro", + "malachite-bigint", + "rustpython-literal", + "rustpython-parser-core", + "static_assertions", +] + +[[package]] +name = "rustpython-codegen" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f101783403a69155ba7b52d8365d796c772a0bfca7df0a5f16d267f3443986" +dependencies = [ + "ahash", + "bitflags 2.6.0", + "indexmap", + "itertools 0.11.0", + "log", + "num-complex", + "num-traits", + "rustpython-ast", + "rustpython-compiler-core", + "rustpython-parser-core", +] + +[[package]] +name = "rustpython-common" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d22a5c520662f0ff98d717e2c4e52d8ba35eb1d99ee771dbdba7f09908b75bbb" +dependencies = [ + "ascii", + "bitflags 2.6.0", + "bstr 0.2.17", + "cfg-if", + "itertools 0.11.0", + "libc", + "lock_api", + "malachite-base", + "malachite-bigint", + "malachite-q", + "num-complex", + "num-traits", + "once_cell", + "parking_lot 0.12.3", + "radium", + "rand", + "rustpython-format", + "siphasher", + "volatile", + "widestring", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustpython-compiler" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1c0ad9d5b948970d41b113cfc9ffe2337b10fdd41e0c92a859b9ed33c218efe" +dependencies = [ + "rustpython-codegen", + "rustpython-compiler-core", + "rustpython-parser", +] + +[[package]] +name = "rustpython-compiler-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bd4e0c9fb7b3c70eb27b38d533edc0aa4875ea38cb06e12d76e234d00ef9766" +dependencies = [ + "bitflags 2.6.0", + "itertools 0.11.0", + "lz4_flex", + "malachite-bigint", + "num-complex", + "rustpython-parser-core", +] + +[[package]] +name = "rustpython-derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71c39620497116ce2996bcc679f9be4f47c1e8915c7ff9a9f0324e9584280660" +dependencies = [ + "rustpython-compiler", + "rustpython-derive-impl", + "syn 1.0.109", +] + +[[package]] +name = "rustpython-derive-impl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd18fa95c71a08ecc9cce739a608f5bff38805963152e671b66f5f266f0e58d" +dependencies = [ + "itertools 0.11.0", + "maplit", + "once_cell", + "proc-macro2", + "quote", + "rustpython-compiler-core", + "rustpython-doc", + "rustpython-parser-core", + "syn 1.0.109", + "syn-ext", + "textwrap 0.15.2", +] + +[[package]] +name = "rustpython-doc" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885d19895d9d29656a8a2b33e967a482b92f3d891b4fd923e40849714051bcd" +dependencies = [ + "once_cell", +] + +[[package]] +name = "rustpython-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0389039b132ad8e350552d771270ccd03186985696764bcee2239694e7839942" +dependencies = [ + "bitflags 2.6.0", + "itertools 0.11.0", + "malachite-bigint", + "num-traits", + "rustpython-literal", +] + +[[package]] +name = "rustpython-literal" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8304be3cae00232a1721a911033e55877ca3810215f66798e964a2d8d22281d" +dependencies = [ + "hexf-parse", + "is-macro", + "lexical-parse-float", + "num-traits", + "unic-ucd-category", +] + +[[package]] +name = "rustpython-parser" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "868f724daac0caf9bd36d38caf45819905193a901e8f1c983345a68e18fb2abb" +dependencies = [ + "anyhow", + "is-macro", + "itertools 0.11.0", + "lalrpop-util", + "log", + "malachite-bigint", + "num-traits", + "phf", + "phf_codegen", + "rustc-hash", + "rustpython-ast", + "rustpython-parser-core", + "tiny-keccak", + "unic-emoji-char", + "unic-ucd-ident", + "unicode_names2", +] + +[[package]] +name = "rustpython-parser-core" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b6c12fa273825edc7bccd9a734f0ad5ba4b8a2f4da5ff7efe946f066d0f4ad" +dependencies = [ + "is-macro", + "memchr", + "rustpython-parser-vendored", +] + +[[package]] +name = "rustpython-parser-vendored" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04fcea49a4630a3a5d940f4d514dc4f575ed63c14c3e3ed07146634aed7f67a6" +dependencies = [ + "memchr", + "once_cell", +] + +[[package]] +name = "rustpython-pylib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852d8eb34fce6cbce4eab3b42a87ef996197230168c7fca9d98173057ce27050" +dependencies = [ + "glob", + "rustpython-compiler-core", + "rustpython-derive", +] + +[[package]] +name = "rustpython-sre_engine" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39367be5d48e1e5caaa146904ea8d35fe43928168fbeb5c1ab295a0031b179c6" +dependencies = [ + "bitflags 2.6.0", + "num_enum", + "optional", +] + +[[package]] +name = "rustpython-stdlib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "014cb19d897ca26566dd91104f446c6c396091d99561aa32fcc1e461000192b4" +dependencies = [ + "adler32", + "ahash", + "ascii", + "base64 0.13.1", + "blake2", + "cfg-if", + "crc32fast", + "crossbeam-utils", + "csv-core", + "digest", + "dns-lookup", + "dyn-clone", + "flate2", + "gethostname", + "hex", + "indexmap", + "itertools 0.11.0", + "junction", + "libc", + "libsqlite3-sys", + "libz-sys", + "mac_address", + "malachite-bigint", + "md-5", + "memchr", + "memmap2", + "mt19937", + "nix 0.27.1", + "num-complex", + "num-integer", + "num-traits", + "num_enum", + "once_cell", + "page_size", + "parking_lot 0.12.3", + "paste", + "puruspe", + "rand", + "rand_core", + "rustpython-common", + "rustpython-derive", + "rustpython-vm", + "schannel", + "sha-1", + "sha2", + "sha3", + "socket2", + "system-configuration 0.5.1", + "termios", + "thread_local", + "ucd", + "unic-char-property", + "unic-normal", + "unic-ucd-age", + "unic-ucd-bidi", + "unic-ucd-category", + "unic-ucd-ident", + "unicode-casing", + "unicode_names2", + "uuid", + "widestring", + "winapi", + "windows-sys 0.52.0", + "xml-rs", +] + +[[package]] +name = "rustpython-vm" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2878cc4b5679f35fa762891d812ca7e011ae7cd41b5c532eb0ad13959b522493" +dependencies = [ + "ahash", + "ascii", + "atty", + "bitflags 2.6.0", + "bstr 0.2.17", + "caseless", + "cfg-if", + "chrono", + "crossbeam-utils", + "exitcode", + "getrandom", + "glob", + "half", + "hex", + "indexmap", + "is-macro", + "itertools 0.11.0", + "junction", + "libc", + "log", + "malachite-bigint", + "memchr", + "memoffset", + "nix 0.27.1", + "num-complex", + "num-integer", + "num-traits", + "num_cpus", + "num_enum", + "once_cell", + "optional", + "parking_lot 0.12.3", + "paste", + "rand", + "result-like", + "rustc_version", + "rustpython-ast", + "rustpython-codegen", + "rustpython-common", + "rustpython-compiler", + "rustpython-compiler-core", + "rustpython-derive", + "rustpython-format", + "rustpython-literal", + "rustpython-parser", + "rustpython-parser-core", + "rustpython-sre_engine", + "rustyline", + "schannel", + "static_assertions", + "strum", + "strum_macros", + "thiserror", + "thread_local", + "timsort", + "uname", + "unic-ucd-bidi", + "unic-ucd-category", + "unic-ucd-ident", + "unicode-casing", + "unicode_names2", + "wasm-bindgen", + "which", + "widestring", + "windows 0.52.0", + "windows-sys 0.52.0", + "winreg", +] + [[package]] name = "rustversion" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e819f2bc632f285be6d7cd36e25940d45b2391dd6d9b939e79de557f7014248" +[[package]] +name = "rustyline" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7803e8936da37efd9b6d4478277f4b2b9bb5cdb37a113e8d63222e58da647e63" +dependencies = [ + "bitflags 2.6.0", + "cfg-if", + "clipboard-win", + "fd-lock", + "home", + "libc", + "log", + "memchr", + "nix 0.28.0", + "radix_trie", + "unicode-segmentation", + "unicode-width", + "utf8parse", + "windows-sys 0.52.0", +] + [[package]] name = "ryu" version = "1.0.18" @@ -2777,9 +3810,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" dependencies = [ "windows-sys 0.59.0", ] @@ -2847,14 +3880,14 @@ checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "indexmap", "itoa", @@ -2888,6 +3921,17 @@ dependencies = [ "unsafe-libyaml", ] +[[package]] +name = "sha-1" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5058ada175748e33390e40e872bd0fe59a19f265d0158daa551c5a88a76009c" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sha1" version = "0.10.6" @@ -2920,6 +3964,16 @@ dependencies = [ "cc", ] +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + [[package]] name = "shlex" version = "1.3.0" @@ -3030,12 +4084,43 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + [[package]] name = "strsim" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + [[package]] name = "subtle" version = "2.6.1" @@ -3055,20 +4140,29 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] +[[package]] +name = "syn-ext" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b86cb2b68c5b3c078cac02588bc23f3c04bb828c5d3aedd17980876ec6a7be6" +dependencies = [ + "syn 1.0.109", +] + [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -3081,21 +4175,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", -] - -[[package]] -name = "sysinfo" -version = "0.31.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" -dependencies = [ - "core-foundation-sys", - "libc", - "memchr", - "ntapi", - "rayon", - "windows", + "syn 2.0.89", ] [[package]] @@ -3109,7 +4189,7 @@ dependencies = [ "memchr", "ntapi", "rayon", - "windows", + "windows 0.57.0", ] [[package]] @@ -3117,11 +4197,12 @@ name = "sysinspect" version = "0.2.0" dependencies = [ "chrono", - "clap", + "clap 4.5.21", "colored", "libsysinspect", "log", - "sysinfo 0.31.4", + "openssl", + "sysinfo", ] [[package]] @@ -3129,7 +4210,7 @@ name = "sysmaster" version = "0.1.0" dependencies = [ "actix-web", - "clap", + "clap 4.5.21", "colored", "ed25519-dalek", "futures", @@ -3153,7 +4234,7 @@ dependencies = [ name = "sysminion" version = "0.1.0" dependencies = [ - "clap", + "clap 4.5.21", "colored", "ed25519-dalek", "glob", @@ -3170,11 +4251,22 @@ dependencies = [ "serde", "serde_json", "serde_yaml", - "sysinfo 0.32.0", + "sysinfo", "tokio", "uuid", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys 0.5.0", +] + [[package]] name = "system-configuration" version = "0.6.1" @@ -3183,7 +4275,17 @@ checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ "bitflags 2.6.0", "core-foundation", - "system-configuration-sys", + "system-configuration-sys 0.6.0", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", ] [[package]] @@ -3205,7 +4307,7 @@ dependencies = [ "cfg-if", "fastrand", "once_cell", - "rustix 0.38.40", + "rustix 0.38.41", "windows-sys 0.59.0", ] @@ -3242,6 +4344,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "terminal_size" version = "0.2.6" @@ -3252,6 +4363,30 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "termios" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" +dependencies = [ + "libc", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "textwrap" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" + [[package]] name = "textwrap" version = "0.16.1" @@ -3282,7 +4417,17 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", ] [[package]] @@ -3316,6 +4461,21 @@ dependencies = [ "time-core", ] +[[package]] +name = "timsort" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "639ce8ef6d2ba56be0383a94dd13b92138d58de44c62618303bb798fa92bdc00" + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinystr" version = "0.7.6" @@ -3326,6 +4486,21 @@ dependencies = [ "zerovec", ] +[[package]] +name = "tinyvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "tokio" version = "1.41.1" @@ -3352,7 +4527,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -3389,6 +4564,23 @@ dependencies = [ "tokio", ] +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.3" @@ -3421,18 +4613,43 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "static_assertions", +] + [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4fa6e588762366f1eb4991ce59ad1b93651d0b769dfb4e4d1c5c4b943d1159" + [[package]] name = "ucd-trie" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +[[package]] +name = "uname" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b72f89f0ca32e4db1c04e2a72f5345d59796d4866a1ee0609084569f73683dc8" +dependencies = [ + "libc", +] + [[package]] name = "unic-char-property" version = "0.9.0" @@ -3454,6 +4671,26 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" +[[package]] +name = "unic-emoji-char" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b07221e68897210270a38bde4babb655869637af0f69407f96053a34f76494d" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-normal" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f09d64d33589a94628bc2aeb037f35c2e25f3f049c7348b5aa5580b48e6bba62" +dependencies = [ + "unic-ucd-normal", +] + [[package]] name = "unic-segment" version = "0.9.0" @@ -3463,6 +4700,72 @@ dependencies = [ "unic-ucd-segment", ] +[[package]] +name = "unic-ucd-age" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8cfdfe71af46b871dc6af2c24fcd360e2f3392ee4c5111877f2947f311671c" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-bidi" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1d568b51222484e1f8209ce48caa6b430bf352962b877d592c29ab31fb53d8c" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-category" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8d4591f5fcfe1bd4453baaf803c40e1b1e69ff8455c47620440b46efef91c0" +dependencies = [ + "matches", + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-hangul" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb1dc690e19010e1523edb9713224cba5ef55b54894fe33424439ec9a40c0054" +dependencies = [ + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-ident" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e230a37c0381caa9219d67cf063aa3a375ffed5bf541a452db16e744bdab6987" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-version", +] + +[[package]] +name = "unic-ucd-normal" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86aed873b8202d22b13859dda5fe7c001d271412c31d411fd9b827e030569410" +dependencies = [ + "unic-char-property", + "unic-char-range", + "unic-ucd-hangul", + "unic-ucd-version", +] + [[package]] name = "unic-ucd-segment" version = "0.9.0" @@ -3483,11 +4786,17 @@ dependencies = [ "unic-common", ] +[[package]] +name = "unicode-casing" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "623f59e6af2a98bdafeb93fa277ac8e1e40440973001ca15cf4ae1541cd16d56" + [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "unicode-linebreak" @@ -3495,6 +4804,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" +[[package]] +name = "unicode-normalization" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.12.0" @@ -3507,6 +4825,28 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode_names2" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1673eca9782c84de5f81b82e4109dcfb3611c8ba0d52930ec4a9478f547b2dd" +dependencies = [ + "phf", + "unicode_names2_generator", +] + +[[package]] +name = "unicode_names2_generator" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91e5b84611016120197efd7dc93ef76774f4e084cd73c9fb3ea4a86c570c56e" +dependencies = [ + "getopts", + "log", + "phf_codegen", + "rand", +] + [[package]] name = "unsafe-libyaml" version = "0.2.11" @@ -3554,7 +4894,21 @@ version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ + "atomic", "getrandom", + "rand", + "uuid-macro-internal", +] + +[[package]] +name = "uuid-macro-internal" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b91f57fe13a38d0ce9e28a03463d8d3c2468ed03d75375110ec71d93b449a08" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.89", ] [[package]] @@ -3563,12 +4917,24 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" +[[package]] +name = "volatile" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8e76fae08f03f96e166d2dfda232190638c10e0383841252416f9cfe2ae60e6" + [[package]] name = "walkdir" version = "2.5.0" @@ -3616,7 +4982,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "wasm-bindgen-shared", ] @@ -3650,7 +5016,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3680,9 +5046,15 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.40", + "rustix 0.38.41", ] +[[package]] +name = "widestring" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" + [[package]] name = "winapi" version = "0.3.9" @@ -3714,6 +5086,16 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +dependencies = [ + "windows-core 0.52.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows" version = "0.57.0" @@ -3753,7 +5135,7 @@ checksum = "9107ddc059d5b6fbfbffdfa7a7fe3e22a226def0b2608f72e9d552763d3e1ad7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -3764,7 +5146,7 @@ checksum = "29bee4b38ea3cde66011baa44dba677c432a78593e202392d1e9070cf2a7fca7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -3954,6 +5336,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] + [[package]] name = "write16" version = "1.0.0" @@ -3966,6 +5366,12 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +[[package]] +name = "xml-rs" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af310deaae937e48a26602b730250b4949e125f468f11e6990be3e5304ddd96f" + [[package]] name = "yoke" version = "0.7.4" @@ -3986,7 +5392,7 @@ checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "synstructure", ] @@ -4008,7 +5414,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -4028,7 +5434,7 @@ checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", "synstructure", ] @@ -4049,7 +5455,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] @@ -4071,7 +5477,7 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.89", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index bf2c4787..ea74f0c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,11 +7,12 @@ edition = "2021" [dependencies] chrono = "0.4.38" -clap = { version = "4.5.18", features = ["unstable-styles"] } +clap = { version = "4.5.21", features = ["unstable-styles"] } colored = "2.1.0" libsysinspect = { path = "./libsysinspect" } log = "0.4.22" -sysinfo = { version = "0.31.4", features = ["linux-tmpfs"] } +sysinfo = { version = "0.32.0", features = ["linux-tmpfs"] } +openssl = { version = "0.10", features = ["vendored"] } [workspace] resolver = "2" From a0bfef422435cff2d2453911d6a97f6bd2357383 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sat, 23 Nov 2024 20:48:55 +0100 Subject: [PATCH 03/17] Mute clippy here, as this is used to escape the VM scope when needed --- libsysinspect/src/pylang/pvm.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libsysinspect/src/pylang/pvm.rs b/libsysinspect/src/pylang/pvm.rs index 8c9c869d..d10b4106 100644 --- a/libsysinspect/src/pylang/pvm.rs +++ b/libsysinspect/src/pylang/pvm.rs @@ -62,6 +62,7 @@ impl PyVm { Ok(()) } + #[allow(clippy::arc_with_non_send_sync)] pub fn as_ptr(&self) -> Arc<&Self> { Arc::new(self) } From 931bfca63e4bf593fc049501a0a5ed8f9dcbfebd Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sat, 23 Nov 2024 20:49:07 +0100 Subject: [PATCH 04/17] Remove unused import --- sysminion/src/minion.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysminion/src/minion.rs b/sysminion/src/minion.rs index b986930e..deda3c52 100644 --- a/sysminion/src/minion.rs +++ b/sysminion/src/minion.rs @@ -9,7 +9,7 @@ use libsysinspect::{ rqtypes::RequestType, MasterMessage, MinionMessage, ProtoConversion, }, - pylang::{self, pvm::PyVm}, + pylang::{self}, rsa, traits::{self, systraits::SystemTraits}, util::dataconv, From 88ac353ce698544172e91be91ab20307736d5ef5 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sat, 23 Nov 2024 21:28:24 +0100 Subject: [PATCH 05/17] Add script loader by a namespace --- libsysinspect/src/pylang/pvm.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libsysinspect/src/pylang/pvm.rs b/libsysinspect/src/pylang/pvm.rs index d10b4106..f0cc18fe 100644 --- a/libsysinspect/src/pylang/pvm.rs +++ b/libsysinspect/src/pylang/pvm.rs @@ -3,6 +3,7 @@ Python virtual machine */ use crate::SysinspectError; +use colored::Colorize; use rustpython_vm::compiler::Mode::Exec; use rustpython_vm::VirtualMachine; use rustpython_vm::{Interpreter, Settings}; @@ -38,9 +39,15 @@ impl PyVm { } /// Load main script of a module by a regular namespace - fn load_script(&self, ns: &str) -> String { - // XXX: empty string is also python code! - fs::read_to_string(PathBuf::from(&self.modpath).join(format!("{ns}.py"))).unwrap_or_default() + fn load_script(&self, ns: &str) -> Result { + // XXX: util::get_namespace() ? Because something similar exists for the binaries + let pbuff = PathBuf::from(&self.modpath) + .join(format!("{}.py", ns.replace(".", "/").trim_start_matches("/").trim_end_matches("/"))); + if pbuff.exists() { + return Ok(fs::read_to_string(pbuff).unwrap_or_default()); + } + + Err(SysinspectError::ModuleError(format!("Module at {} was not found", pbuff.to_str().unwrap_or_default().yellow()))) } fn load_pylib(&self, vm: &VirtualMachine) -> Result<(), SysinspectError> { @@ -76,7 +83,7 @@ impl PyVm { } self.load_pylib(vm)?; - let code_obj = match vm.compile(&self.load_script(namespace), Exec, "".to_owned()) { + let code_obj = match vm.compile(&self.load_script(namespace)?, Exec, "".to_owned()) { Ok(src) => src, Err(err) => { return Err(SysinspectError::ModuleError(format!("Unable to compile source code for {namespace}: {err}"))); From b9c1635bca78bbe9e0580e533bc2d2aa39b5a688 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sat, 23 Nov 2024 22:24:03 +0100 Subject: [PATCH 06/17] Add opts and kwargs to the dispatcher function --- libsysinspect/src/pylang/pvm.rs | 62 ++++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/libsysinspect/src/pylang/pvm.rs b/libsysinspect/src/pylang/pvm.rs index f0cc18fe..973f2e4a 100644 --- a/libsysinspect/src/pylang/pvm.rs +++ b/libsysinspect/src/pylang/pvm.rs @@ -4,10 +4,18 @@ Python virtual machine use crate::SysinspectError; use colored::Colorize; -use rustpython_vm::compiler::Mode::Exec; -use rustpython_vm::VirtualMachine; +use rustpython_vm::{ + builtins::PyStr, + compiler::Mode::Exec, + convert::IntoObject, + function::{FuncArgs, KwArgs}, + AsObject, PyRef, PyResult, +}; use rustpython_vm::{Interpreter, Settings}; +use rustpython_vm::{PyObjectRef, VirtualMachine}; +use serde_json::{json, Value}; use std::{ + collections::HashMap, fs, path::{Path, PathBuf}, sync::Arc, @@ -74,8 +82,39 @@ impl PyVm { Arc::new(self) } + fn from_json(&self, vm: &VirtualMachine, value: Value) -> PyResult { + Ok(match value { + Value::Null => vm.ctx.none(), + Value::Bool(b) => vm.ctx.new_bool(b).into(), + Value::Number(num) => { + if let Some(i) = num.as_i64() { + vm.ctx.new_int(i).into() + } else if let Some(f) = num.as_f64() { + vm.ctx.new_float(f).into() + } else { + vm.ctx.none() + } + } + Value::String(s) => vm.ctx.new_str(s).into(), + Value::Array(arr) => vm + .ctx + .new_list(arr.into_iter().map(|item| self.from_json(vm, item).expect("Failed to convert JSON")).collect()) + .into(), + Value::Object(obj) => { + let py_dict = vm.ctx.new_dict(); + for (key, val) in obj { + let py_val = self.from_json(vm, val)?; + py_dict.set_item(key.as_str(), py_val, vm)?; + } + py_dict.into() + } + }) + } + /// Call a light Python module - pub fn call(self: Arc<&Self>, namespace: &str) -> Result<(), SysinspectError> { + pub fn call( + self: Arc<&Self>, namespace: &str, opts: Option>, args: Option>, + ) -> Result<(), SysinspectError> { self.itp.enter(|vm| { let lpth = Path::new(&self.libpath); if !lpth.exists() || !lpth.is_dir() { @@ -97,8 +136,23 @@ impl PyVm { return Err(SysinspectError::ModuleError(format!("Error running \"{namespace}\" Python module: {:?}", err))); } + // opts/args + let py_opts = opts.into_iter().map(|val| self.from_json(vm, json!(val)).unwrap()).collect::>(); + let py_args = vm.ctx.new_dict(); + for (key, val) in args.unwrap_or_default() { + let py_key = vm.ctx.new_str(key); + let py_val = self.from_json(vm, val).unwrap(); + py_args.set_item(py_key.as_object(), py_val, vm).unwrap(); + } + + let kwargs: KwArgs = py_args + .into_iter() + .map(|(k, v)| (k.downcast::().unwrap().as_str().to_string(), v)) + .collect(); + let farg = FuncArgs::new(py_opts, kwargs); + let dispatcher_function = scope.globals.get_item("dispatch", vm).expect("Failed to find `dispatch` function"); - let result = match dispatcher_function.call((), vm) { + let result = match dispatcher_function.call(farg, vm) { Ok(r) => r, Err(err) => { vm.print_exception(err); From 6489d14a7e698243d0e48e0e97ddea7bea908a67 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sat, 23 Nov 2024 22:25:28 +0100 Subject: [PATCH 07/17] Lintfix. Sort of. --- libsysinspect/src/pylang/pvm.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libsysinspect/src/pylang/pvm.rs b/libsysinspect/src/pylang/pvm.rs index 973f2e4a..2f75f43b 100644 --- a/libsysinspect/src/pylang/pvm.rs +++ b/libsysinspect/src/pylang/pvm.rs @@ -5,11 +5,9 @@ Python virtual machine use crate::SysinspectError; use colored::Colorize; use rustpython_vm::{ - builtins::PyStr, compiler::Mode::Exec, - convert::IntoObject, function::{FuncArgs, KwArgs}, - AsObject, PyRef, PyResult, + AsObject, PyResult, }; use rustpython_vm::{Interpreter, Settings}; use rustpython_vm::{PyObjectRef, VirtualMachine}; @@ -82,6 +80,8 @@ impl PyVm { Arc::new(self) } + #[allow(clippy::wrong_self_convention)] + #[allow(clippy::only_used_in_recursion)] fn from_json(&self, vm: &VirtualMachine, value: Value) -> PyResult { Ok(match value { Value::Null => vm.ctx.none(), From 88f5239c66315f1d7249bdf1de8f52bde15beee9 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 18:52:18 +0100 Subject: [PATCH 08/17] Fix imports --- sysminion/src/minion.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sysminion/src/minion.rs b/sysminion/src/minion.rs index deda3c52..03192f64 100644 --- a/sysminion/src/minion.rs +++ b/sysminion/src/minion.rs @@ -16,7 +16,8 @@ use libsysinspect::{ SysinspectError, }; use once_cell::sync::{Lazy, OnceCell}; -use std::{fs, path::PathBuf, sync::Arc, vec}; +use serde_json::json; +use std::{collections::HashMap, fs, path::PathBuf, sync::Arc, vec}; use tokio::io::AsyncReadExt; use tokio::net::{tcp::OwnedReadHalf, TcpStream}; use tokio::sync::Mutex; From 9c75cfe66f47736f132b834f31d153d46190be45 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 18:53:21 +0100 Subject: [PATCH 09/17] Add runner for Python modules --- libsysinspect/src/intp/actproc/modfinder.rs | 61 ++++++++++++++-- libsysinspect/src/intp/conf.rs | 4 +- libsysinspect/src/pylang/mod.rs | 2 + libsysinspect/src/pylang/pvm.rs | 78 +++++++++++++++------ 4 files changed, 116 insertions(+), 29 deletions(-) diff --git a/libsysinspect/src/intp/actproc/modfinder.rs b/libsysinspect/src/intp/actproc/modfinder.rs index 86b53dcf..4d899a03 100644 --- a/libsysinspect/src/intp/actproc/modfinder.rs +++ b/libsysinspect/src/intp/actproc/modfinder.rs @@ -5,10 +5,13 @@ use crate::{ constraints::{Constraint, ConstraintKind}, functions, }, + pylang, util::dataconv, SysinspectError, }; +use colored::Colorize; use core::str; +use pest::pratt_parser::Op; use serde::{Deserialize, Serialize}; use serde_json::json; use std::{ @@ -38,7 +41,7 @@ pub struct ModCall { constraints: Vec, // Module params - args: HashMap, + args: HashMap, // XXX: Should be String/Value, not String/String! opts: Vec, } @@ -201,12 +204,58 @@ impl ModCall { cret } + /// Run the module pub fn run(&self) -> Result, SysinspectError> { - // Event reactor: - // - Configurable - // - Chain plugins/functions - // - Event reactions - // - Should probably store all the result in a common structure + let pymod = self + .module + .parent() + .unwrap() + .join(format!("{}.py", self.module.file_name().unwrap_or_default().to_str().unwrap_or_default())); + if pymod.exists() && self.module.exists() { + return Err(SysinspectError::ModuleError(format!( + "Module names must be unique, however both \"{}\" and \"{}\" do exist. Please rename one of these, update your model and continue.", + pymod.file_name().unwrap_or_default().to_str().unwrap_or_default().yellow(), + self.module.file_name().unwrap_or_default().to_str().unwrap_or_default().yellow() + ))); + } else if pymod.exists() { + self.run_python_module(pymod) + } else if self.module.exists() { + self.run_native_module() + } else { + Err(SysinspectError::ModuleError(format!( + "No such module under the namespace: {}", + self.module.file_name().unwrap_or_default().to_str().unwrap_or_default() + ))) + } + } + + /// Runs python script module + fn run_python_module(&self, pymod: PathBuf) -> Result, SysinspectError> { + log::debug!("Calling Python module: {}", pymod.as_os_str().to_str().unwrap_or_default()); + + let opts = self.opts.iter().map(|v| json!(v)).collect::>(); + let args = self.args.iter().map(|(k, v)| (k.to_string(), json!(v))).collect::>(); + + match pylang::pvm::PyVm::new(None, None).as_ptr().call(pymod, Some(opts), Some(args)) { + Ok(out) => { + return match serde_json::from_str::(&out) { + Ok(r) => Ok(Some(ActionResponse::new( + self.eid.to_owned(), + self.aid.to_owned(), + self.state.to_owned(), + r.clone(), + self.eval_constraints(&r), + ))), + Err(e) => Err(SysinspectError::ModuleError(format!("JSON error: {e}"))), + }; + } + Err(err) => return Err(err), + }; + } + + /// Runs native external module + fn run_native_module(&self) -> Result, SysinspectError> { + log::debug!("Calling native module: {}", self.module.as_os_str().to_str().unwrap_or_default()); match Command::new(&self.module).stdin(Stdio::piped()).stdout(Stdio::piped()).spawn() { Ok(mut p) => { // Send options diff --git a/libsysinspect/src/intp/conf.rs b/libsysinspect/src/intp/conf.rs index 85e04ca7..bd15019f 100644 --- a/libsysinspect/src/intp/conf.rs +++ b/libsysinspect/src/intp/conf.rs @@ -84,7 +84,7 @@ impl Config { Err(SysinspectError::ModelDSLError("Unable to parse configuration".to_string())) } - /// Get module from the namespace + /// Get module (or Python module) from the namespace pub fn get_module(&self, namespace: &str) -> Result { // Fool-proof cleanup, likely a bad idea let modpath = &self.modules.to_owned().unwrap_or(PathBuf::from(DEFAULT_MODULES_ROOT)).join( @@ -99,7 +99,7 @@ impl Config { ); if !modpath.exists() { - return Err(SysinspectError::ModuleError(format!("Module \"{}\" was not found at {:?}", namespace, modpath))); + //return Err(SysinspectError::ModuleError(format!("Module \"{}\" was not found at {:?}", namespace, modpath))); } Ok(modpath.to_owned()) diff --git a/libsysinspect/src/pylang/mod.rs b/libsysinspect/src/pylang/mod.rs index 0fb2cf45..c39c38bd 100644 --- a/libsysinspect/src/pylang/mod.rs +++ b/libsysinspect/src/pylang/mod.rs @@ -1,2 +1,4 @@ pub mod pvm; pub mod pylib; + +pub static PY_MAIN_FUNC: &str = "main"; diff --git a/libsysinspect/src/pylang/pvm.rs b/libsysinspect/src/pylang/pvm.rs index 2f75f43b..82ef126c 100644 --- a/libsysinspect/src/pylang/pvm.rs +++ b/libsysinspect/src/pylang/pvm.rs @@ -2,7 +2,7 @@ Python virtual machine */ -use crate::SysinspectError; +use crate::{pylang::PY_MAIN_FUNC, SysinspectError}; use colored::Colorize; use rustpython_vm::{ compiler::Mode::Exec, @@ -45,15 +45,19 @@ impl PyVm { } /// Load main script of a module by a regular namespace - fn load_script(&self, ns: &str) -> Result { + fn load_by_ns(&self, ns: &str) -> Result { // XXX: util::get_namespace() ? Because something similar exists for the binaries let pbuff = PathBuf::from(&self.modpath) .join(format!("{}.py", ns.replace(".", "/").trim_start_matches("/").trim_end_matches("/"))); - if pbuff.exists() { - return Ok(fs::read_to_string(pbuff).unwrap_or_default()); + self.load_by_path(&pbuff) + } + + fn load_by_path(&self, pth: &PathBuf) -> Result { + if pth.exists() { + return Ok(fs::read_to_string(pth).unwrap_or_default()); } - Err(SysinspectError::ModuleError(format!("Module at {} was not found", pbuff.to_str().unwrap_or_default().yellow()))) + Err(SysinspectError::ModuleError(format!("Module at {} was not found", pth.to_str().unwrap_or_default().yellow()))) } fn load_pylib(&self, vm: &VirtualMachine) -> Result<(), SysinspectError> { @@ -112,9 +116,9 @@ impl PyVm { } /// Call a light Python module - pub fn call( - self: Arc<&Self>, namespace: &str, opts: Option>, args: Option>, - ) -> Result<(), SysinspectError> { + pub fn call>( + self: Arc<&Self>, namespace: T, opts: Option>, args: Option>, + ) -> Result { self.itp.enter(|vm| { let lpth = Path::new(&self.libpath); if !lpth.exists() || !lpth.is_dir() { @@ -122,10 +126,21 @@ impl PyVm { } self.load_pylib(vm)?; - let code_obj = match vm.compile(&self.load_script(namespace)?, Exec, "".to_owned()) { + // Get script source + let src: String; + if namespace.as_ref().is_absolute() { + src = self.load_by_path(&namespace.as_ref().to_path_buf())?; + } else { + src = self.load_by_ns(namespace.as_ref().to_str().unwrap_or_default())?; + } + + let code_obj = match vm.compile(&src, Exec, "".to_owned()) { Ok(src) => src, Err(err) => { - return Err(SysinspectError::ModuleError(format!("Unable to compile source code for {namespace}: {err}"))); + return Err(SysinspectError::ModuleError(format!( + "Unable to compile source code for {}: {err}", + namespace.as_ref().to_str().unwrap_or_default() + ))); } }; @@ -133,7 +148,13 @@ impl PyVm { let scope = vm.new_scope_with_builtins(); if let Err(err) = vm.run_code_obj(code_obj, scope.clone()) { - return Err(SysinspectError::ModuleError(format!("Error running \"{namespace}\" Python module: {:?}", err))); + let mut buff = String::new(); + _ = vm.write_exception(&mut buff, &err); + return Err(SysinspectError::ModuleError(format!( + "Error running Python function \"{}\": {}", + namespace.as_ref().to_str().unwrap_or_default(), + buff.trim() + ))); } // opts/args @@ -149,23 +170,38 @@ impl PyVm { .into_iter() .map(|(k, v)| (k.downcast::().unwrap().as_str().to_string(), v)) .collect(); - let farg = FuncArgs::new(py_opts, kwargs); - let dispatcher_function = scope.globals.get_item("dispatch", vm).expect("Failed to find `dispatch` function"); - let result = match dispatcher_function.call(farg, vm) { + let fref = match scope.globals.get_item(PY_MAIN_FUNC, vm) { + Ok(fref) => fref, + Err(err) => { + let mut buff = String::new(); + _ = vm.write_exception(&mut buff, &err); + return Err(SysinspectError::ModuleError(format!( + "Error running Python function \"{}\": {}", + namespace.as_ref().to_str().unwrap_or_default(), + buff.trim() + ))); + } + }; + + let r = match fref.call(FuncArgs::new(py_opts, kwargs), vm) { Ok(r) => r, Err(err) => { - vm.print_exception(err); - return Ok(()); + let mut buff = String::new(); + _ = vm.write_exception(&mut buff, &err); + return Err(SysinspectError::ModuleError(format!( + "Error running \"{}\" Python module:\n{}", + namespace.as_ref().to_str().unwrap_or_default(), + buff.trim() + ))); } }; - if let Ok(py_str) = result.downcast::() { - println!("{}", py_str.as_str()); - } else { - println!("error: no string return"); + if let Ok(py_str) = r.downcast::() { + return Ok(py_str.as_str().to_string()); } - Ok(()) + + Err(SysinspectError::ModuleError("Python script does not returns a JSON string".to_string())) }) } } From cabc0d74457ae1cf3a53fa079d6f925e67a8db73 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 18:57:24 +0100 Subject: [PATCH 10/17] Refactor statements --- libsysinspect/src/intp/actproc/modfinder.rs | 31 ++++++++++----------- libsysinspect/src/pylang/pvm.rs | 9 +++--- sysminion/src/minion.rs | 4 +-- 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/libsysinspect/src/intp/actproc/modfinder.rs b/libsysinspect/src/intp/actproc/modfinder.rs index 4d899a03..22ff77d3 100644 --- a/libsysinspect/src/intp/actproc/modfinder.rs +++ b/libsysinspect/src/intp/actproc/modfinder.rs @@ -11,7 +11,6 @@ use crate::{ }; use colored::Colorize; use core::str; -use pest::pratt_parser::Op; use serde::{Deserialize, Serialize}; use serde_json::json; use std::{ @@ -212,11 +211,11 @@ impl ModCall { .unwrap() .join(format!("{}.py", self.module.file_name().unwrap_or_default().to_str().unwrap_or_default())); if pymod.exists() && self.module.exists() { - return Err(SysinspectError::ModuleError(format!( + Err(SysinspectError::ModuleError(format!( "Module names must be unique, however both \"{}\" and \"{}\" do exist. Please rename one of these, update your model and continue.", pymod.file_name().unwrap_or_default().to_str().unwrap_or_default().yellow(), self.module.file_name().unwrap_or_default().to_str().unwrap_or_default().yellow() - ))); + ))) } else if pymod.exists() { self.run_python_module(pymod) } else if self.module.exists() { @@ -237,20 +236,18 @@ impl ModCall { let args = self.args.iter().map(|(k, v)| (k.to_string(), json!(v))).collect::>(); match pylang::pvm::PyVm::new(None, None).as_ptr().call(pymod, Some(opts), Some(args)) { - Ok(out) => { - return match serde_json::from_str::(&out) { - Ok(r) => Ok(Some(ActionResponse::new( - self.eid.to_owned(), - self.aid.to_owned(), - self.state.to_owned(), - r.clone(), - self.eval_constraints(&r), - ))), - Err(e) => Err(SysinspectError::ModuleError(format!("JSON error: {e}"))), - }; - } - Err(err) => return Err(err), - }; + Ok(out) => match serde_json::from_str::(&out) { + Ok(r) => Ok(Some(ActionResponse::new( + self.eid.to_owned(), + self.aid.to_owned(), + self.state.to_owned(), + r.clone(), + self.eval_constraints(&r), + ))), + Err(e) => Err(SysinspectError::ModuleError(format!("JSON error: {e}"))), + }, + Err(err) => Err(err), + } } /// Runs native external module diff --git a/libsysinspect/src/pylang/pvm.rs b/libsysinspect/src/pylang/pvm.rs index 82ef126c..db1568cb 100644 --- a/libsysinspect/src/pylang/pvm.rs +++ b/libsysinspect/src/pylang/pvm.rs @@ -127,12 +127,11 @@ impl PyVm { self.load_pylib(vm)?; // Get script source - let src: String; - if namespace.as_ref().is_absolute() { - src = self.load_by_path(&namespace.as_ref().to_path_buf())?; + let src = if namespace.as_ref().is_absolute() { + self.load_by_path(&namespace.as_ref().to_path_buf())? } else { - src = self.load_by_ns(namespace.as_ref().to_str().unwrap_or_default())?; - } + self.load_by_ns(namespace.as_ref().to_str().unwrap_or_default())? + }; let code_obj = match vm.compile(&src, Exec, "".to_owned()) { Ok(src) => src, diff --git a/sysminion/src/minion.rs b/sysminion/src/minion.rs index 03192f64..ace97e61 100644 --- a/sysminion/src/minion.rs +++ b/sysminion/src/minion.rs @@ -9,15 +9,13 @@ use libsysinspect::{ rqtypes::RequestType, MasterMessage, MinionMessage, ProtoConversion, }, - pylang::{self}, rsa, traits::{self, systraits::SystemTraits}, util::dataconv, SysinspectError, }; use once_cell::sync::{Lazy, OnceCell}; -use serde_json::json; -use std::{collections::HashMap, fs, path::PathBuf, sync::Arc, vec}; +use std::{fs, path::PathBuf, sync::Arc, vec}; use tokio::io::AsyncReadExt; use tokio::net::{tcp::OwnedReadHalf, TcpStream}; use tokio::sync::Mutex; From 747c210467c4d78f027e8404d856dfa93a69e91a Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 19:25:38 +0100 Subject: [PATCH 11/17] Move module collision check to the config. Make config Python-aware --- libsysinspect/src/intp/actproc/modfinder.rs | 28 +++++---------------- libsysinspect/src/intp/conf.rs | 25 ++++++++++++++++-- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/libsysinspect/src/intp/actproc/modfinder.rs b/libsysinspect/src/intp/actproc/modfinder.rs index 22ff77d3..1b3d657b 100644 --- a/libsysinspect/src/intp/actproc/modfinder.rs +++ b/libsysinspect/src/intp/actproc/modfinder.rs @@ -205,37 +205,21 @@ impl ModCall { /// Run the module pub fn run(&self) -> Result, SysinspectError> { - let pymod = self - .module - .parent() - .unwrap() - .join(format!("{}.py", self.module.file_name().unwrap_or_default().to_str().unwrap_or_default())); - if pymod.exists() && self.module.exists() { - Err(SysinspectError::ModuleError(format!( - "Module names must be unique, however both \"{}\" and \"{}\" do exist. Please rename one of these, update your model and continue.", - pymod.file_name().unwrap_or_default().to_str().unwrap_or_default().yellow(), - self.module.file_name().unwrap_or_default().to_str().unwrap_or_default().yellow() - ))) - } else if pymod.exists() { - self.run_python_module(pymod) - } else if self.module.exists() { - self.run_native_module() + if self.module.extension().unwrap_or_default().to_str().unwrap_or_default().eq("py") { + self.run_python_module() } else { - Err(SysinspectError::ModuleError(format!( - "No such module under the namespace: {}", - self.module.file_name().unwrap_or_default().to_str().unwrap_or_default() - ))) + self.run_native_module() } } /// Runs python script module - fn run_python_module(&self, pymod: PathBuf) -> Result, SysinspectError> { - log::debug!("Calling Python module: {}", pymod.as_os_str().to_str().unwrap_or_default()); + fn run_python_module(&self) -> Result, SysinspectError> { + log::debug!("Calling Python module: {}", self.module.as_os_str().to_str().unwrap_or_default()); let opts = self.opts.iter().map(|v| json!(v)).collect::>(); let args = self.args.iter().map(|(k, v)| (k.to_string(), json!(v))).collect::>(); - match pylang::pvm::PyVm::new(None, None).as_ptr().call(pymod, Some(opts), Some(args)) { + match pylang::pvm::PyVm::new(None, None).as_ptr().call(&self.module, Some(opts), Some(args)) { Ok(out) => match serde_json::from_str::(&out) { Ok(r) => Ok(Some(ActionResponse::new( self.eid.to_owned(), diff --git a/libsysinspect/src/intp/conf.rs b/libsysinspect/src/intp/conf.rs index bd15019f..7918bf0c 100644 --- a/libsysinspect/src/intp/conf.rs +++ b/libsysinspect/src/intp/conf.rs @@ -87,7 +87,7 @@ impl Config { /// Get module (or Python module) from the namespace pub fn get_module(&self, namespace: &str) -> Result { // Fool-proof cleanup, likely a bad idea - let modpath = &self.modules.to_owned().unwrap_or(PathBuf::from(DEFAULT_MODULES_ROOT)).join( + let mut modpath = self.modules.to_owned().unwrap_or(PathBuf::from(DEFAULT_MODULES_ROOT)).join( namespace .trim_start_matches('.') .trim_end_matches('.') @@ -98,8 +98,29 @@ impl Config { .join("/"), ); + let pymodpath = modpath + .parent() + .unwrap() + .join(format!("{}.py", modpath.file_name().unwrap().to_os_string().to_str().unwrap_or_default())); + + // Collision + if pymodpath.exists() && modpath.exists() { + return Err(SysinspectError::ModuleError(format!( + "Module names must be unique, however both \"{}\" and \"{}\" do exist. Please rename one of these, update your model and continue.", + pymodpath.file_name().unwrap_or_default().to_str().unwrap_or_default(), + modpath.file_name().unwrap_or_default().to_str().unwrap_or_default() + ))); + } + if !modpath.exists() { - //return Err(SysinspectError::ModuleError(format!("Module \"{}\" was not found at {:?}", namespace, modpath))); + if !pymodpath.exists() { + return Err(SysinspectError::ModuleError(format!( + "No module \"{}\" was not found as \"{:?}\"", + namespace, modpath + ))); + } else { + modpath = pymodpath; + } } Ok(modpath.to_owned()) From 77b1a7c88217489b85737291170d476e14879047 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 19:26:40 +0100 Subject: [PATCH 12/17] Remove unused import --- libsysinspect/src/intp/actproc/modfinder.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/libsysinspect/src/intp/actproc/modfinder.rs b/libsysinspect/src/intp/actproc/modfinder.rs index 1b3d657b..bbe54bcb 100644 --- a/libsysinspect/src/intp/actproc/modfinder.rs +++ b/libsysinspect/src/intp/actproc/modfinder.rs @@ -9,7 +9,6 @@ use crate::{ util::dataconv, SysinspectError, }; -use colored::Colorize; use core::str; use serde::{Deserialize, Serialize}; use serde_json::json; From 21e140c2aa1fff7b6524f99b7f5982e8df8ee0ed Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 21:29:06 +0100 Subject: [PATCH 13/17] An attempt to implement a core class, exporting minion traits. The problem with this that it *always* creates a new instance of the traits, consequently calling everything. This slows down process by an order of magnitude and therefore for now it is disabled. There must be a better approach instead. --- libsysinspect/src/pylang/pvm.rs | 6 +- libsysinspect/src/pylang/pylib/mod.rs | 1 + libsysinspect/src/pylang/pylib/pysystem.rs | 77 ++++++++++++++++++++++ 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 libsysinspect/src/pylang/pylib/pysystem.rs diff --git a/libsysinspect/src/pylang/pvm.rs b/libsysinspect/src/pylang/pvm.rs index db1568cb..77bea680 100644 --- a/libsysinspect/src/pylang/pvm.rs +++ b/libsysinspect/src/pylang/pvm.rs @@ -19,6 +19,8 @@ use std::{ sync::Arc, }; +// use super::pylib::pysystem::syscore; + pub struct PyVm { itp: Interpreter, libpath: String, @@ -34,11 +36,9 @@ impl PyVm { let itp = rustpython::InterpreterConfig::new() .init_stdlib() .settings(cfg) - /* .init_hook(Box::new(|vm| { - vm.add_native_module("rust_py_module".to_owned(), Box::new(rust_py_module::make_module)); + //vm.add_native_module("syscore".to_owned(), Box::new(syscore::make_module)); })) - */ .interpreter(); Self { itp, libpath: libpath.to_string(), modpath: modpath.unwrap_or("/usr/share/sysinspect/modules/".to_string()) } diff --git a/libsysinspect/src/pylang/pylib/mod.rs b/libsysinspect/src/pylang/pylib/mod.rs index e69de29b..5d17177b 100644 --- a/libsysinspect/src/pylang/pylib/mod.rs +++ b/libsysinspect/src/pylang/pylib/mod.rs @@ -0,0 +1 @@ +pub mod pysystem; diff --git a/libsysinspect/src/pylang/pylib/pysystem.rs b/libsysinspect/src/pylang/pylib/pysystem.rs new file mode 100644 index 00000000..200e3f99 --- /dev/null +++ b/libsysinspect/src/pylang/pylib/pysystem.rs @@ -0,0 +1,77 @@ +/* +Python module, exported to the Python realm + */ + +use rustpython_vm::pymodule; + +#[pymodule] +pub mod syscore { + use crate::{cfg::mmconf::MinionConfig, traits::systraits::SystemTraits, util::dataconv}; + use rustpython_vm::PyResult; + use rustpython_vm::{builtins::PyList, convert::ToPyObject, pyclass, PyObjectRef, PyPayload, VirtualMachine}; + use std::path::PathBuf; + + #[derive(Debug, Clone)] + struct StrVec(Vec); + impl ToPyObject for StrVec { + fn to_pyobject(self, vm: &VirtualMachine) -> PyObjectRef { + let l = self.0.into_iter().map(|s| vm.new_pyobj(s)).collect(); + PyList::new_ref(l, vm.as_ref()).to_pyobject(vm) + } + } + + #[pyattr] + #[pyclass(module = "syscore", name = "__MinionTraits")] + #[derive(Debug, PyPayload, Default)] + pub struct MinionTraits { + traits: Option, + } + + #[pyclass] + impl MinionTraits { + fn new() -> MinionTraits { + // This sucks big time. It always initialises traits for every script call + let cfg = match MinionConfig::new(PathBuf::from("/etc/sysinspect/sysinspect.conf")) { + Ok(c) => Some(c), + Err(err) => { + log::debug!("Error initialising traits: {err}"); + None + } + }; + + if let Some(cfg) = cfg { + return MinionTraits { traits: Some(SystemTraits::new(cfg)) }; + } + + MinionTraits { ..Default::default() } + } + + #[pymethod] + fn get(&self, key: String) -> String { + if self.traits.is_some() { + return dataconv::to_string(self.traits.clone().and_then(|v| v.get(&key))).unwrap_or_default(); + } + "".to_string() + } + + #[pymethod] + fn list(&self) -> StrVec { + let mut out: StrVec = StrVec(vec![]); + if let Some(traits) = self.traits.clone() { + for item in traits.items() { + out.0.push(item); + } + } + + out + } + } + + #[pyfunction] + #[allow(non_snake_case)] + /// This is a mimic of "MinionTraits" Python class, + /// which needs to be called for the init. + fn MinionTraits() -> PyResult { + Ok(MinionTraits::new()) + } +} From 1e3a56b389c69e4b6c690a782f9297b9027edd64 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 21:29:34 +0100 Subject: [PATCH 14/17] Update a makefile --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0f52c3cb..4933be4c 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ devel-musl: mv target/x86_64-unknown-linux-musl/debug/run target/x86_64-unknown-linux-musl/debug/sys/ musl: - cargo build --release + cargo build --release --workspace --target x86_64-unknown-linux-musl cargo build -p proc -p net -p run --release --target x86_64-unknown-linux-musl rm -rf target/x86_64-unknown-linux-musl/release/sys mkdir -p target/x86_64-unknown-linux-musl/release/sys @@ -34,8 +34,13 @@ devel: mv target/debug/run target/debug/sys/ build: - cargo build --release + cargo build --release --workspace cargo build -p proc -p net -p run --release + rm -rf target/release/sys/ + mkdir -p target/release/sys/ + mv target/release/proc target/release/sys/ + mv target/release/net target/release/sys/ + mv target/release/run target/release/sys/ # Move plugin binaries rm -rf target/release/sys From aebd0d4d623d60ea9065bb6f9ec5e6cc34369048 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 21:31:40 +0100 Subject: [PATCH 15/17] Add SysinspectReturn structure. Probably should be implemented in the core instead --- python/lib/sysinspect.py | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 python/lib/sysinspect.py diff --git a/python/lib/sysinspect.py b/python/lib/sysinspect.py new file mode 100644 index 00000000..15695425 --- /dev/null +++ b/python/lib/sysinspect.py @@ -0,0 +1,66 @@ +# Sysinspect Objects +# Author: Bo Maryniuk + +from __future__ import annotations +from typing import Any +import json + + +class SysinspectReturn: + """ + Return structure for the Sysinspect module. + """ + + def __init__(self, retcode: int = 0, message: str = ""): + """ + Constructor. + """ + self.retcode = retcode + self.warnings = [] + self.message = message + self.data = {} + + def set_retcode(self, retcode: int = 0) -> SysinspectReturn: + """ + Set return code + """ + self.retcode = retcode + return self + + def set_message(self, message: str) -> SysinspectReturn: + """ + Set message + """ + self.message = message + return self + + def add_warning(self, warning: str) -> SysinspectReturn: + """ + Add a warning message + """ + self.warnings.append(warning) + return self + + def add_data(self, data: dict[str, Any]) -> SysinspectReturn: + """ + Add data structure + """ + if data: + self.data.update(data) + return self + + + def __str__(self): + ret:dict = { + "retcode": self.retcode, + "message": self.message, + } + + if self.warnings: + ret["warning"] = self.warnings + + if self.data: + ret["data"] = self.data + + return json.dumps(ret) + From 9e3cc1e2bc9d554cc84d330b6074229af7d054d6 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 21:32:17 +0100 Subject: [PATCH 16/17] Add python minimal plugin --- python/modules/file/conf.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 python/modules/file/conf.py diff --git a/python/modules/file/conf.py b/python/modules/file/conf.py new file mode 100644 index 00000000..bb1a4e36 --- /dev/null +++ b/python/modules/file/conf.py @@ -0,0 +1,16 @@ +from sysinspect import SysinspectReturn +# from syscore import MinionTraits + +def main(*args, **kw) -> str: + """ + Main function to dispatch the module. + """ + + # t = MinionTraits() + # print(t.get("hardware.cpu.brand")) + + + # Expand SysinspectReturn with your data. + # See lib/sysinspect.py for more details. + + return str(SysinspectReturn().add_data({"hello": "world!"})) From 033c84a9158c7eab76995aa52e9021487f4b9815 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Sun, 24 Nov 2024 21:32:35 +0100 Subject: [PATCH 17/17] Add another action, calling python module (if installed) --- examples/models/inherited/evt.cfg | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/models/inherited/evt.cfg b/examples/models/inherited/evt.cfg index 0f49bcd5..77a36250 100644 --- a/examples/models/inherited/evt.cfg +++ b/examples/models/inherited/evt.cfg @@ -5,3 +5,15 @@ constraints: interfaces: - fact: if-up.virbr1.port equals: static(entities.addresses.claims.interfaces.virtual.port) + +actions: + python-module-tests: + descr: Check if python module works at all + module: file.conf + bind: + - addresses + + state: + interfaces: + opts: + args: