Skip to content

Commit

Permalink
Add writeAuditRPCEvent to agent_oss (#17607)
Browse files Browse the repository at this point in the history
* Add writeAuditRPCEvent to agent_oss

* fix the other diffs

* backport change log
  • Loading branch information
roncodingenthusiast authored Jun 7, 2023
1 parent 1e920a7 commit 8118aae
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/_5740.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
api: (Enterprise only) Add `POST /v1/operator/audit-hash` endpoint to calculate the hash of the data used by the audit log hash function and salt.
```
3 changes: 3 additions & 0 deletions .changelog/_5750.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
cli: (Enterprise only) Add a new `consul operator audit hash` command to retrieve and compare the hash of the data used by the audit log hash function and salt.
```
11 changes: 11 additions & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1621,7 +1621,18 @@ func (a *Agent) RPC(ctx context.Context, method string, args interface{}, reply
method = e + "." + p[1]
}
}

// audit log only on consul clients
_, ok := a.delegate.(*consul.Client)
if ok {
a.writeAuditRPCEvent(method, "OperationStart")
}

a.endpointsLock.RUnlock()

defer func() {
a.writeAuditRPCEvent(method, "OperationComplete")
}()
return a.delegate.RPC(ctx, method, args, reply)
}

Expand Down
4 changes: 4 additions & 0 deletions agent/agent_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ func (a *Agent) AgentEnterpriseMeta() *acl.EnterpriseMeta {
func (a *Agent) registerEntCache() {}

func (*Agent) fillEnterpriseProxyDataSources(*proxycfg.DataSources) {}

func (a *Agent) writeAuditRPCEvent(_ string, _ string) interface{} {
return nil
}
5 changes: 3 additions & 2 deletions agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,9 @@ type ConfigEntries struct {

// Audit allows us to enable and define destinations for auditing
type Audit struct {
Enabled *bool `mapstructure:"enabled"`
Sinks map[string]AuditSink `mapstructure:"sink"`
Enabled *bool `mapstructure:"enabled"`
Sinks map[string]AuditSink `mapstructure:"sink"`
RPCEnabled *bool `mapstructure:"rpc_enabled"`
}

// AuditSink can be provided multiple times to define pipelines for auditing
Expand Down

0 comments on commit 8118aae

Please sign in to comment.