minor: report secureboot and FDE status to the cloud

This commit is contained in:
Edwin Joassart 2025-03-06 15:37:24 +01:00
parent b8032edc04
commit d80abb53a7
2 changed files with 27 additions and 0 deletions

View File

@ -182,6 +182,25 @@ export async function undervoltageDetected(): Promise<boolean> {
} }
} }
interface HostSecurity {
fullDiskEncryption: boolean;
secureboot: boolean;
secureboot_keys_metadata: string | undefined;
}
async function getHostSecurityInfos(): Promise<HostSecurity | undefined> {
try {
const rawHostSecurity = await fs.readFile(
'/var/run/supervisor/security.json',
'utf-8',
);
const hostSecurity = JSON.parse(rawHostSecurity);
return hostSecurity;
} catch {
return undefined;
}
}
/** /**
* System metrics that are always reported in current state * System metrics that are always reported in current state
* due to their importance, regardless of HARDWARE_METRICS * due to their importance, regardless of HARDWARE_METRICS
@ -191,7 +210,12 @@ export async function getSystemChecks() {
// such as fs corruption checks, network issues, etc. // such as fs corruption checks, network issues, etc.
const undervoltage = await undervoltageDetected(); const undervoltage = await undervoltageDetected();
const hostSecurity = await getHostSecurityInfos();
return { return {
is_storage_encrypted: hostSecurity?.fullDiskEncryption || false,
is_secureboot_enabled: hostSecurity?.secureboot || false,
secureboot_keys_metadata: hostSecurity?.secureboot_keys_metadata || null,
is_undervolted: undervoltage, is_undervolted: undervoltage,
}; };
} }

View File

@ -195,6 +195,9 @@ const DeviceReport = t.partial({
cpu_usage: t.number, cpu_usage: t.number,
cpu_id: t.string, cpu_id: t.string,
is_undervolted: t.boolean, is_undervolted: t.boolean,
is_secureboot_enabled: t.boolean,
is_storage_encrypted: t.boolean,
secureboot_keys_metadata: t.union([t.string, t.null]),
// These are for internal reporting only, they are not sent // These are for internal reporting only, they are not sent
// to the API // to the API
update_failed: t.boolean, update_failed: t.boolean,