mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
collapse success/severity/done into status
This commit is contained in:
parent
307334e8dd
commit
fc4e43785e
@ -53,7 +53,7 @@ export class AdminChecks {
|
|||||||
const {id} = probe;
|
const {id} = probe;
|
||||||
let result = this._results.get(id);
|
let result = this._results.get(id);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
result = Observable.create(this._parent, {});
|
result = Observable.create(this._parent, {status: 'none'});
|
||||||
this._results.set(id, result);
|
this._results.set(id, result);
|
||||||
}
|
}
|
||||||
let request = this._requests.get(id);
|
let request = this._requests.get(id);
|
||||||
@ -108,7 +108,7 @@ export class AdminCheckRunner {
|
|||||||
public start() {
|
public start() {
|
||||||
let result = this.results.get(this.id);
|
let result = this.results.get(this.id);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
result = Observable.create(this.parent, {});
|
result = Observable.create(this.parent, {status: 'none'});
|
||||||
this.results.set(this.id, result);
|
this.results.set(this.id, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ Please log in as an administrator.`)),
|
|||||||
use => {
|
use => {
|
||||||
const req = this._checks.requestCheckById(use, 'sandboxing');
|
const req = this._checks.requestCheckById(use, 'sandboxing');
|
||||||
const result = req ? use(req.result) : undefined;
|
const result = req ? use(req.result) : undefined;
|
||||||
const success = result?.success;
|
const success = result?.status === 'success';
|
||||||
const details = result?.details as SandboxingBootProbeDetails|undefined;
|
const details = result?.details as SandboxingBootProbeDetails|undefined;
|
||||||
if (!details) {
|
if (!details) {
|
||||||
return cssValueLabel(t('unknown'));
|
return cssValueLabel(t('unknown'));
|
||||||
@ -217,7 +217,8 @@ Please log in as an administrator.`)),
|
|||||||
return cssValueLabel(cssErrorText('unavailable'));
|
return cssValueLabel(cssErrorText('unavailable'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const { success, details } = result;
|
const { status, details } = result;
|
||||||
|
const success = status === 'success';
|
||||||
const loginSystemId = details?.loginSystemId;
|
const loginSystemId = details?.loginSystemId;
|
||||||
|
|
||||||
if (!success || !loginSystemId) {
|
if (!success || !loginSystemId) {
|
||||||
@ -500,10 +501,10 @@ Please log in as an administrator.`)),
|
|||||||
{ style: 'margin-top: 0px; padding-top: 0px;' },
|
{ style: 'margin-top: 0px; padding-top: 0px;' },
|
||||||
),
|
),
|
||||||
result.verdict ? dom('pre', result.verdict) : null,
|
result.verdict ? dom('pre', result.verdict) : null,
|
||||||
(result.success === undefined) ? null :
|
(result.status === 'none') ? null :
|
||||||
dom('p',
|
dom('p',
|
||||||
result.success ? t('Check succeeded.') : t('Check failed.')),
|
(result.status === 'success') ? t('Check succeeded.') : t('Check failed.')),
|
||||||
(result.done !== true) ? null :
|
(result.status !== 'none') ? null :
|
||||||
dom('p', t('No fault detected.')),
|
dom('p', t('No fault detected.')),
|
||||||
(details?.info === undefined) ? null : [
|
(details?.info === undefined) ? null : [
|
||||||
cssCheckHeader(t('Notes')),
|
cssCheckHeader(t('Notes')),
|
||||||
@ -530,12 +531,21 @@ Please log in as an administrator.`)),
|
|||||||
* visualization of the results can be elaborated in future.
|
* visualization of the results can be elaborated in future.
|
||||||
*/
|
*/
|
||||||
private _encodeSuccess(result: BootProbeResult) {
|
private _encodeSuccess(result: BootProbeResult) {
|
||||||
if (result.success === undefined) { return '―'; }
|
switch (result.status) {
|
||||||
if (result.success) { return '✅'; }
|
case 'success':
|
||||||
if (result.severity === 'warning') { return '❗'; }
|
return '✅';
|
||||||
if (result.severity === 'hmm') { return '?'; }
|
case 'fault':
|
||||||
// remaining case is a fault.
|
|
||||||
return '❌';
|
return '❌';
|
||||||
|
case 'warning':
|
||||||
|
return '❗';
|
||||||
|
case 'hmm':
|
||||||
|
return '?';
|
||||||
|
case 'none':
|
||||||
|
return '―';
|
||||||
|
default:
|
||||||
|
// should not arrive here
|
||||||
|
return '??';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,9 +13,12 @@ export type BootProbeIds =
|
|||||||
|
|
||||||
export interface BootProbeResult {
|
export interface BootProbeResult {
|
||||||
verdict?: string;
|
verdict?: string;
|
||||||
success?: boolean;
|
// Result of check.
|
||||||
done?: boolean;
|
// "success" is a positive outcome.
|
||||||
severity?: 'fault' | 'warning' | 'hmm';
|
// "none" means no fault detected (but that the test is not exhaustive
|
||||||
|
// enough to claim "success").
|
||||||
|
// "fault" is a bad error, "warning" a ... warning, "hmm" almost a debug message.
|
||||||
|
status: 'success' | 'fault' | 'warning' | 'hmm' | 'none';
|
||||||
details?: Record<string, any>;
|
details?: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,17 +91,16 @@ const _homeUrlReachableProbe: Probe = {
|
|||||||
throw new ApiError(await resp.text(), resp.status);
|
throw new ApiError(await resp.text(), resp.status);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
status: 'success',
|
||||||
details,
|
details,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
|
||||||
details: {
|
details: {
|
||||||
...details,
|
...details,
|
||||||
error: String(e),
|
error: String(e),
|
||||||
},
|
},
|
||||||
severity: 'fault',
|
status: 'fault',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,7 +120,7 @@ const _webSocketsProbe: Probe = {
|
|||||||
ws.on('open', () => {
|
ws.on('open', () => {
|
||||||
ws.send('Just nod if you can hear me.');
|
ws.send('Just nod if you can hear me.');
|
||||||
resolve({
|
resolve({
|
||||||
success: true,
|
status: 'success',
|
||||||
details,
|
details,
|
||||||
});
|
});
|
||||||
ws.close();
|
ws.close();
|
||||||
@ -129,7 +128,7 @@ const _webSocketsProbe: Probe = {
|
|||||||
ws.on('error', (ev) => {
|
ws.on('error', (ev) => {
|
||||||
details.error = ev.message;
|
details.error = ev.message;
|
||||||
resolve({
|
resolve({
|
||||||
success: false,
|
status: 'fault',
|
||||||
details,
|
details,
|
||||||
});
|
});
|
||||||
ws.close();
|
ws.close();
|
||||||
@ -159,17 +158,16 @@ const _statusCheckProbe: Probe = {
|
|||||||
throw new Error(`Failed, page has unexpected content`);
|
throw new Error(`Failed, page has unexpected content`);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: true,
|
status: 'success',
|
||||||
details,
|
details,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
|
||||||
details: {
|
details: {
|
||||||
...details,
|
...details,
|
||||||
error: String(e),
|
error: String(e),
|
||||||
},
|
},
|
||||||
severity: 'fault',
|
status: 'fault',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -185,13 +183,12 @@ const _userProbe: Probe = {
|
|||||||
if (process.getuid && process.getuid() === 0) {
|
if (process.getuid && process.getuid() === 0) {
|
||||||
return {
|
return {
|
||||||
details,
|
details,
|
||||||
success: false,
|
|
||||||
verdict: 'User appears to be root (UID 0)',
|
verdict: 'User appears to be root (UID 0)',
|
||||||
severity: 'warning',
|
status: 'warning',
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return {
|
return {
|
||||||
success: true,
|
status: 'success',
|
||||||
details,
|
details,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -208,22 +205,20 @@ const _bootProbe: Probe = {
|
|||||||
bootKeySet: hasBoot,
|
bootKeySet: hasBoot,
|
||||||
};
|
};
|
||||||
if (!hasBoot) {
|
if (!hasBoot) {
|
||||||
return { success: true, details };
|
return { status: 'success', details };
|
||||||
}
|
}
|
||||||
details.bootKeyLength = bootKey.length;
|
details.bootKeyLength = bootKey.length;
|
||||||
if (bootKey.length < 10) {
|
if (bootKey.length < 10) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
|
||||||
verdict: 'Boot key length is shorter than 10.',
|
verdict: 'Boot key length is shorter than 10.',
|
||||||
details,
|
details,
|
||||||
severity: 'fault',
|
status: 'fault',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
success: false,
|
|
||||||
verdict: 'Boot key ideally should be removed after installation.',
|
verdict: 'Boot key ideally should be removed after installation.',
|
||||||
details,
|
details,
|
||||||
severity: 'warning',
|
status: 'warning',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -247,19 +242,18 @@ const _hostHeaderProbe: Probe = {
|
|||||||
};
|
};
|
||||||
if (url.hostname === 'localhost') {
|
if (url.hostname === 'localhost') {
|
||||||
return {
|
return {
|
||||||
done: true,
|
status: 'none',
|
||||||
details,
|
details,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (String(url.hostname).toLowerCase() !== String(host).toLowerCase()) {
|
if (String(url.hostname).toLowerCase() !== String(host).toLowerCase()) {
|
||||||
return {
|
return {
|
||||||
success: false,
|
|
||||||
details,
|
details,
|
||||||
severity: 'hmm',
|
status: 'hmm',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
done: true,
|
status: 'none',
|
||||||
details,
|
details,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -271,7 +265,7 @@ const _sandboxingProbe: Probe = {
|
|||||||
apply: async (server, req) => {
|
apply: async (server, req) => {
|
||||||
const details = server.getSandboxInfo();
|
const details = server.getSandboxInfo();
|
||||||
return {
|
return {
|
||||||
success: details?.configured && details?.functional,
|
status: (details?.configured && details?.functional) ? 'success' : 'fault',
|
||||||
details,
|
details,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -283,7 +277,7 @@ const _authenticationProbe: Probe = {
|
|||||||
apply: async(server, req) => {
|
apply: async(server, req) => {
|
||||||
const loginSystemId = server.getInfo('loginMiddlewareComment');
|
const loginSystemId = server.getInfo('loginMiddlewareComment');
|
||||||
return {
|
return {
|
||||||
success: loginSystemId != undefined,
|
status: (loginSystemId != undefined) ? 'success' : 'fault',
|
||||||
details: {
|
details: {
|
||||||
loginSystemId,
|
loginSystemId,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user