feat: collect native HIP facts and log redacted XML responses

This commit is contained in:
Kevin Yue committed 2026-11-18 13:56:12 +08:00
1 parent f2ca674b88
commit bde11186f8
26 files changed
+1567 -206

No files matched your search

+29 -3
View File
@@ -158,19 +158,22 @@ pub(crate) fn profile(
control: &dyn gpapi::collection::CollectionControl,
) -> io::Result<OsProfile> {
let identity = gpapi::os_profile::desktop::identity_from_parts(
hostname.unwrap_or_else(|| identity.computer().into()),
host_id.unwrap_or_else(|| identity.host_id().into()),
hostname.as_deref().unwrap_or(identity.computer()).into(),
host_id.as_deref().unwrap_or(identity.host_id()).into(),
identity.serialno().into(),
identity.mac_addr().into(),
);
let mut builder = OsProfileBuilder::new(os).host_identity(identity);
if let Some(hostname) = hostname {
builder = builder.computer_name_override(hostname);
}
if let Some(version) = version {
builder = builder.client_version(version);
}
if let Some(os_version) = os_version {
builder = builder.os_version(os_version);
}
gpapi::os_profile::desktop::collect_profile_with_control(builder, None, control)
gpapi::os_profile::desktop::collect_profile_with_control(builder, host_id.as_deref(), control)
}
fn generation_error(error: anyhow::Error) -> io::Error {
@@ -235,6 +238,29 @@ mod tests {
assert_eq!(profile.host_identity().serialno(), "serial");
}
#[cfg(windows)]
#[test]
fn native_windows_profile_retains_negotiated_host_id() {
let identity = gpapi::os_profile::HostIdentity::from_parts(
"device".into(),
"hardware-seed".into(),
"serial".into(),
"00:11:22:33:44:55".into(),
);
let profile = profile(
&identity,
ClientOs::Windows,
None,
None,
Some("negotiated-host".into()),
None,
&gpapi::collection::CollectionBudget::new(std::time::Duration::from_secs(60)),
)
.unwrap();
assert_eq!(profile.host_id(), "negotiated-host");
assert_eq!(profile.host_identity().host_id(), "negotiated-host");
}
#[test]
fn callback_errors_preserve_cancellation() {
let error = generation_error(io::Error::new(io::ErrorKind::Interrupted, "cancelled").into());