(core) add housekeeping endpoints for cleaning doc snapshots+state

Summary:
This adds endpoints that allow the support user to remove unlisted
snapshots for a document, and to remove all action history for
a document.

This does increase what the support user can do, but not in a way
that would be particularly valuable to attack.  It would have some
destructive value, for removing history (removing unlisted
snapshots doesn't impact the user, by contrast).

This would simplify some maintenance operations.

Test Plan: added test for snapshots; tested states manually

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2699
This commit is contained in:
Paul Fitzpatrick
2021-01-05 09:35:14 -05:00
parent 5deac68315
commit 68a682f876
3 changed files with 65 additions and 4 deletions

View File

@@ -1106,9 +1106,10 @@ export class FlexServer implements GristServer {
}
public async addHousekeeper() {
if (this._check('housekeeper', 'start', 'homedb', 'map')) { return; }
if (this._check('housekeeper', 'start', 'homedb', 'map', 'json', 'api-mw')) { return; }
const store = this._docWorkerMap;
this.housekeeper = new Housekeeper(this.dbManager, this, store, store);
this.housekeeper.addEndpoints(this.app);
await this.housekeeper.start();
}

View File

@@ -104,7 +104,6 @@ export async function main(port: number, serverTypes: ServerType[],
if (includeHome) {
if (!includeApp) {
server.addUsage();
await server.addHousekeeper();
}
if (!includeDocs) {
server.addDocApiForwarder();
@@ -115,9 +114,8 @@ export async function main(port: number, serverTypes: ServerType[],
if (!includeApp) {
server.addHomeApi();
server.addBillingApi();
}
if (!includeApp) {
server.addNotifier();
await server.addHousekeeper();
}
server.addLoginRoutes();
server.addBillingPages();