Skip to content

Commit

Permalink
updated at 2024-09-16T08:47:22-04:00
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfitz committed Sep 16, 2024
1 parent 858f67b commit 0d1cab0
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core
Submodule core updated 63 files
+3 −1 app/client/components/DataTables.ts
+12 −0 app/client/components/Printing.css
+3 −0 app/client/models/DataRowModel.ts
+7 −3 app/client/ui/AccountWidget.ts
+5 −3 app/client/ui/UserImage.ts
+34 −15 app/client/widgets/Toggle.ts
+31 −0 app/common/AuditEvent.ts
+16 −0 app/common/LoginSessionAPI.ts
+3 −1 app/common/schema.ts
+22 −10 app/gen-server/ApiServer.ts
+2 −2 app/gen-server/entity/User.ts
+9 −9 app/gen-server/lib/homedb/HomeDBManager.ts
+8 −8 app/gen-server/lib/homedb/UsersManager.ts
+2 −1 app/server/generateInitialDocSql.ts
+2 −2 app/server/lib/Assistance.ts
+40 −0 app/server/lib/AuditLogger.ts
+14 −4 app/server/lib/DocApi.ts
+6 −0 app/server/lib/DocManager.ts
+13 −0 app/server/lib/FlexServer.ts
+15 −8 app/server/lib/GranularAccess.ts
+9 −0 app/server/lib/GristAuditLogger.ts
+10 −0 app/server/lib/GristServer.ts
+135 −0 app/server/lib/HTTPAuditLogger.ts
+14 −2 app/server/lib/ICreate.ts
+1 −1 app/server/lib/InstallAdmin.ts
+2 −4 app/server/lib/Telemetry.ts
+30 −0 app/server/lib/configureGristAuditLogger.ts
+8 −0 app/server/lib/coreCreator.ts
+15 −27 app/server/lib/dbUtils.ts
+8 −8 app/server/lib/initialDocSql.ts
+6 −3 app/server/lib/requestUtils.ts
+2 −0 app/server/mergedServerMain.ts
+1 −0 package.json
+124 −27 sandbox/grist/column.py
+5 −4 sandbox/grist/docactions.py
+2 −0 sandbox/grist/dropdown_condition.py
+8 −9 sandbox/grist/engine.py
+10 −4 sandbox/grist/gencode.py
+8 −0 sandbox/grist/migrations.py
+5 −0 sandbox/grist/records.py
+73 −0 sandbox/grist/reverse_references.py
+31 −7 sandbox/grist/schema.py
+4 −0 sandbox/grist/table.py
+26 −0 sandbox/grist/test_dropdown_condition_renames.py
+2 −1 sandbox/grist/test_gencode.py
+72 −4 sandbox/grist/test_reflist_rel.py
+1,166 −0 sandbox/grist/test_twoway_refs.py
+139 −13 sandbox/grist/useractions.py
+31 −5 sandbox/grist/usertypes.py
+1 −0 static/sinon.js
+ test/fixtures/docs/Hello.grist
+94 −108 test/gen-server/lib/homedb/UsersManager.ts
+6 −17 test/gen-server/seed.ts
+3 −3 test/nbrowser/DropdownConditionEditor.ts
+3 −3 test/nbrowser/Formulas.ts
+382 −0 test/nbrowser/TwoWayReference.ts
+3 −1 test/nbrowser/WebhookOverflow.ts
+64 −14 test/nbrowser/gristUtils.ts
+26 −13 test/server/lib/Assistance.ts
+1 −0 test/server/lib/Authorizer.ts
+12 −6 test/server/lib/DocApi.ts
+117 −0 test/server/lib/GristAuditLogger.ts
+19 −0 yarn.lock
24 changes: 24 additions & 0 deletions ext/app/server/lib/HECAuditLogger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {AuditEvent, AuditEventName} from 'app/common/AuditEvent';
import {IAuditLogger} from 'app/server/lib/AuditLogger';
import {HTTPAuditLogger} from 'app/server/lib/HTTPAuditLogger';
import moment from 'moment-timezone';

export class HECAuditLogger extends HTTPAuditLogger implements IAuditLogger {
protected toJSON<Name extends AuditEventName>({event, timestamp}: AuditEvent<Name>): string {
return JSON.stringify({
event,
time: toUnixTimestamp(timestamp),
});
}
}

/**
* Converts an ISO 8601 timestamp to a Unix timestamp.
*
* The format of the timestamp is `[seconds].[milliseconds]` (e.g. `"1725459194.123"`), as
* documented [here](https://docs.splunk.com/Documentation/SplunkCloud/latest/Data/FormateventsforHTTPEventCollector#Event_metadata).
*/
function toUnixTimestamp(timestamp: string): string {
const unixMs = moment(timestamp).format('x');
return `${unixMs.slice(0, -3)}.${unixMs.slice(-3)}`;
}
29 changes: 29 additions & 0 deletions ext/app/server/lib/configureHECAuditLogger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {appSettings} from 'app/server/lib/AppSettings';
import {HECAuditLogger} from 'app/server/lib/HECAuditLogger';

export function configureHECAuditLogger() {
const options = checkHECAuditLogger();
if (!options) { return undefined; }

return new HECAuditLogger(options);
}

export function checkHECAuditLogger() {
const settings = appSettings.section('auditLogger').section('http');
const endpoint = settings.flag('endpoint').readString({
envVar: 'GRIST_AUDIT_HTTP_ENDPOINT',
});
if (!endpoint) { return undefined; }

const payloadFormat = settings.flag('payloadFormat').readString({
envVar: 'GRIST_AUDIT_HTTP_PAYLOAD_FORMAT',
});
if (payloadFormat !== 'hec') { return undefined; }

const authorizationHeader = settings.flag('authorizationHeader').readString({
envVar: 'GRIST_AUDIT_HTTP_AUTHORIZATION_HEADER',
censor: true,
});

return {endpoint, authorizationHeader};
}
14 changes: 14 additions & 0 deletions ext/app/server/lib/create.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Activation } from 'app/gen-server/lib/Activation';
import { configureSendGridNotifier } from 'app/gen-server/lib/configureSendGridNotifier';
import { checkAzureExternalStorage, configureAzureExternalStorage } from 'app/server/lib/configureAzureExternalStorage';
import { checkGristAuditLogger, configureGristAuditLogger } from 'app/server/lib/configureGristAuditLogger';
import { checkHECAuditLogger, configureHECAuditLogger } from 'app/server/lib/configureHECAuditLogger';
import { checkMinIOExternalStorage, configureMinIOExternalStorage } from 'app/server/lib/configureMinIOExternalStorage';
import { checkS3ExternalStorage, configureS3ExternalStorage } from 'app/server/lib/configureS3ExternalStorage';
import { ICreate, makeSimpleCreator } from 'app/server/lib/ICreate';
Expand Down Expand Up @@ -32,6 +34,18 @@ export const makeEnterpriseCreator = () => makeSimpleCreator({
notifier: {
create: configureSendGridNotifier,
},
auditLogger: [
{
name: 'grist',
check: () => checkGristAuditLogger() !== undefined,
create: configureGristAuditLogger,
},
{
name: 'hec',
check: () => checkHECAuditLogger() !== undefined,
create: configureHECAuditLogger,
},
],
});

export const create = isRunningEnterprise() ? makeEnterpriseCreator() : makeCoreCreator();
Expand Down

0 comments on commit 0d1cab0

Please sign in to comment.