2023-03-15 16:00:52 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2015-04-13 21:12:03 +00:00
|
|
|
package audit
|
|
|
|
|
|
|
|
import (
|
2018-03-08 19:21:11 +00:00
|
|
|
"context"
|
2015-04-13 21:12:03 +00:00
|
|
|
"io"
|
2019-05-22 22:52:53 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/vault/sdk/logical"
|
2015-04-13 21:12:03 +00:00
|
|
|
)
|
|
|
|
|
Add option 'elide_list_responses' to audit backends (#18128)
This PR relates to a feature request logged through HashiCorp commercial
support.
Vault lacks pagination in its APIs. As a result, certain list operations
can return **very** large responses. The user's chosen audit sinks may
experience difficulty consuming audit records that swell to tens of
megabytes of JSON.
In our case, one of the systems consuming audit log data could not cope,
and failed.
The responses of list operations are typically not very interesting, as
they are mostly lists of keys, or, even when they include a "key_info"
field, are not returning confidential information. They become even less
interesting once HMAC-ed by the audit system.
Some example Vault "list" operations that are prone to becoming very
large in an active Vault installation are:
auth/token/accessors/
identity/entity/id/
identity/entity-alias/id/
pki/certs/
In response, I've coded a new option that can be applied to audit
backends, `elide_list_responses`. When enabled, response data is elided
from audit logs, only when the operation type is "list".
For added safety, the elision only applies to the "keys" and "key_info"
fields within the response data - these are conventionally the only
fields present in a list response - see logical.ListResponse, and
logical.ListResponseWithInfo. However, other fields are technically
possible if a plugin author writes unusual code, and these will be
preserved in the audit log even with this option enabled.
The elision replaces the values of the "keys" and "key_info" fields with
an integer count of the number of entries. This allows even the elided
audit logs to still be useful for answering questions like "Was any data
returned?" or "How many records were listed?".
2023-01-11 21:15:52 +00:00
|
|
|
// Formatter is an interface that is responsible for formatting a
|
2015-04-13 21:12:03 +00:00
|
|
|
// request/response into some format. Formatters write their output
|
|
|
|
// to an io.Writer.
|
2015-04-22 05:42:37 +00:00
|
|
|
//
|
|
|
|
// It is recommended that you pass data through Hash prior to formatting it.
|
2015-04-13 21:12:03 +00:00
|
|
|
type Formatter interface {
|
2019-05-22 22:52:53 +00:00
|
|
|
FormatRequest(context.Context, io.Writer, FormatterConfig, *logical.LogInput) error
|
|
|
|
FormatResponse(context.Context, io.Writer, FormatterConfig, *logical.LogInput) error
|
2016-09-21 14:29:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type FormatterConfig struct {
|
|
|
|
Raw bool
|
|
|
|
HMACAccessor bool
|
|
|
|
|
Add option 'elide_list_responses' to audit backends (#18128)
This PR relates to a feature request logged through HashiCorp commercial
support.
Vault lacks pagination in its APIs. As a result, certain list operations
can return **very** large responses. The user's chosen audit sinks may
experience difficulty consuming audit records that swell to tens of
megabytes of JSON.
In our case, one of the systems consuming audit log data could not cope,
and failed.
The responses of list operations are typically not very interesting, as
they are mostly lists of keys, or, even when they include a "key_info"
field, are not returning confidential information. They become even less
interesting once HMAC-ed by the audit system.
Some example Vault "list" operations that are prone to becoming very
large in an active Vault installation are:
auth/token/accessors/
identity/entity/id/
identity/entity-alias/id/
pki/certs/
In response, I've coded a new option that can be applied to audit
backends, `elide_list_responses`. When enabled, response data is elided
from audit logs, only when the operation type is "list".
For added safety, the elision only applies to the "keys" and "key_info"
fields within the response data - these are conventionally the only
fields present in a list response - see logical.ListResponse, and
logical.ListResponseWithInfo. However, other fields are technically
possible if a plugin author writes unusual code, and these will be
preserved in the audit log even with this option enabled.
The elision replaces the values of the "keys" and "key_info" fields with
an integer count of the number of entries. This allows even the elided
audit logs to still be useful for answering questions like "Was any data
returned?" or "How many records were listed?".
2023-01-11 21:15:52 +00:00
|
|
|
// Vault lacks pagination in its APIs. As a result, certain list operations can return **very** large responses.
|
|
|
|
// The user's chosen audit sinks may experience difficulty consuming audit records that swell to tens of megabytes
|
|
|
|
// of JSON. The responses of list operations are typically not very interesting, as they are mostly lists of keys,
|
|
|
|
// or, even when they include a "key_info" field, are not returning confidential information. They become even less
|
|
|
|
// interesting once HMAC-ed by the audit system.
|
|
|
|
//
|
|
|
|
// Some example Vault "list" operations that are prone to becoming very large in an active Vault installation are:
|
|
|
|
// auth/token/accessors/
|
|
|
|
// identity/entity/id/
|
|
|
|
// identity/entity-alias/id/
|
|
|
|
// pki/certs/
|
|
|
|
//
|
|
|
|
// This option exists to provide such users with the option to have response data elided from audit logs, only when
|
|
|
|
// the operation type is "list". For added safety, the elision only applies to the "keys" and "key_info" fields
|
|
|
|
// within the response data - these are conventionally the only fields present in a list response - see
|
|
|
|
// logical.ListResponse, and logical.ListResponseWithInfo. However, other fields are technically possible if a
|
|
|
|
// plugin author writes unusual code, and these will be preserved in the audit log even with this option enabled.
|
|
|
|
// The elision replaces the values of the "keys" and "key_info" fields with an integer count of the number of
|
|
|
|
// entries. This allows even the elided audit logs to still be useful for answering questions like
|
|
|
|
// "Was any data returned?" or "How many records were listed?".
|
|
|
|
ElideListResponses bool
|
|
|
|
|
2016-09-21 14:29:42 +00:00
|
|
|
// This should only ever be used in a testing context
|
|
|
|
OmitTime bool
|
2015-04-13 21:12:03 +00:00
|
|
|
}
|