Skip to content

Commit 91bb454

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
[DrJones] Remove X-UIDH
Drive-by: keep removed header names but redact the values. Bug: 375118590 Change-Id: Ib2a039f001c5c394d394641e7be155d4b5af06cf Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5973735 Reviewed-by: Mathias Bynens <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent ac69188 commit 91bb454

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

front_end/panels/freestyler/DrJonesNetworkAgent.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {describeWithMockConnection} from '../../testing/MockConnection.js';
1515
import {createNetworkPanelForMockConnection} from '../../testing/NetworkHelpers.js';
1616
import * as Coordinator from '../../ui/components/render_coordinator/render_coordinator.js';
1717

18-
import {allowHeader, DrJonesNetworkAgent, formatInitiatorUrl, ResponseType} from './freestyler.js';
18+
import {allowHeader, DrJonesNetworkAgent, formatHeaders, formatInitiatorUrl, ResponseType} from './freestyler.js';
1919

2020
const coordinator = Coordinator.RenderCoordinator.RenderCoordinator.instance();
2121

@@ -356,4 +356,17 @@ test`,
356356
});
357357
}
358358
});
359+
360+
describe('formatHeaders', () => {
361+
it('does not redact a header from the list', () => {
362+
assert.strictEqual(formatHeaders('test:', [{name: 'content-type', value: 'foo'}]), 'test:\ncontent-type: foo');
363+
});
364+
365+
it('disallows headers not on the list', () => {
366+
assert.strictEqual(formatHeaders('test:', [{name: 'cookie', value: 'foo'}]), 'test:\ncookie: <redacted>');
367+
assert.strictEqual(formatHeaders('test:', [{name: 'set-cookie', value: 'foo'}]), 'test:\nset-cookie: <redacted>');
368+
assert.strictEqual(
369+
formatHeaders('test:', [{name: 'authorization', value: 'foo'}]), 'test:\nauthorization: <redacted>');
370+
});
371+
});
359372
});

front_end/panels/freestyler/DrJonesNetworkAgent.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ const allowedHeaders = new Set([
260260
'x-request-id',
261261
'x-requested-with',
262262
'x-ua-compatible',
263-
'x-uidh',
264263
'x-wap-profile',
265264
'x-webkit-csp',
266265
'x-xss-protection',
@@ -272,7 +271,19 @@ export function allowHeader(header: SDK.NetworkRequest.NameValue): boolean {
272271

273272
export function formatHeaders(title: string, headers: SDK.NetworkRequest.NameValue[]): string {
274273
return formatLines(
275-
title, headers.filter(allowHeader).map(header => header.name + ': ' + header.value + '\n'), MAX_HEADERS_SIZE);
274+
title,
275+
headers
276+
.map(header => {
277+
if (allowHeader(header)) {
278+
return header;
279+
}
280+
return {
281+
name: header.name,
282+
value: '<redacted>',
283+
};
284+
})
285+
.map(header => header.name + ': ' + header.value + '\n'),
286+
MAX_HEADERS_SIZE);
276287
}
277288

278289
export function formatNetworkRequestTiming(request: SDK.NetworkRequest.NetworkRequest): string {

0 commit comments

Comments
 (0)