mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
All: Mask auth token and password in log
This commit is contained in:
parent
7f0b3fd718
commit
0d33955fcd
@ -1439,9 +1439,6 @@ packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js.map
|
|||||||
packages/lib/services/synchronizer/tools.d.ts
|
packages/lib/services/synchronizer/tools.d.ts
|
||||||
packages/lib/services/synchronizer/tools.js
|
packages/lib/services/synchronizer/tools.js
|
||||||
packages/lib/services/synchronizer/tools.js.map
|
packages/lib/services/synchronizer/tools.js.map
|
||||||
packages/lib/services/synchronizer/uploadUtils.d.ts
|
|
||||||
packages/lib/services/synchronizer/uploadUtils.js
|
|
||||||
packages/lib/services/synchronizer/uploadUtils.js.map
|
|
||||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.d.ts
|
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.d.ts
|
||||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
||||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js.map
|
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js.map
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1425,9 +1425,6 @@ packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js.map
|
|||||||
packages/lib/services/synchronizer/tools.d.ts
|
packages/lib/services/synchronizer/tools.d.ts
|
||||||
packages/lib/services/synchronizer/tools.js
|
packages/lib/services/synchronizer/tools.js
|
||||||
packages/lib/services/synchronizer/tools.js.map
|
packages/lib/services/synchronizer/tools.js.map
|
||||||
packages/lib/services/synchronizer/uploadUtils.d.ts
|
|
||||||
packages/lib/services/synchronizer/uploadUtils.js
|
|
||||||
packages/lib/services/synchronizer/uploadUtils.js.map
|
|
||||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.d.ts
|
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.d.ts
|
||||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
||||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js.map
|
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js.map
|
||||||
|
@ -91,6 +91,23 @@ export default class JoplinServerApi {
|
|||||||
return _('Could not connect to Joplin Server. Please check the Synchronisation options in the config screen. Full error was:\n\n%s', msg);
|
return _('Could not connect to Joplin Server. Please check the Synchronisation options in the config screen. Full error was:\n\n%s', msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private hidePassword(o: any): any {
|
||||||
|
if (typeof o === 'string') {
|
||||||
|
try {
|
||||||
|
const output = JSON.parse(o);
|
||||||
|
if (!output) return o;
|
||||||
|
if (output.password) output.password = '******';
|
||||||
|
return JSON.stringify(output);
|
||||||
|
} catch (error) {
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const output = { ...o };
|
||||||
|
if (output.password) output.password = '******';
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private requestToCurl_(url: string, options: any) {
|
private requestToCurl_(url: string, options: any) {
|
||||||
const output = [];
|
const output = [];
|
||||||
output.push('curl');
|
output.push('curl');
|
||||||
@ -99,11 +116,12 @@ export default class JoplinServerApi {
|
|||||||
if (options.headers) {
|
if (options.headers) {
|
||||||
for (const n in options.headers) {
|
for (const n in options.headers) {
|
||||||
if (!options.headers.hasOwnProperty(n)) continue;
|
if (!options.headers.hasOwnProperty(n)) continue;
|
||||||
output.push(`${'-H ' + '"'}${n}: ${options.headers[n]}"`);
|
const headerValue = n === 'X-API-AUTH' ? '******' : options.headers[n];
|
||||||
|
output.push(`${'-H ' + '"'}${n}: ${headerValue}"`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options.body) {
|
if (options.body) {
|
||||||
const serialized = typeof options.body !== 'string' ? JSON.stringify(options.body) : options.body;
|
const serialized = typeof options.body !== 'string' ? JSON.stringify(this.hidePassword(options.body)) : this.hidePassword(options.body);
|
||||||
output.push(`${'--data ' + '\''}${serialized}'`);
|
output.push(`${'--data ' + '\''}${serialized}'`);
|
||||||
}
|
}
|
||||||
output.push(`'${url}'`);
|
output.push(`'${url}'`);
|
||||||
|
Loading…
Reference in New Issue
Block a user