Documentation
¶
Index ¶
- Constants
- Variables
- func Flush(timeout time.Duration) bool
- func Publish(event AuditEvent) error
- func PublishWithContext(ctx context.Context, event AuditEvent) error
- func SetPublisher(publisher Publisher)
- type AuditEvent
- type AuditEventPayload
- type Client
- type DotCased
- type HTTPSyncTransport
- type HTTPTransport
- type MockPublisher
- type NoopHTTPTransport
- type Processor
- type Publisher
- type PublisherOption
- func WithDebug(debug bool) PublisherOption
- func WithHTTPClient(httpClient *http.Client) PublisherOption
- func WithHTTPTimeout(httpTimeout time.Duration) PublisherOption
- func WithHTTPTransport(httpTransport *http.Transport) PublisherOption
- func WithPublishKey(publishKey string) PublisherOption
- func WithPublishURL(publishURL string) PublisherOption
- func WithSilence(silence bool) PublisherOption
- func WithTransport(transport Transporter) PublisherOption
- type PublisherOptions
- type SensitiveRange
- type SensitiveValue
- type Transporter
Constants ¶
const ( // DotCasedKey is the key name for the property that encodes information about // an AuditEvent. DotCasedKey = ".cased" // DefaultSensitiveLabel is the default value used if a particular PII // does not contain a label. DefaultSensitiveLabel = "sensitive-value" )
Variables ¶
var ContextKey = contextKey(0)
ContextKey ...
Logger ...
var Processors = []Processor{ SensitiveDataProcessor, PublishedAtProcessor, }
Processors contains all processors available to transform an audit event before it's published to Cased.
Functions ¶
func PublishWithContext ¶
func PublishWithContext(ctx context.Context, event AuditEvent) error
PublishWithContext enriches the provided audit event with the context set in the request. If the same key is present in both the context and provided audit event, the audit event value will be preserved.
Types ¶
type AuditEvent ¶
type AuditEvent map[string]interface{}
AuditEvent ...
func GetContextFromContext ¶
func GetContextFromContext(ctx context.Context) AuditEvent
GetContextFromContext ...
type AuditEventPayload ¶
type AuditEventPayload struct {
DotCased DotCased `json:".cased"`
AuditEvent AuditEvent
}
AuditEventPayload is the wrapper struct hosting the nestable JSON AuditEvent with the internal `.cased` property with a rich struct.
func NewAuditEventPayload ¶
func NewAuditEventPayload(event AuditEvent) *AuditEventPayload
NewAuditEventPayload ...
func PublishedAtProcessor ¶
func PublishedAtProcessor(aep *AuditEventPayload) *AuditEventPayload
PublishedAtProcessor sets the current time the audit event was published at.
func SensitiveDataProcessor ¶
func SensitiveDataProcessor(aep *AuditEventPayload) *AuditEventPayload
SensitiveDataProcessor adds sensitive data positions based on values.
func (*AuditEventPayload) MarshalJSON ¶
func (aep *AuditEventPayload) MarshalJSON() ([]byte, error)
MarshalJSON ...
func (*AuditEventPayload) UnmarshalJSON ¶
func (aep *AuditEventPayload) UnmarshalJSON(data []byte) error
UnmarshalJSON ...
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the underlying processor that is used by the main API and Hub instances. It must be created with NewClient.
func (Client) Options ¶
func (c Client) Options() PublisherOptions
Options return PublisherOptions for the current Client.
type DotCased ¶
type DotCased struct {
PII map[string][]*SensitiveRange `json:"pii,omitempty"`
ID string `json:"id,omitempty"`
Event AuditEvent `json:"event,omitempty"`
PublisherUserAgent string `json:"publisher_user_agent,omitempty"`
ProcessedAt *time.Time `json:"processed_at,omitempty"`
ReceivedAt *time.Time `json:"received_at,omitempty"`
PublishedAt time.Time `json:"published_at"`
}
DotCased is a reserved property in an audit event containing the original event, any modifications to the event post-processing, timestamps, and more.
type HTTPSyncTransport ¶
type HTTPSyncTransport struct {
// contains filtered or unexported fields
}
HTTPSyncTransport provides a transport that publishes audit events synchronously as they are received.
func NewHTTPSyncTransport ¶
func NewHTTPSyncTransport() *HTTPSyncTransport
NewHTTPSyncTransport returns a transport that publishes audit events synchronously as they are received.
func (*HTTPSyncTransport) Configure ¶
func (t *HTTPSyncTransport) Configure(options PublisherOptions)
Configure prepares the synchronous audit event publisher with provided client options.
func (*HTTPSyncTransport) Flush ¶
func (t *HTTPSyncTransport) Flush(_ time.Duration) bool
Flush is unused.
func (*HTTPSyncTransport) Publish ¶
func (t *HTTPSyncTransport) Publish(event *AuditEventPayload) error
Publish publishes the provided audit event to Cased.
type HTTPTransport ¶
type HTTPTransport struct {
BufferSize int
// contains filtered or unexported fields
}
HTTPTransport ...
func (*HTTPTransport) Configure ¶
func (t *HTTPTransport) Configure(options PublisherOptions)
Configure prepares the asynchronous audit event publisher with provided client options.
func (*HTTPTransport) Flush ¶
func (t *HTTPTransport) Flush(timeout time.Duration) bool
Flush waits for all audit events to be published that are in the buffer.
func (*HTTPTransport) Publish ¶
func (t *HTTPTransport) Publish(event *AuditEventPayload) error
Publish queues the audit event to be published in the asynchronously.
To ensure queued audit events are published at end of process see Flush.
type MockPublisher ¶
type MockPublisher struct {
Events []AuditEvent
// contains filtered or unexported fields
}
func NewMockPublisher ¶
func NewMockPublisher() (*MockPublisher, func())
func NewSilencedMockPublisher ¶
func NewSilencedMockPublisher() (*MockPublisher, func())
func (MockPublisher) Options ¶
func (mp MockPublisher) Options() PublisherOptions
func (*MockPublisher) Publish ¶
func (mp *MockPublisher) Publish(event AuditEvent) error
type NoopHTTPTransport ¶
type NoopHTTPTransport struct{}
NoopHTTPTransport does not publish audit events to Cased.
func NewNoopHTTPTransport ¶
func NewNoopHTTPTransport() *NoopHTTPTransport
NewNoopHTTPTransport returns a client that does not publish audit events to Cased.
func (*NoopHTTPTransport) Configure ¶
func (t *NoopHTTPTransport) Configure(options PublisherOptions)
Configure is a noop operation.
func (*NoopHTTPTransport) Flush ¶
func (t *NoopHTTPTransport) Flush(_ time.Duration) bool
Flush is a noop operation.
func (*NoopHTTPTransport) Publish ¶
func (t *NoopHTTPTransport) Publish(event *AuditEventPayload) error
Publish is a noop operation.
type Processor ¶
type Processor func(*AuditEventPayload) *AuditEventPayload
Processor is the interface necessary for processor functions to implement. It takes the audit event payload that is about to be published and mutates it as necessary.
Each processor should be idempotent and not depend on another processor to be called beforehand.
type Publisher ¶
type Publisher interface {
Publish(event AuditEvent) error
Options() PublisherOptions
Flush(timeout time.Duration) bool
}
Publisher describes the interface for structs that want to publish audit events to Cased.
type PublisherOption ¶
type PublisherOption func(opts *PublisherOptions)
PublisherOption ...
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) PublisherOption
WithHTTPClient ...
func WithHTTPTimeout ¶
func WithHTTPTimeout(httpTimeout time.Duration) PublisherOption
WithHTTPTimeout ...
func WithHTTPTransport ¶
func WithHTTPTransport(httpTransport *http.Transport) PublisherOption
WithHTTPTransport ...
func WithPublishKey ¶
func WithPublishKey(publishKey string) PublisherOption
WithPublishKey configures the publish key used to publish audit events to Cased. You can obtain the publish key from the audit trail settings page within the Cased dashboard.
type PublisherOptions ¶
type PublisherOptions struct {
// PublishURL contains the URL to published Cased events to.
PublishURL string `envconfig:"CASED_PUBLISH_URL" default:"https://publish.cased.com"`
// PublishKey is the publish API key used to publish to an audit trail.
//
// A publish key is associated with a single audit trail and is required if
// you intend to publish events to Cased in your application.
PublishKey string `envconfig:"CASED_PUBLISH_KEY"`
Debug bool `envconfig:"CASED_DEBUG" default:"false"`
// Silence to determine if new events are published to Cased.
Silence bool `envconfig:"CASED_SILENCE" default:"false"`
HTTPClient *http.Client
HTTPTransport *http.Transport
HTTPTimeout time.Duration `envconfig:"CASED_HTTP_TIMEOUT" default:"5s"`
Transport Transporter
}
PublisherOptions ...
type SensitiveRange ¶
type SensitiveRange struct {
Begin int `json:"begin"`
End int `json:"end"`
Label string `json:"label"`
}
SensitiveRange is a range that informs Cased about any sensitive information stored in an AuditEvent.
type SensitiveValue ¶
type SensitiveValue struct {
Value string
Ranges []SensitiveRange
}
SensitiveValue contains the sensitive value and all the sensitive ranges within the provided value.
func NewSensitiveValue ¶
func NewSensitiveValue(value, label string) SensitiveValue
NewSensitiveValue marks an entire string as sensitive.
The marked sensitive value will be encoded upon publishing to Cased.
func (SensitiveValue) MarshalJSON ¶
func (sv SensitiveValue) MarshalJSON() ([]byte, error)
MarshalJSON encodes the provided sensitive value for JSON representation.
type Transporter ¶
type Transporter interface {
Configure(options PublisherOptions)
Publish(event *AuditEventPayload) error
Flush(timeout time.Duration) bool
}
Transporter ...
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
example
|
|
|
basic
command
|
|
|
configuration
command
|
|
|
http
command
|
|
|
sensitive-data
command
|
|