From 79f1eb6e5eb6568e9f642d9083c446765fce2889 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 20 Feb 2023 21:21:32 +0100 Subject: [PATCH] improvements in the anonymization script --- bin/tpl/anonymize-database.sql | 155 ++++++++++++++++++++++++++++++++- 1 file changed, 152 insertions(+), 3 deletions(-) diff --git a/bin/tpl/anonymize-database.sql b/bin/tpl/anonymize-database.sql index afdff5168..d72e0b29a 100644 --- a/bin/tpl/anonymize-database.sql +++ b/bin/tpl/anonymize-database.sql @@ -1,12 +1,161 @@ UPDATE etapi_tokens SET tokenHash = 'API token hash value'; -UPDATE notes SET title = 'title' WHERE title NOT IN ('root', '_hidden', '_share'); +UPDATE notes SET title = 'title' WHERE noteId != 'root' AND noteId NOT LIKE '\_%' ESCAPE '\'; UPDATE note_contents SET content = 'text' WHERE content IS NOT NULL; UPDATE note_revisions SET title = 'title'; UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL; -UPDATE attributes SET name = 'name', value = 'value' WHERE type = 'label' AND name NOT IN('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'workspaceInbox', 'workspaceSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteContentChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); -UPDATE attributes SET name = 'name' WHERE type = 'relation' AND name NOT IN ('inbox', 'disableVersioning', 'calendarRoot', 'archived', 'excludeFromExport', 'disableInclusion', 'appCss', 'appTheme', 'hidePromotedAttributes', 'readOnly', 'autoReadOnlyDisabled', 'cssClass', 'iconClass', 'keyboardShortcut', 'run', 'runOnInstance', 'runAtHour', 'customRequestHandler', 'customResourceProvider', 'widget', 'noteInfoWidgetDisabled', 'linkMapWidgetDisabled', 'noteRevisionsWidgetDisabled', 'whatLinksHereWidgetDisabled', 'similarNotesWidgetDisabled', 'workspace', 'workspaceIconClass', 'workspaceTabBackgroundColor', 'searchHome', 'workspaceInbox', 'workspaceSearchHome', 'sqlConsoleHome', 'datePattern', 'pageSize', 'viewType', 'mapRootNoteId', 'bookmarkFolder', 'sorted', 'top', 'fullContentWidth', 'shareHiddenFromTree', 'shareAlias', 'shareOmitDefaultCss', 'shareRoot', 'shareDescription', 'internalLink', 'imageLink', 'relationMapLink', 'includeMapLink', 'runOnNoteCreation', 'runOnNoteTitleChange', 'runOnNoteContentChange', 'runOnNoteChange', 'runOnChildNoteCreation', 'runOnAttributeCreation', 'runOnAttributeChange', 'template', 'widget', 'renderNote', 'shareCss', 'shareJs', 'shareFavicon'); +UPDATE attributes SET name = 'name', value = 'value' + WHERE type = 'label' + AND name NOT IN ('inbox', + 'disableVersioning', + 'calendarRoot', + 'archived', + 'excludeFromExport', + 'disableInclusion', + 'appCss', + 'appTheme', + 'hidePromotedAttributes', + 'readOnly', + 'autoReadOnlyDisabled', + 'cssClass', + 'iconClass', + 'keyboardShortcut', + 'run', + 'runOnInstance', + 'runAtHour', + 'customRequestHandler', + 'customResourceProvider', + 'widget', + 'noteInfoWidgetDisabled', + 'linkMapWidgetDisabled', + 'noteRevisionsWidgetDisabled', + 'whatLinksHereWidgetDisabled', + 'similarNotesWidgetDisabled', + 'workspace', + 'workspaceIconClass', + 'workspaceTabBackgroundColor', + 'searchHome', + 'workspaceInbox', + 'workspaceSearchHome', + 'sqlConsoleHome', + 'datePattern', + 'pageSize', + 'viewType', + 'mapRootNoteId', + 'bookmarkFolder', + 'sorted', + 'top', + 'fullContentWidth', + 'shareHiddenFromTree', + 'shareAlias', + 'shareOmitDefaultCss', + 'shareRoot', + 'internalLink', + 'imageLink', + 'relationMapLink', + 'includeMapLink', + 'runOnNoteCreation', + 'runOnNoteTitleChange', + 'runOnNoteContentChange', + 'runOnNoteChange', + 'runOnChildNoteCreation', + 'runOnAttributeCreation', + 'runOnAttributeChange', + 'template', + 'inherit', + 'widget', + 'renderNote', + 'shareCss', + 'shareJs', + 'shareFavicon', + 'executeButton', + 'keepCurrentHoisting', + 'color', + 'toc', + 'excludeFromNoteMap', + 'docName', + 'launcherType', + 'builtinWidget', + 'baseSize', + 'growthFactor' + ); + +UPDATE attributes SET name = 'name' + AND name NOT IN ('inbox', + 'disableVersioning', + 'calendarRoot', + 'archived', + 'excludeFromExport', + 'disableInclusion', + 'appCss', + 'appTheme', + 'hidePromotedAttributes', + 'readOnly', + 'autoReadOnlyDisabled', + 'cssClass', + 'iconClass', + 'keyboardShortcut', + 'run', + 'runOnInstance', + 'runAtHour', + 'customRequestHandler', + 'customResourceProvider', + 'widget', + 'noteInfoWidgetDisabled', + 'linkMapWidgetDisabled', + 'noteRevisionsWidgetDisabled', + 'whatLinksHereWidgetDisabled', + 'similarNotesWidgetDisabled', + 'workspace', + 'workspaceIconClass', + 'workspaceTabBackgroundColor', + 'searchHome', + 'workspaceInbox', + 'workspaceSearchHome', + 'sqlConsoleHome', + 'datePattern', + 'pageSize', + 'viewType', + 'mapRootNoteId', + 'bookmarkFolder', + 'sorted', + 'top', + 'fullContentWidth', + 'shareHiddenFromTree', + 'shareAlias', + 'shareOmitDefaultCss', + 'shareRoot', + 'internalLink', + 'imageLink', + 'relationMapLink', + 'includeMapLink', + 'runOnNoteCreation', + 'runOnNoteTitleChange', + 'runOnNoteContentChange', + 'runOnNoteChange', + 'runOnChildNoteCreation', + 'runOnAttributeCreation', + 'runOnAttributeChange', + 'template', + 'inherit', + 'widget', + 'renderNote', + 'shareCss', + 'shareJs', + 'shareFavicon', + 'executeButton', + 'keepCurrentHoisting', + 'color', + 'toc', + 'excludeFromNoteMap', + 'docName', + 'launcherType', + 'builtinWidget', + 'baseSize', + 'growthFactor' + ); + UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL AND prefix != 'recovered'; UPDATE options SET value = 'anonymized' WHERE name IN ('documentId', 'documentSecret', 'encryptedDataKey',