Harden Panama health snapshots

This commit is contained in:
Gabriel Brown
2026-08-18 09:30:18 -04:00
parent e2e03252e4
commit 21aa9223df
3 changed files with 137 additions and 6 deletions
+51 -4
View File
@@ -152,10 +152,11 @@ Singleton {
return false;
}
root.snapshot = candidate;
root.checks = candidate.checks;
root.summary = candidate.summary;
root.status = candidate.summary.status;
const accepted = root.safeSnapshot(candidate);
root.snapshot = accepted;
root.checks = accepted.checks;
root.summary = accepted.summary;
root.status = accepted.summary.status;
root.acceptedGeneration = scanGeneration;
root.diagnosticUnavailable = false;
root.lastError = "";
@@ -167,6 +168,52 @@ Singleton {
root.lastError = message;
}
function safeSnapshot(candidate: var): var {
return {
schemaVersion: 1,
generatedAt: candidate.generatedAt,
summary: {
status: candidate.summary.status,
healthy: candidate.summary.healthy,
warnings: candidate.summary.warnings,
errors: candidate.summary.errors,
unconfigured: candidate.summary.unconfigured
},
context: {
session: candidate.context.session,
versions: candidate.context.versions.map(version => ({
id: version.id,
version: version.version
}))
},
checks: candidate.checks.map(check => root.safeCheck(check))
};
}
function safeCheck(candidate: var): var {
const check = {
id: candidate.id,
group: candidate.group,
title: candidate.title,
status: candidate.status,
detail: candidate.detail
};
if (candidate.action !== undefined)
check.action = root.safeAction(candidate.action);
return check;
}
function safeAction(candidate: var): var {
const action = {
kind: candidate.kind,
label: candidate.label,
confirm: candidate.confirm
};
if (Object.prototype.hasOwnProperty.call(candidate, "target"))
action.target = candidate.target;
return action;
}
function repair(id: string, external: bool): bool {
if (root.busy)
return false;