diff --git a/src/backend/launcher.ts b/src/backend/launcher.ts index 436e15abf6..4c239226ba 100644 --- a/src/backend/launcher.ts +++ b/src/backend/launcher.ts @@ -838,13 +838,17 @@ async function callRunner( child.stdout.setEncoding('utf-8') child.stdout.on('data', (data: string) => { + const stringToLog = options?.logSanitizer + ? options.logSanitizer(data) + : data + if (!logsDisabled) { if (options?.logFile) { - appendFileSync(options.logFile, data) + appendFileSync(options.logFile, stringToLog) } if (options?.verboseLogFile) { - appendFileSync(options.verboseLogFile, data) + appendFileSync(options.verboseLogFile, stringToLog) } } @@ -857,13 +861,17 @@ async function callRunner( child.stderr.setEncoding('utf-8') child.stderr.on('data', (data: string) => { + const stringToLog = options?.logSanitizer + ? options.logSanitizer(data) + : data + if (!logsDisabled) { if (options?.logFile) { - appendFileSync(options.logFile, data) + appendFileSync(options.logFile, stringToLog) } if (options?.verboseLogFile) { - appendFileSync(options.verboseLogFile, data) + appendFileSync(options.verboseLogFile, stringToLog) } } diff --git a/src/backend/storeManagers/gog/user.ts b/src/backend/storeManagers/gog/user.ts index 16afee3f36..ea3defbecb 100644 --- a/src/backend/storeManagers/gog/user.ts +++ b/src/backend/storeManagers/gog/user.ts @@ -13,6 +13,19 @@ import { import { gogdlAuthConfig } from 'backend/constants' import { clearCache } from 'backend/utils' +function authLogSanitizer(line: string) { + try { + const output = JSON.parse(line) + output.access_token = '' + output.session_id = '' + output.refresh_token = '' + output.user_id = '' + return JSON.stringify(output) + '\n' + } catch (error) { + return line + } +} + export class GOGUser { static async login( code: string @@ -26,7 +39,10 @@ export class GOGUser { // Gets token from GOG basaed on authorization code const { stdout } = await runRunnerCommand( ['auth', '--code', code], - createAbortController('gogdl-auth') + createAbortController('gogdl-auth'), + { + logSanitizer: authLogSanitizer + } ) try { @@ -102,7 +118,10 @@ export class GOGUser { } const { stdout } = await runRunnerCommand( ['auth'], - createAbortController('gogdl-get-credentials') + createAbortController('gogdl-get-credentials'), + { + logSanitizer: authLogSanitizer + } ) deleteAbortController('gogdl-get-credentials') diff --git a/src/backend/storeManagers/nile/user.ts b/src/backend/storeManagers/nile/user.ts index 5c42954fcf..c6105d6550 100644 --- a/src/backend/storeManagers/nile/user.ts +++ b/src/backend/storeManagers/nile/user.ts @@ -14,12 +14,28 @@ import { nileUserData } from 'backend/constants' import { configStore } from './electronStores' import { clearCache } from 'backend/utils' +function authLogSanitizer(line: string) { + try { + const output = JSON.parse(line) + output.url = '' + output.code_verifier = '' + output.serial = '' + output.client_id = '' + return JSON.stringify(output) + '\n' + } catch (error) { + return line + } +} + export class NileUser { static async getLoginData(): Promise { logDebug('Getting login data from Nile', LogPrefix.Nile) const { stdout } = await runRunnerCommand( ['auth', '--login', '--non-interactive'], - createAbortController('nile-auth') + createAbortController('nile-auth'), + { + logSanitizer: authLogSanitizer + } ) deleteAbortController('nile-auth') const output: NileLoginData = JSON.parse(stdout) diff --git a/src/common/types.ts b/src/common/types.ts index 6080734994..c84364ed6c 100644 --- a/src/common/types.ts +++ b/src/common/types.ts @@ -344,6 +344,7 @@ export interface CallRunnerOptions { logMessagePrefix?: string logFile?: string verboseLogFile?: string + logSanitizer?: (line: string) => string env?: Record | NodeJS.ProcessEnv wrappers?: string[] onOutput?: (output: string, child: ChildProcess) => void