Skip to content

Commit

Permalink
VAULT-23122: Audit fix for 'log_raw' issue (#24968) (#24974)
Browse files Browse the repository at this point in the history
* Fix for log_raw issue on audit

* Updates and test change

* changelog

* Update test now that the original event won't have the formatted data

Co-authored-by: Peter Wilson <[email protected]>
  • Loading branch information
1 parent aa769f0 commit 2a72f2a
Show file tree
Hide file tree
Showing 10 changed files with 461 additions and 79 deletions.
24 changes: 20 additions & 4 deletions audit/entry_formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (f *EntryFormatter) Process(ctx context.Context, e *eventlogger.Event) (*ev
return nil, fmt.Errorf("%s: event is nil: %w", op, event.ErrInvalidParameter)
}

a, ok := e.Payload.(*auditEvent)
a, ok := e.Payload.(*AuditEvent)
if !ok {
return nil, fmt.Errorf("%s: cannot parse event payload: %w", op, event.ErrInvalidParameter)
}
Expand Down Expand Up @@ -155,10 +155,26 @@ func (f *EntryFormatter) Process(ctx context.Context, e *eventlogger.Event) (*ev
result = append([]byte(f.prefix), result...)
}

// Store the final format.
e.FormattedAs(f.config.RequiredFormat.String(), result)
// Copy some properties from the event (and audit event) and store the
// format for the next (sink) node to Process.
a2 := &AuditEvent{
ID: a.ID,
Version: a.Version,
Subtype: a.Subtype,
Timestamp: a.Timestamp,
Data: data, // Use the cloned data here rather than a pointer to the original.
}

e2 := &eventlogger.Event{
Type: e.Type,
CreatedAt: e.CreatedAt,
Formatted: make(map[string][]byte), // we are about to set this ourselves.
Payload: a2,
}

e2.FormattedAs(f.config.RequiredFormat.String(), result)

return e, nil
return e2, nil
}

// FormatRequest attempts to format the specified logical.LogInput into a RequestEntry.
Expand Down
Loading

0 comments on commit 2a72f2a

Please sign in to comment.