feat: schedule nonblocking Windows HIP patch checks

This commit is contained in:
Kevin Yue committed 2026-11-17 12:00:36 +08:00
1 parent 67b30ac7ca
commit ce6c97a2f7
13 files changed
+318 -19

No files matched your search

+17 -3
View File
@@ -275,10 +275,18 @@ pub fn generate_identity_report(input: &ReportInput) -> anyhow::Result<String> {
}
pub fn generate_report_with_control(input: &ReportInput, control: &dyn CollectionControl) -> anyhow::Result<String> {
Ok(generate_report_details(input, control)?.xml)
}
pub fn generate_report_details(
input: &ReportInput,
control: &dyn CollectionControl,
) -> anyhow::Result<gpapi::hip::HipReport> {
control.check()?;
let cookie_params = cookie_params(input);
let (generate_time, day, month, year) = get_current_time_components();
let host_info = HostInfoCollector::new(&input.profile, input, &cookie_params).collect(control)?;
let windows_updates = host_info.windows_updates.clone();
let template = HipReportTemplate {
client_version: input.profile.client_version(),
generate_time,
@@ -289,9 +297,9 @@ pub fn generate_report_with_control(input: &ReportInput, control: &dyn Collectio
host_info,
md5: input.context.md5(),
};
let report = format_xml(&template.render()?)?;
let xml = format_xml(&template.render()?)?;
control.check()?;
Ok(report)
Ok(gpapi::hip::HipReport { xml, windows_updates })
}
fn cookie_params(input: &ReportInput) -> HashMap<String, String> {
@@ -373,6 +381,7 @@ struct HostInfo {
sentinel: Option<SentinelInfo>,
ufw: Option<UfwInfo>,
windows_categories: Option<String>,
windows_updates: Option<gpapi::hip::WindowsUpdateStatus>,
}
impl HostInfo {
@@ -497,6 +506,7 @@ impl<'p, 'a> HostInfoCollector<'p, 'a> {
sentinel: None,
ufw: None,
windows_categories: None,
windows_updates: None,
})
}
@@ -558,7 +568,11 @@ impl<'p, 'a> HostInfoCollector<'p, 'a> {
let commands = CollectorCommands::new(control);
#[cfg(windows)]
if self.profile.client_os() == ClientOs::Windows && self.profile.is_native() {
info.windows_categories = Some(windows::collect(&commands, control)?.render()?);
let report = windows::collect(&commands, control)?;
info.windows_updates = Some(gpapi::hip::WindowsUpdateStatus {
checked_at: report.patches_checked_at,
});
info.windows_categories = Some(report.render()?);
}
if self.profile.client_os() == ClientOs::Linux && self.profile.is_native() {
+1
View File
@@ -11,6 +11,7 @@ pub(super) struct WindowsReport {
pub firewall: Vec<ProductState>,
pub patch_management: Vec<ProductState>,
pub missing_patches: Option<Vec<MissingPatch>>,
pub patches_checked_at: Option<u64>,
pub unavailable: Vec<String>,
}