Harden Panama health snapshots
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user