mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
be fussier about boot key; log more problems
This commit is contained in:
parent
19f40085fa
commit
9947eabdbc
@ -1,3 +1,4 @@
|
|||||||
|
import { reportError } from 'app/client/models/errors';
|
||||||
import { BootProbeIds, BootProbeInfo, BootProbeResult } from 'app/common/BootProbe';
|
import { BootProbeIds, BootProbeInfo, BootProbeResult } from 'app/common/BootProbe';
|
||||||
import { InstallAPI } from 'app/common/InstallAPI';
|
import { InstallAPI } from 'app/common/InstallAPI';
|
||||||
import { getGristConfig } from 'app/common/urlUtils';
|
import { getGristConfig } from 'app/common/urlUtils';
|
||||||
@ -32,7 +33,7 @@ export class AdminChecks {
|
|||||||
const config = getGristConfig();
|
const config = getGristConfig();
|
||||||
const errMessage = config.errMessage;
|
const errMessage = config.errMessage;
|
||||||
if (!errMessage) {
|
if (!errMessage) {
|
||||||
const _probes = await this._installAPI.getChecks().catch(() => undefined);
|
const _probes = await this._installAPI.getChecks().catch(reportError);
|
||||||
if (!this._parent.isDisposed()) {
|
if (!this._parent.isDisposed()) {
|
||||||
// Currently, probes are forbidden if not admin.
|
// Currently, probes are forbidden if not admin.
|
||||||
// TODO: May want to relax this to allow some probes that help
|
// TODO: May want to relax this to allow some probes that help
|
||||||
|
@ -484,9 +484,7 @@ Please log in as an administrator.`),
|
|||||||
result: BootProbeResult,
|
result: BootProbeResult,
|
||||||
details: ProbeDetails|undefined) {
|
details: ProbeDetails|undefined) {
|
||||||
|
|
||||||
const status = (result.success !== undefined) ?
|
const status = this._encodeSuccess(result);
|
||||||
(result.success ? '✅' : '❗') : '―';
|
|
||||||
|
|
||||||
return dom.create(AdminSectionItem, {
|
return dom.create(AdminSectionItem, {
|
||||||
id: `probe-${info.id}`,
|
id: `probe-${info.id}`,
|
||||||
name: info.id,
|
name: info.id,
|
||||||
@ -521,6 +519,20 @@ Please log in as an administrator.`),
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Give an icon summarizing success or failure. Factor in the
|
||||||
|
* severity of the result for failures. This is crude, the
|
||||||
|
* visualization of the results can be elaborated in future.
|
||||||
|
*/
|
||||||
|
private _encodeSuccess(result: BootProbeResult) {
|
||||||
|
if (result.success === undefined) { return '―'; }
|
||||||
|
if (result.success) { return '✅'; }
|
||||||
|
if (result.severity === 'warning') { return '❗'; }
|
||||||
|
if (result.severity === 'hmm') { return '?'; }
|
||||||
|
// remaining case is a fault.
|
||||||
|
return '❌';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//function maybeSwitchToggle(value: Observable<boolean|null>): DomContents {
|
//function maybeSwitchToggle(value: Observable<boolean|null>): DomContents {
|
||||||
|
@ -169,7 +169,7 @@ const _bootProbe: Probe = {
|
|||||||
id: 'boot-page',
|
id: 'boot-page',
|
||||||
name: 'Is the boot page adequately protected',
|
name: 'Is the boot page adequately protected',
|
||||||
apply: async (server) => {
|
apply: async (server) => {
|
||||||
const bootKey = server.getBootKey;
|
const bootKey = server.getBootKey() || '';
|
||||||
const hasBoot = Boolean(bootKey);
|
const hasBoot = Boolean(bootKey);
|
||||||
const details: Record<string, any> = {
|
const details: Record<string, any> = {
|
||||||
bootKeySet: hasBoot,
|
bootKeySet: hasBoot,
|
||||||
@ -178,10 +178,19 @@ const _bootProbe: Probe = {
|
|||||||
return { success: true, details };
|
return { success: true, details };
|
||||||
}
|
}
|
||||||
details.bootKeyLength = bootKey.length;
|
details.bootKeyLength = bootKey.length;
|
||||||
|
if (bootKey.length < 10) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
verdict: 'Boot key length is shorter than 10.',
|
||||||
|
details,
|
||||||
|
severity: 'fault',
|
||||||
|
};
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
success: bootKey.length > 10,
|
success: false,
|
||||||
|
verdict: 'Boot key ideally should be removed after installation.',
|
||||||
details,
|
details,
|
||||||
severity: 'hmm',
|
severity: 'warning',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user