OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // TODO(eroman): put these methods into a namespace. | 5 // TODO(eroman): put these methods into a namespace. |
6 | 6 |
7 var createLogEntryTablePrinter; | 7 var createLogEntryTablePrinter; |
8 var proxySettingsToString; | 8 var proxySettingsToString; |
9 var stripCookiesAndLoginInfo; | 9 var stripCookiesAndLoginInfoAndGoAwayDebugData; |
10 | 10 |
11 // Start of anonymous namespace. | 11 // Start of anonymous namespace. |
12 (function() { | 12 (function() { |
13 'use strict'; | 13 'use strict'; |
14 | 14 |
15 function canCollapseBeginWithEnd(beginEntry) { | 15 function canCollapseBeginWithEnd(beginEntry) { |
16 return beginEntry && | 16 return beginEntry && |
17 beginEntry.isBegin() && | 17 beginEntry.isBegin() && |
18 beginEntry.end && | 18 beginEntry.end && |
19 beginEntry.end.index == beginEntry.index + 1 && | 19 beginEntry.end.index == beginEntry.index + 1 && |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 })(); // end of ParameterOutputter | 237 })(); // end of ParameterOutputter |
238 | 238 |
239 /** | 239 /** |
240 * Formats the parameters for |entry| and writes them to |out|. | 240 * Formats the parameters for |entry| and writes them to |out|. |
241 * Certain event types have custom pretty printers. Everything else will | 241 * Certain event types have custom pretty printers. Everything else will |
242 * default to a JSON-like format. | 242 * default to a JSON-like format. |
243 */ | 243 */ |
244 function writeParameters(entry, privacyStripping, out) { | 244 function writeParameters(entry, privacyStripping, out) { |
245 if (privacyStripping) { | 245 if (privacyStripping) { |
246 // If privacy stripping is enabled, remove data as needed. | 246 // If privacy stripping is enabled, remove data as needed. |
247 entry = stripCookiesAndLoginInfo(entry); | 247 entry = stripCookiesAndLoginInfoAndGoAwayDebugData(entry); |
248 } else { | 248 } else { |
249 // If headers are in an object, convert them to an array for better display. | 249 // If headers are in an object, convert them to an array for better display. |
250 entry = reformatHeaders(entry); | 250 entry = reformatHeaders(entry); |
251 } | 251 } |
252 | 252 |
253 // Use any parameter writer available for this event type. | 253 // Use any parameter writer available for this event type. |
254 var paramsWriter = getParamaterWriterForEventType(entry.type); | 254 var paramsWriter = getParamaterWriterForEventType(entry.type); |
255 var consumedParams = {}; | 255 var consumedParams = {}; |
256 if (paramsWriter) | 256 if (paramsWriter) |
257 paramsWriter(entry, out, consumedParams); | 257 paramsWriter(entry, out, consumedParams); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 headers.push(key + ': ' + entry.params.headers[key]); | 472 headers.push(key + ': ' + entry.params.headers[key]); |
473 entry.params.headers = headers; | 473 entry.params.headers = headers; |
474 | 474 |
475 return entry; | 475 return entry; |
476 } | 476 } |
477 | 477 |
478 /** | 478 /** |
479 * Removes a cookie or unencrypted login information from a single HTTP header | 479 * Removes a cookie or unencrypted login information from a single HTTP header |
480 * line, if present, and returns the modified line. Otherwise, just returns | 480 * line, if present, and returns the modified line. Otherwise, just returns |
481 * the original line. | 481 * the original line. |
482 * | |
483 * Note: this logic should be kept in sync with | |
484 * net::ElideHeaderValueForNetLog in net/http/http_log_util.cc. | |
482 */ | 485 */ |
483 function stripCookieOrLoginInfo(line) { | 486 function stripCookieOrLoginInfo(line) { |
484 var patterns = [ | 487 var patterns = [ |
485 // Cookie patterns | 488 // Cookie patterns |
486 /^set-cookie: /i, | 489 /^set-cookie: /i, |
487 /^set-cookie2: /i, | 490 /^set-cookie2: /i, |
488 /^cookie: /i, | 491 /^cookie: /i, |
489 | 492 |
490 // Unencrypted authentication patterns | 493 // Unencrypted authentication patterns |
491 /^authorization: \S*\s*/i, | 494 /^authorization: \S*\s*/i, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
538 // This is often the case when viewing a loaded log. | 541 // This is often the case when viewing a loaded log. |
539 if (suffix.search(/^\[[0-9]+ bytes were stripped\]$/) == -1) { | 542 if (suffix.search(/^\[[0-9]+ bytes were stripped\]$/) == -1) { |
540 return prefix + '[' + suffix.length + ' bytes were stripped]'; | 543 return prefix + '[' + suffix.length + ' bytes were stripped]'; |
541 } | 544 } |
542 } | 545 } |
543 | 546 |
544 return line; | 547 return line; |
545 } | 548 } |
546 | 549 |
547 /** | 550 /** |
551 * Remove debug data from HTTP/2 GOAWAY frame due to privacy considerations, see | |
552 * https://httpwg.github.io/specs/rfc7540.html#GOAWAY. | |
553 * | |
554 * Note: this logic should be kept in sync with | |
555 * net::ElideGoAwayDebugDataForNetLog in net/http/http_log_util.cc. | |
556 */ | |
557 function stripGoAwayDebugData(value) { | |
558 return '[' + value.length + ' bytes were stripped]'; | |
559 } | |
560 | |
561 /** | |
548 * If |entry| has headers, returns a copy of |entry| with all cookie and | 562 * If |entry| has headers, returns a copy of |entry| with all cookie and |
549 * unencrypted login text removed. Otherwise, returns original |entry| object. | 563 * unencrypted login text removed. Otherwise, returns original |entry| object. |
550 * This is needed so that JSON log dumps can be made without affecting the | 564 * This is needed so that JSON log dumps can be made without affecting the |
551 * source data. Converts headers stored in objects to arrays. | 565 * source data. Converts headers stored in objects to arrays. |
552 * | |
553 * Note: this logic should be kept in sync with | |
554 * net::ElideHeaderForNetLog in net/http/http_log_util.cc. | |
555 */ | 566 */ |
556 stripCookiesAndLoginInfo = function(entry) { | 567 stripCookiesAndLoginInfoAndGoAwayDebugData = function(entry) { |
eroman
2015/10/07 17:00:51
This name is accurate however a bit too long IMO.
Bence
2015/10/30 11:55:26
stripPrivacyInfo sounds a lot better, should have
| |
557 if (!entry.params || entry.params.headers === undefined || | 568 if (!entry.params) { |
569 return entry; | |
570 } | |
571 | |
572 if (entry.type == EventType.HTTP2_SESSION_GOAWAY && | |
573 entry.params.debug_data != undefined) { | |
574 // Duplicate the top level object, and |entry.params|. All other fields are | |
575 // just pointers to the original values, as they won't be modified, other | |
576 // than |entry.params.debug_data|. | |
577 entry = shallowCloneObject(entry); | |
578 entry.params = shallowCloneObject(entry.params); | |
579 entry.params.debug_data = | |
580 stripGoAwayDebugData(entry.params.debug_data); | |
581 return entry; | |
582 } | |
583 | |
584 if (entry.params.headers === undefined || | |
558 !(entry.params.headers instanceof Object)) { | 585 !(entry.params.headers instanceof Object)) { |
559 return entry; | 586 return entry; |
560 } | 587 } |
561 | 588 |
562 // Make sure entry's headers are in an array. | 589 // Make sure entry's headers are in an array. |
563 entry = reformatHeaders(entry); | 590 entry = reformatHeaders(entry); |
564 | 591 |
565 // Duplicate the top level object, and |entry.params|. All other fields are | 592 // Duplicate the top level object, and |entry.params|. All other fields are |
566 // just pointers to the original values, as they won't be modified, other than | 593 // just pointers to the original values, as they won't be modified, other than |
567 // |entry.params.headers|. | 594 // |entry.params.headers|. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 } | 802 } |
776 | 803 |
777 if (config.source != undefined && config.source != 'UNKNOWN') | 804 if (config.source != undefined && config.source != 'UNKNOWN') |
778 result.push('Source: ' + config.source); | 805 result.push('Source: ' + config.source); |
779 | 806 |
780 return result.join('\n'); | 807 return result.join('\n'); |
781 }; | 808 }; |
782 | 809 |
783 // End of anonymous namespace. | 810 // End of anonymous namespace. |
784 })(); | 811 })(); |
OLD | NEW |