Skip to content

Commit

Permalink
150 feature imix platform information (#160)
Browse files Browse the repository at this point in the history
* Implement os_pretty_name.

* Cleanup compiler warn.
  • Loading branch information
hulto authored Mar 23, 2023
1 parent 9c63e50 commit 292de05
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion implants/imix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ httptest = "0.15.4"
chrono = { version = "0.4.23" , features = ["serde"] }
tempfile = "3.3.0"
whoami = "1.3.0"
uuid = { version = "1.3.0", features = ["v4","fast-rng"] }
uuid = { version = "1.3.0", features = ["v4","fast-rng"] }
sys-info = "0.9.1"
23 changes: 23 additions & 0 deletions implants/imix/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use tokio::time::Duration;
use imix::graphql::{GraphQLTask, self};
use eldritch::eldritch_run;
use uuid::Uuid;
use sys_info::{os_release,linux_os_release};

async fn install(config_path: String) -> Result<(), imix::Error> {
let config_file = File::open(config_path)?;
Expand Down Expand Up @@ -123,6 +124,21 @@ fn get_host_id(host_id_file_path: String) -> Result<String> {
}


fn get_os_pretty_name() -> Result<String> {
if cfg!(target_os = "linux") {
let linux_rel = linux_os_release()?;
let pretty_name = match linux_rel.pretty_name {
Some(local_pretty_name) => local_pretty_name,
None => "UNKNOWN-Linux".to_string(),
};
return Ok(format!("{}",pretty_name));
} else if cfg!(target_os = "windows") || cfg!(target_os = "macos") {
return Ok(os_release()?);
} else {
return Ok("UNKNOWN".to_string());
}
}

// Async handler for port scanning.
async fn main_loop(config_path: String) -> Result<()> {
let debug = true;
Expand Down Expand Up @@ -295,6 +311,13 @@ mod tests {
use imix::{graphql::{GraphQLJob, GraphQLTome}};
use super::*;

#[test]
fn imix_test_get_os_pretty_name() {
let res = get_os_pretty_name().unwrap();
println!("{res}");
assert!(!res.contains("UNKNOWN"));
}

#[test]
fn imix_handle_exec_tome() {
let test_tome_input = GraphQLTask{
Expand Down

0 comments on commit 292de05

Please sign in to comment.