@@ -181,12 +181,44 @@ class CheReporter extends mocha.reporters.Spec {
181
181
const networkLogsEntries : logging . Entry [ ] = await this . driverHelper . getDriver ( ) . manage ( ) . logs ( ) . get ( 'performance' ) ;
182
182
const events : any [ ] = networkLogsEntries . map ( ( entry ) : any [ ] => JSON . parse ( entry . message ) . message ) ;
183
183
const har : any = chromeHar . harFromMessages ( events , { includeTextFromResponseBody : true } ) ;
184
+ this . redactHarContent ( har ) ;
185
+
184
186
const networkLogsStream : WriteStream = fs . createWriteStream ( harFileName ) ;
185
187
networkLogsStream . write ( Buffer . from ( JSON . stringify ( har ) ) , ( ) : void => {
186
188
networkLogsStream . end ( ) ;
187
189
} ) ;
188
190
} ) ;
189
191
}
192
+
193
+ redactHarContent ( har : any ) : void {
194
+ har . log ?. entries ?. forEach ( ( entry : any ) : void => {
195
+ let text : string | undefined = entry . request ?. postData ?. text ;
196
+ if ( text ) {
197
+ text = StringUtil . updateUrlQueryValue ( text , 'csrf' , '<REDACTED>' ) ;
198
+ text = StringUtil . updateUrlQueryValue ( text , 'username' , '<REDACTED>' ) ;
199
+ entry . request . postData . text = StringUtil . updateUrlQueryValue ( text , 'password' , '<REDACTED>' ) ;
200
+ }
201
+
202
+ const cookies : any = entry . request ?. cookies ;
203
+ if ( cookies ) {
204
+ cookies . forEach ( ( cookie : any ) : void => {
205
+ if ( cookie . name ?. startsWith ( '_oauth_proxy' ) ) {
206
+ cookie . value = '<REDACTED>' ;
207
+ }
208
+ } ) ;
209
+ }
210
+
211
+ const headers : any = entry . request ?. headers ;
212
+ if ( headers ) {
213
+ headers . forEach ( ( header : any ) : void => {
214
+ if ( header . name ?. toLowerCase ( ) === 'cookie' ) {
215
+ header . value = StringUtil . updateCookieValue ( header . value , '_oauth_proxy' , '<REDACTED>' ) ;
216
+ header . value = StringUtil . updateCookieValue ( header . value , '_oauth_proxy_csrf' , '<REDACTED>' ) ;
217
+ }
218
+ } ) ;
219
+ }
220
+ } ) ;
221
+ }
190
222
}
191
223
192
224
export = CheReporter ;
0 commit comments