mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Updates header filters for request logs. (#162062)
## Summary Updates [header](https://www.elastic.co/guide/en/elasticsearch/reference/master/jwt-auth-realm.html#hmac-oidc-example-request-headers) filters for request logs. /cc @elastic/kibana-security
This commit is contained in:
parent
e1352db526
commit
303575544a
4 changed files with 46 additions and 2 deletions
|
@ -91,6 +91,23 @@ describe('getEcsResponseLog', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
test('redacts es-client-authentication headers by default', () => {
|
||||
const event = createResponseEvent({
|
||||
requestParams: {
|
||||
headers: { 'es-client-authentication': 'ae3fda37-xxx', 'user-agent': 'world' },
|
||||
},
|
||||
response: { headers: { 'content-length': '123' } },
|
||||
});
|
||||
const log = getEcsResponseLog(event);
|
||||
// @ts-expect-error ECS custom field
|
||||
expect(log.http.request.headers).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"es-client-authentication": "[REDACTED]",
|
||||
"user-agent": "world",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('does not mutate original headers', () => {
|
||||
const reqHeaders = { a: 'foo', b: ['hello', 'world'] };
|
||||
const resHeaders = { c: 'bar' };
|
||||
|
|
|
@ -12,7 +12,13 @@ import { type LogMeta } from '@kbn/logging';
|
|||
|
||||
// If you are updating these, consider whether they should also be updated in the
|
||||
// http service `getResponseLog`
|
||||
const FORBIDDEN_HEADERS = ['authorization', 'cookie', 'set-cookie', 'x-elastic-app-auth'];
|
||||
const FORBIDDEN_HEADERS = [
|
||||
'authorization',
|
||||
'cookie',
|
||||
'set-cookie',
|
||||
'x-elastic-app-auth',
|
||||
'es-client-authentication',
|
||||
];
|
||||
const REDACTED_HEADER_TEXT = '[REDACTED]';
|
||||
|
||||
// We are excluding sensitive headers by default, until we have a log filtering mechanism.
|
||||
|
|
|
@ -211,6 +211,21 @@ describe('getEcsResponseLog', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
test('redacts es-client-authentication headers by default', () => {
|
||||
const req = createMockHapiRequest({
|
||||
headers: { 'es-client-authentication': 'ae3fda37-xxx', 'user-agent': 'world' },
|
||||
response: { headers: { 'content-length': '123' } },
|
||||
});
|
||||
const result = getEcsResponseLog(req, logger);
|
||||
// @ts-expect-error ECS custom field
|
||||
expect(result.meta.http.request.headers).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"es-client-authentication": "[REDACTED]",
|
||||
"user-agent": "world",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('does not mutate original headers', () => {
|
||||
const reqHeaders = { a: 'foo', b: ['hello', 'world'] };
|
||||
const resHeaders = { headers: { c: 'bar' } };
|
||||
|
|
|
@ -16,7 +16,13 @@ import { getResponsePayloadBytes } from './get_payload_size';
|
|||
|
||||
// If you are updating these, consider whether they should also be updated in the
|
||||
// elasticsearch service `getEcsResponseLog`
|
||||
const FORBIDDEN_HEADERS = ['authorization', 'cookie', 'set-cookie', 'x-elastic-app-auth'];
|
||||
const FORBIDDEN_HEADERS = [
|
||||
'authorization',
|
||||
'cookie',
|
||||
'set-cookie',
|
||||
'x-elastic-app-auth',
|
||||
'es-client-authentication',
|
||||
];
|
||||
const REDACTED_HEADER_TEXT = '[REDACTED]';
|
||||
|
||||
type HapiHeaders = Record<string, string | string[]>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue