-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DH-18086: gRPC transport logging ### Testing I tested this using a local http1 proxy on a Grizzly dev server to see errors logged via gRPC transport. I was able to see the following when creating new Core+ workers: ``` [NodeHttp2gRPCTransport] ERROR: Session error Error: Protocol error at Http2Session.onSessionInternalError (node:internal/http2/core:793:26) at Http2Session.callbackTrampoline (node:internal/async_hooks:130:17) ``` I also tested without the proxy and can see debug messages for gRPC transport communication. This is easy to test by connecting a server and looking at the Output -> Deephaven Debug panel and looking for [NodeHttp2gRPCTransport] messages.
- Loading branch information
Showing
9 changed files
with
160 additions
and
31 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { CENSORED_TEXT } from '../common'; | ||
import { hasProperty } from './dataUtils'; | ||
|
||
/** | ||
* Sanitize an auth header value. | ||
* @param authHeaderValue Sanitize secret portion of known auth headers. If | ||
* unrecognized, replace the whole thing. | ||
* @returns The sanitized auth header value. | ||
*/ | ||
export function sanitizeAuthHeaderValue(authHeaderValue: string): string { | ||
if ( | ||
authHeaderValue.startsWith('io.deephaven.proto.auth.Token') || | ||
authHeaderValue.startsWith('Bearer') | ||
) { | ||
return authHeaderValue.replace(/ \S+$/, ` ${CENSORED_TEXT}`); | ||
} | ||
|
||
return CENSORED_TEXT; | ||
} | ||
|
||
/** | ||
* Sanitize an auth header. | ||
* @param authorization The authorization header value. This can be a string | ||
* or an array of strings. Any other data types will be treated as an empty | ||
* string. | ||
* @returns The sanitized auth header value. | ||
*/ | ||
export function sanitizeAuthHeader(authorization: unknown): string | string[] { | ||
if (typeof authorization === 'string') { | ||
return sanitizeAuthHeaderValue(authorization); | ||
} | ||
|
||
if (Array.isArray(authorization)) { | ||
return authorization.map(sanitizeAuthHeaderValue); | ||
} | ||
|
||
return CENSORED_TEXT; | ||
} | ||
|
||
/** | ||
* Sanitize auth headers in a gRPC log message. | ||
* @param args The arguments to sanitize. | ||
* @returns The sanitized arguments. | ||
*/ | ||
export function sanitizeGRPCLogMessageArgs([ | ||
arg0, | ||
arg1, | ||
...args | ||
]: unknown[]): unknown[] { | ||
if (arg0 === 'start' && hasProperty(arg1, 'authorization')) { | ||
return [ | ||
arg0, | ||
{ | ||
...arg1, | ||
authorization: sanitizeAuthHeader(arg1.authorization), | ||
}, | ||
]; | ||
} | ||
|
||
return [arg0, arg1, ...args]; | ||
} |