Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
DB_POOL,
},
enterprise::{
periodic::config::poll_instance, posture::authorize_posture_session,
self, periodic::config::poll_instance, posture::authorize_posture_session,
provisioning::ProvisioningConfig,
},
error::Error,
Expand Down Expand Up @@ -1577,25 +1577,9 @@ pub fn get_platform_header() -> String {
}

#[tauri::command(async)]
#[cfg(not(windows))]
pub async fn get_posture_data() -> Result<DevicePostureData, Error> {
debug!("Received a command to prepare posture report");
Ok(DevicePostureData::new())
}

#[tauri::command(async)]
#[cfg(windows)]
pub async fn get_posture_data() -> Result<DevicePostureData, Error> {
debug!("Received a command to prepare posture report");
DAEMON_CLIENT
.clone()
.get_posture_data(tonic::Request::new(()))
.await
.map(|response| response.into_inner())
.map_err(|err| {
error!("Failed to get posture data from the daemon: {err}");
Error::InternalError(format!("Failed to get posture data from the daemon: {err}"))
})
enterprise::posture::get_posture_data().await
}

#[derive(Debug, Serialize)]
Expand Down
13 changes: 12 additions & 1 deletion src-tauri/src/enterprise/inspector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,18 @@ fn os_name() -> Result<String, UnavailableReason> {

/// Returns the operating system version.
fn os_version() -> Result<String, UnavailableReason> {
System::os_version().ok_or(UnavailableReason::DetectionFailed)
#[cfg(windows)]
{
// Windows can report versions like "11 (26200)"; core expects a parseable major.
System::os_version()
.and_then(|version| version.split_whitespace().next().map(ToString::to_string))
.ok_or(UnavailableReason::DetectionFailed)
}

#[cfg(not(windows))]
{
System::os_version().ok_or(UnavailableReason::DetectionFailed)
}
}

/// Returns the Linux kernel version.
Expand Down
23 changes: 22 additions & 1 deletion src-tauri/src/enterprise/posture.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use reqwest::StatusCode;
use serde::Deserialize;

#[cfg(windows)]
use crate::service::client::DAEMON_CLIENT;
use crate::{
database::{
models::{instance::Instance, location::Location, wireguard_keys::WireguardKeys, Id},
Expand Down Expand Up @@ -30,7 +32,7 @@ pub async fn authorize_posture_session(location: &Location<Id>) -> Result<String
))
})?;

let posture_data = DevicePostureData::new();
let posture_data = get_posture_data().await?;

let request = DevicePostureCheckRequest {
location_id: location.network_id,
Expand Down Expand Up @@ -77,3 +79,22 @@ pub async fn authorize_posture_session(location: &Location<Id>) -> Result<String
))),
}
}

pub async fn get_posture_data() -> Result<DevicePostureData, Error> {
#[cfg(windows)]
{
DAEMON_CLIENT
.clone()
.get_posture_data(tonic::Request::new(()))
.await
.map(|response| response.into_inner())
.map_err(|err| {
error!("Failed to get posture data from the daemon: {err}");
Error::InternalError(format!("Failed to get posture data from the daemon: {err}"))
})
}
#[cfg(not(windows))]
{
Ok(DevicePostureData::new())
}
}
Loading