Chromium Code Reviews| 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 stripCookiesAndLoginInfo; |
| 10 | 10 |
| (...skipping 461 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 stripCookiesAndLoginInfo = function(entry) { |
|
eroman
2015/10/06 17:19:41
This function name doesn't seem accurate anymore,
Bence
2015/10/07 15:18:27
I renamed this function and added TODO to capture
| |
| 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 |