Skip to content

Add sys library to Talaria#28

Merged
coal-rock merged 36 commits intomainfrom
re/talaria-std-sys-lib
May 8, 2025
Merged

Add sys library to Talaria#28
coal-rock merged 36 commits intomainfrom
re/talaria-std-sys-lib

Conversation

@engelhartrueben
Copy link
Copy Markdown
Collaborator

@engelhartrueben engelhartrueben commented May 5, 2025

Add system library and custom error handling.


Added functions to talaria/src/stdlib/sys.rs:

os_name -> String : the name of the agents OS
os_family -> String : the name of the agents family
username -> Result<String, Box<EvalAltResult>> : the username of the agent
hostname -> Result<String, Box<EvalAltResult>> : the host name of the agent
is_admin -> bool : checks if hermes has admin perms
reboot -> Result<(), <Box<EvalAltResult>> : reboot agent
shutdown -> Result<(), Box<EvalAltRestult>> : shutdown agent
uptime -> Result<f32, Box<EvalAltResult>> : get uptime of agent (unix only)
cpu_architecture -> String : get cpu arch
is_windows -> boolean : is agent os Windows
is_linux -> boolean : is agent os Linux
is_macos -> boolean : is agent os MacOs
is_bsd -> boolean : is agent os BSD


Custom 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.rs lives the enum Error where we can store our custom error types. We can retrieve the error type from a returned library function via get_error_name and the message inside via get_error_msg. New errors are to be added to this enum with an associated String value.

To import talaria/src/stdlib/error.rs for use in the standard library: use crate::stdlib::error::error::Error as script_error;


Notes

All functions are untested on Windows and BSD.

@engelhartrueben engelhartrueben requested a review from coal-rock May 5, 2025 00:04
@engelhartrueben engelhartrueben added the wip Work In Progress label May 5, 2025
…n the whole Result<bool, Box<EvalAltResult>>
@engelhartrueben engelhartrueben removed the wip Work In Progress label May 7, 2025
@engelhartrueben engelhartrueben marked this pull request as ready for review May 7, 2025 15:21
@coal-rock
Copy link
Copy Markdown
Owner

I've gone ahead and cleaned up some of the documentation.
(I recommend you check this out if you're curious about convention/features of mdbook)

Aside from that, everything looks great!
Good work!!

LGTM 🔥

@coal-rock coal-rock merged commit fe7d0dd into main May 8, 2025
4 checks passed
@engelhartrueben engelhartrueben deleted the re/talaria-std-sys-lib branch May 8, 2025 21:24
@coal-rock coal-rock changed the title Add sys library to Talarai Add sys library to Talaria May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants