-
Notifications
You must be signed in to change notification settings - Fork 85
Add auditing and system admin realm joining #705
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sethvargo The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @mikehelmick @whaught |
2a72ca2
to
6adc5dc
Compare
ca974c1
to
2d70c7d
Compare
audits = append(audits, audit) | ||
} | ||
|
||
// TODO(sethvargo): diff allowed CIDRs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna do this later.
@whaught @mikehelmick okay - this is ready for review now after a few iterations and virtual rubber-ducking. High-level overview:
|
2d70c7d
to
4c9c025
Compare
type AuditEntry struct { | ||
Errorable | ||
|
||
// ID is the entry's ID. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why not the gorm.Model embed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gorm.Model
changes the behavior and semantics for delete. If the resource has DeletedAt
, it soft deletes. Audit entries are also immutable and gorm.Model
includes an unnecessary UpdatedAt
field. Given I expect audit_entries to be our largest table (even with purging), I wanted to keep the number of columns as small as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like two metrics, they can be saved for future work if you'd like.
Unscoped(). | ||
Where("created_at < ?", createdBefore). | ||
Delete(&AuditEntry{}) | ||
return result.RowsAffected, result.Error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a metric, audit_rows_cleaned or something here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally, but it'll be a bit of work because the cleanup job isn't actually configured with metrics right now. I created #716 to add metrics to all the things we cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack, ty.
package database | ||
|
||
// Auditable represents a resource that can be audited as an actor or actee. | ||
type Auditable interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My knowledge of gorm is limited. Is there anyway to do a callback here so that we can increment a counter on every audit entry inserted? If there is, can we do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have access to the tx in the callback, so we can increment a SQL counter (that's how we do the in-app stats actually).
We can create a global callback that has access to metrics and then basically guard it with a if table == "audit_entries"
. What do you hope to glean from counting the number of audits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would love a graph in our dashboards to see how many things are happening on a server from an admin point of view. Basically a stackdriver stat that says x number of actions lets us see the rate of actions happening on an instance. Good for debugging or tracking admin abuse.
c5161de
to
8e7f326
Compare
/lgtm |
* Allow for v1.5+ early key release. Multiple keys can be provided that all have the same start interval * Add configuration params for this * Add tests for new pieces. 100% coverage on exposure model transform. * Add documentation. * add same day release as an optional feature to the generate server Fixes #705 Part of #663
Release Note