Skip to content

Commit 42488ab

Browse files
committed
feat: redact 'accessToken' and 'apiKey'
1 parent d7baa9e commit 42488ab

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

electron/common/logger/__tests__/logger-format.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,14 @@ describe('logger-format', () => {
9696
it('should mask sensitive values', () => {
9797
const data = {
9898
password: 'secret',
99-
key: 'secret',
99+
apiKey: 'secret',
100100
};
101101

102102
const result = formatLogData(data);
103103

104104
expect(result).toEqual({
105105
password: '***REDACTED***',
106-
key: '***REDACTED***',
106+
apiKey: '***REDACTED***',
107107
});
108108
});
109109
});

electron/common/logger/__tests__/logger-mask.test.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,32 @@ import { isNotMaskable, maskSensitiveValues } from '../logger.mask';
33
describe('logger-mask', () => {
44
describe('#maskSensitiveValues', () => {
55
const data: Record<string, any> = {
6-
key: 'key1',
6+
accessToken: 'accessToken1',
77
password: 'password1',
88
apiKey: 'apiKey1',
99
credential: 'credential1',
1010
nested: {
11-
key: 'key2',
11+
accessToken: 'accessToken2',
1212
password: 'password2',
1313
apiKey: 'apiKey2',
1414
credential: 'credential2',
1515
},
1616
};
1717

18-
it('should mask password and key properties by default', () => {
18+
it('should mask password, accessToken, and apiKey properties by default', () => {
1919
const result = maskSensitiveValues({
2020
json: data,
2121
});
2222

2323
expect(result).toEqual({
24-
key: '***REDACTED***',
24+
accessToken: '***REDACTED***',
2525
password: '***REDACTED***',
26-
apiKey: 'apiKey1',
26+
apiKey: '***REDACTED***',
2727
credential: 'credential1',
2828
nested: {
29-
key: '***REDACTED***',
29+
accessToken: '***REDACTED***',
3030
password: '***REDACTED***',
31-
apiKey: 'apiKey2',
31+
apiKey: '***REDACTED***',
3232
credential: 'credential2',
3333
},
3434
});
@@ -41,12 +41,12 @@ describe('logger-mask', () => {
4141
});
4242

4343
expect(result).toEqual({
44-
key: 'key1',
44+
accessToken: 'accessToken1',
4545
password: 'password1',
4646
apiKey: '***REDACTED***',
4747
credential: '***REDACTED***',
4848
nested: {
49-
key: 'key2',
49+
accessToken: 'accessToken2',
5050
password: 'password2',
5151
apiKey: '***REDACTED***',
5252
credential: '***REDACTED***',
@@ -62,12 +62,12 @@ describe('logger-mask', () => {
6262
});
6363

6464
expect(result).toEqual({
65-
key: 'key1',
65+
accessToken: 'accessToken1',
6666
password: 'password1',
6767
apiKey: '***MASKED***',
6868
credential: '***MASKED***',
6969
nested: {
70-
key: 'key2',
70+
accessToken: 'accessToken2',
7171
password: 'password2',
7272
apiKey: '***MASKED***',
7373
credential: '***MASKED***',

electron/common/logger/logger.mask.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export function maskSensitiveValues(options: {
2121
*/
2222
mask?: string;
2323
}): any {
24-
const { json, keys = ['password', 'key'], mask = '***REDACTED***' } = options;
24+
const {
25+
json,
26+
keys = ['password', 'accessToken', 'apiKey'],
27+
mask = '***REDACTED***',
28+
} = options;
2529

2630
if (isNotMaskable(json)) {
2731
return json;

0 commit comments

Comments
 (0)