From a11ed64202124b154b91cad63fe2a0af3590f9f8 Mon Sep 17 00:00:00 2001 From: jharris4 Date: Wed, 4 Aug 2021 09:40:13 +0100 Subject: [PATCH 1/2] do not allow sysinfo command when using system db --- .../services/commandInterpreterHelper.ts | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/shared/services/commandInterpreterHelper.ts b/src/shared/services/commandInterpreterHelper.ts index 5a05ae379eb..42bf561c65d 100644 --- a/src/shared/services/commandInterpreterHelper.ts +++ b/src/shared/services/commandInterpreterHelper.ts @@ -354,13 +354,27 @@ const availableCommands = [ name: 'sysinfo', match: (cmd: any) => /^sysinfo$/.test(cmd), exec(action: any, put: any, store: any) { - put( - frames.add({ - useDb: getUseDb(store.getState()), - ...action, - type: 'sysinfo' - }) - ) + const useDb = getUseDb(store.getState()) + if (useDb === 'system') { + put( + frames.add({ + useDb, + ...action, + type: 'error', + error: UnsupportedError( + 'The sysinfo command is not supported while using the system database.' + ) + }) + ) + } else { + put( + frames.add({ + useDb, + ...action, + type: 'sysinfo' + }) + ) + } } }, { From 0dad206fd0b3fbb6809a561ec3bb5fe4195c0e41 Mon Sep 17 00:00:00 2001 From: jharris4 Date: Wed, 4 Aug 2021 10:12:03 +0100 Subject: [PATCH 2/2] use constant for system db name and tweak error msg --- src/shared/services/commandInterpreterHelper.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/shared/services/commandInterpreterHelper.ts b/src/shared/services/commandInterpreterHelper.ts index 42bf561c65d..326cdc93080 100644 --- a/src/shared/services/commandInterpreterHelper.ts +++ b/src/shared/services/commandInterpreterHelper.ts @@ -48,7 +48,8 @@ import { getRemoteContentHostnameAllowlist, getDatabases, fetchMetaData, - getAvailableSettings + getAvailableSettings, + SYSTEM_DB } from 'shared/modules/dbMeta/dbMetaDuck' import { canSendTxMetadata } from 'shared/modules/features/versionedFeatures' import { fetchRemoteGuide } from 'shared/modules/commands/helpers/play' @@ -355,14 +356,14 @@ const availableCommands = [ match: (cmd: any) => /^sysinfo$/.test(cmd), exec(action: any, put: any, store: any) { const useDb = getUseDb(store.getState()) - if (useDb === 'system') { + if (useDb === SYSTEM_DB) { put( frames.add({ useDb, ...action, type: 'error', error: UnsupportedError( - 'The sysinfo command is not supported while using the system database.' + 'The :sysinfo command is not supported while using the system database.' ) }) )