audit
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- func BuildAudit[T Auditable](ctx context.Context, p *BuildAuditParams[T])
- func Empty[T Auditable]() T
- func ResourceID[T Auditable](tgt T) uuid.UUID
- func ResourceTarget[T Auditable](tgt T) string
- func ResourceType[T Auditable](tgt T) database.ResourceType
- type AdditionalFields
- type Auditable
- type Auditor
- type BuildAuditParams
- type Differ
- type Map
- type MockAuditor
- type OldNew
- type Request
- type RequestParams
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcBuildAudit¶added inv0.13.0
func BuildAudit[TAuditable](ctxcontext.Context, p *BuildAuditParams[T])
BuildAudit creates an audit log for a workspace build.The audit log is committed upon invocation.
funcResourceID¶added inv0.8.15
funcResourceTarget¶added inv0.8.15
funcResourceType¶added inv0.8.15
func ResourceType[TAuditable](tgt T)database.ResourceType
Types¶
typeAdditionalFields¶added inv0.16.0
type AdditionalFields struct {WorkspaceNamestring `json:"workspace_name"`BuildNumberstring `json:"build_number"`BuildReasondatabase.BuildReason `json:"build_reason"`WorkspaceOwnerstring `json:"workspace_owner"`}
typeAuditable¶
type Auditable interface {database.APIKey |database.Template |database.TemplateVersion |database.User |database.Workspace |database.GitSSHKey |database.WorkspaceBuild |database.AuditableGroup |database.License |database.WorkspaceProxy |database.AuditOAuthConvertState}
Auditable is mostly a marker interface. It contains a definitive list of allauditable types. If you want to audit a new type, first define it inAuditableResources, then add it to this interface.
typeAuditor¶added inv0.8.11
typeBuildAuditParams¶added inv0.13.0
typeDiffer¶added inv0.8.11
Differ is used so the enterprise version can implement the diff function inthe Auditor feature interface. Only types in the same package as theinterface can implement unexported methods.
typeMap¶
Map is a map of changed fields in an audited resource. It maps field names tothe old and new value for that field.
typeMockAuditor¶added inv0.8.15
type MockAuditor struct {// contains filtered or unexported fields}
funcNewMock¶added inv0.8.15
func NewMock() *MockAuditor
func (*MockAuditor)AuditLogs¶added inv0.8.15
func (a *MockAuditor) AuditLogs() []database.AuditLog
func (*MockAuditor)ResetLogs¶added inv0.25.0
func (a *MockAuditor) ResetLogs()
ResetLogs removes all audit logs from the mock auditor.This is helpful for testing to get a clean slate.
typeRequest¶added inv0.8.11
type Request[TAuditable] struct {Old TNew T// This optional field can be passed in when the userID cannot be determined from the API Key// such as in the case of login, when the audit log is created prior the API Key's existence.UserIDuuid.UUID// This optional field can be passed in if the AuditAction must be overridden// such as in the case of new user authentication when the Audit Action is 'register', not 'login'.Actiondatabase.AuditAction// contains filtered or unexported fields}
funcInitRequest¶added inv0.8.11
func InitRequest[TAuditable](whttp.ResponseWriter, p *RequestParams) (*Request[T], func())
InitRequest initializes an audit log for a request. It returns a functionthat should be deferred, causing the audit log to be committed when thehandler returns.
typeRequestParams¶added inv0.8.11
type RequestParams struct {AuditAuditorLogslog.LoggerRequest *http.RequestActiondatabase.AuditActionAdditionalFieldsjson.RawMessage}