Conversation
…and hostname of agent
…. High priority to remove package for smaller bundle
…dmin or not. cross os compatible.
…ripting error type
…n enum due to rhais lack of support for enums
…ing of the os family
…brary. Unix systems have extern sys calls, but this is for simplicity
…t on the exact commands run per os family
…reebsd or openbsd
…n the whole Result<bool, Box<EvalAltResult>>
we now provide the user a list of return types for which they can match
Owner
|
I've gone ahead and cleaned up some of the documentation. Aside from that, everything looks great! LGTM 🔥 |
coal-rock
approved these changes
May 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add system library and custom error handling.
Added functions to
talaria/src/stdlib/sys.rs:os_name -> String: the name of the agents OSos_family -> String: the name of the agents familyusername -> Result<String, Box<EvalAltResult>>: the username of the agenthostname -> Result<String, Box<EvalAltResult>>: the host name of the agentis_admin -> bool: checks if hermes has admin permsreboot -> Result<(), <Box<EvalAltResult>>: reboot agentshutdown -> Result<(), Box<EvalAltRestult>>: shutdown agentuptime -> Result<f32, Box<EvalAltResult>>: get uptime of agent (unix only)cpu_architecture -> String: get cpu archis_windows -> boolean: is agent os Windowsis_linux -> boolean: is agent os Linuxis_macos -> boolean: is agent os MacOsis_bsd -> boolean: is agent os BSDCustom Errors
(@coal-rock implemented)
Rhai does not support enums, so we had to implement our own means of error handling through the standard library.
In
talaria/src/stdlib/error.rslives the enum Error where we can store our custom error types. We can retrieve the error type from a returned library function viaget_error_nameand the message inside viaget_error_msg. New errors are to be added to this enum with an associatedStringvalue.To import
talaria/src/stdlib/error.rsfor use in the standard library:use crate::stdlib::error::error::Error as script_error;Notes
All functions are untested on Windows and BSD.