docs(config): Don't show [template] for long strings (#16224)

This commit is contained in:
Gabriel-Ladzaretti 2022-06-28 16:49:42 +03:00 committed by GitHub
parent db4160a205
commit 7ac91e452c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 8 deletions

View file

@ -160,13 +160,14 @@ describe('logger/index', () => {
constructor(public field: string) {} constructor(public field: string) {}
} }
const prBody = 'test';
logger.error({ logger.error({
foo: 'secret"password', foo: 'secret"password',
bar: ['somethingelse', 'secret"password'], bar: ['somethingelse', 'secret"password'],
npmToken: 'token', npmToken: 'token',
buffer: Buffer.from('test'), buffer: Buffer.from('test'),
content: 'test', content: 'test',
prBody: 'test', prBody,
secrets: { secrets: {
foo: 'barsecret', foo: 'barsecret',
}, },
@ -181,7 +182,7 @@ describe('logger/index', () => {
expect(logged.npmToken).not.toBe('token'); expect(logged.npmToken).not.toBe('token');
expect(logged.buffer).toBe('[content]'); expect(logged.buffer).toBe('[content]');
expect(logged.content).toBe('[content]'); expect(logged.content).toBe('[content]');
expect(logged.prBody).toBe('[Template]'); expect(logged.prBody).toBe(prBody);
expect(logged.secrets.foo).toBe('***********'); expect(logged.secrets.foo).toBe('***********');
expect(logged.someFn).toBe('[function]'); expect(logged.someFn).toBe('[function]');
expect(logged.someObject.field).toBe('**redacted**'); expect(logged.someObject.field).toBe('**redacted**');

View file

@ -39,7 +39,7 @@ export class ProblemStream extends Stream {
this._problems = []; this._problems = [];
} }
} }
const templateFields = ['prBody'];
const contentFields = [ const contentFields = [
'content', 'content',
'contents', 'contents',
@ -148,8 +148,6 @@ export function sanitizeValue(
curValue = '***********'; curValue = '***********';
} else if (contentFields.includes(key)) { } else if (contentFields.includes(key)) {
curValue = '[content]'; curValue = '[content]';
} else if (templateFields.includes(key)) {
curValue = '[Template]';
} else if (key === 'secrets') { } else if (key === 'secrets') {
curValue = {}; curValue = {};
Object.keys(val).forEach((secretKey) => { Object.keys(val).forEach((secretKey) => {

View file

@ -116,9 +116,6 @@ function genTable(obj: [string, string][], type: string, def: any): string {
) { ) {
el[1] = `<code>${el[1]}</code>`; el[1] = `<code>${el[1]}</code>`;
} }
if (type === 'string' && el[0] === 'default' && el[1].length > 200) {
el[1] = `[template]`;
}
// objects and arrays should be printed in JSON notation // objects and arrays should be printed in JSON notation
if ((type === 'object' || type === 'array') && el[0] === 'default') { if ((type === 'object' || type === 'array') && el[0] === 'default') {
// only show array and object defaults if they are not null and are not empty // only show array and object defaults if they are not null and are not empty