@@ -13,7 +13,8 @@ use sysinfo::System;
1313
1414use crate :: {
1515 service:: proto:: defguard:: enterprise:: posture:: v2:: {
16- bool_check, string_check, BoolCheck , DevicePostureData , StringCheck , UnavailableReason ,
16+ bool_check, int32_check, string_check, BoolCheck , DevicePostureData , Int32Check ,
17+ StringCheck , UnavailableReason ,
1718 } ,
1819 VERSION ,
1920} ;
@@ -109,11 +110,11 @@ fn device_integrity() -> Result<bool, UnavailableReason> {
109110 Err ( UnavailableReason :: NotApplicable )
110111}
111112
112- /// Returns the security update status .
113- fn security_update_status ( ) -> Result < bool , UnavailableReason > {
113+ /// Returns the number of days since the last installed Windows security update.
114+ fn security_update_age_days ( ) -> Result < i32 , UnavailableReason > {
114115 #[ cfg( windows) ]
115116 {
116- windows:: security_update_status ( )
117+ windows:: security_update_age_days ( )
117118 }
118119
119120 #[ cfg( not( windows) ) ]
@@ -134,6 +135,18 @@ impl From<Result<bool, UnavailableReason>> for BoolCheck {
134135 }
135136}
136137
138+ /// Convert `Result` to `Int32Check`.
139+ impl From < Result < i32 , UnavailableReason > > for Int32Check {
140+ fn from ( value : Result < i32 , UnavailableReason > ) -> Self {
141+ Self {
142+ result : Some ( match value {
143+ Ok ( inner) => int32_check:: Result :: Value ( inner) ,
144+ Err ( err) => int32_check:: Result :: Unavailable ( err as i32 ) ,
145+ } ) ,
146+ }
147+ }
148+ }
149+
137150/// Convert `Result` to `StringCheck`.
138151impl From < Result < String , UnavailableReason > > for StringCheck {
139152 fn from ( value : Result < String , UnavailableReason > ) -> Self {
@@ -159,7 +172,7 @@ impl DevicePostureData {
159172 disk_encryption : Some ( BoolCheck :: from ( disk_encryption_status ( ) ) ) ,
160173 antivirus_present : Some ( BoolCheck :: from ( anti_virus_status ( ) ) ) ,
161174 windows_ad_domain_joined : Some ( BoolCheck :: from ( part_of_domain ( ) ) ) ,
162- windows_security_update_current : Some ( BoolCheck :: from ( security_update_status ( ) ) ) ,
175+ windows_security_update_age_days : Some ( Int32Check :: from ( security_update_age_days ( ) ) ) ,
163176 linux_kernel_version : Some ( StringCheck :: from ( linux_kernel_version ( ) ) ) ,
164177 device_integrity : Some ( BoolCheck :: from ( device_integrity ( ) ) ) ,
165178 }
0 commit comments