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 BackgroundAudit[T Auditable](ctx context.Context, p *BackgroundAuditParams[T])
- func BackgroundTaskFields(subsystem BackgroundSubsystem) map[string]string
- func BackgroundTaskFieldsBytes(ctx context.Context, logger slog.Logger, subsystem BackgroundSubsystem) []byte
- func BaggageToContext(ctx context.Context, d Baggage) (context.Context, error)
- func Empty[T Auditable]() T
- func ParseIP(ipStr string) pqtype.Inet
- func ResourceID[T Auditable](tgt T) uuid.UUID
- func ResourceRequiresOrgID[T Auditable]() bool
- func ResourceTarget[T Auditable](tgt T) string
- func ResourceType[T Auditable](tgt T) database.ResourceType
- type AdditionalFields
- type Auditable
- type Auditor
- type BackgroundAuditParams
- type BackgroundSubsystem
- type Baggage
- type Differ
- type Map
- type MockAuditor
- type OldNew
- type Request
- type RequestParams
- type WorkspaceBuildBaggage
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcBackgroundAudit¶added inv2.5.0
func BackgroundAudit[TAuditable](ctxcontext.Context, p *BackgroundAuditParams[T])
BackgroundAudit creates an audit log for a background event.The audit log is committed upon invocation.
funcBackgroundTaskFields¶added inv2.17.0
func BackgroundTaskFields(subsystemBackgroundSubsystem) map[string]string
funcBackgroundTaskFieldsBytes¶added inv2.17.0
funcBaggageToContext¶added inv2.3.2
funcResourceID¶
funcResourceRequiresOrgID¶added inv2.9.0
ResourceRequiresOrgID will ensure given resources are always audited with anorganization ID.
funcResourceTarget¶
funcResourceType¶
func ResourceType[TAuditable](tgt T)database.ResourceType
Types¶
typeAuditable¶
type Auditable interface {database.APIKey |database.Template |database.TemplateVersion |database.User |database.WorkspaceTable |database.GitSSHKey |database.WorkspaceBuild |database.AuditableGroup |database.License |database.WorkspaceProxy |database.AuditOAuthConvertState |database.HealthSettings |database.NotificationsSettings |database.OAuth2ProviderApp |database.OAuth2ProviderAppSecret |database.CustomRole |database.AuditableOrganizationMember |database.Organization |database.NotificationTemplate |idpsync.OrganizationSyncSettings |idpsync.GroupSyncSettings |idpsync.RoleSyncSettings |database.WorkspaceAgent |database.WorkspaceApp}
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¶
typeBackgroundAuditParams¶added inv2.5.0
type BackgroundAuditParams[TAuditable] struct {AuditAuditorLogslog.LoggerUserIDuuid.UUIDRequestIDuuid.UUIDTimetime.TimeStatusintActiondatabase.AuditActionOrganizationIDuuid.UUIDIPstringUserAgentstring// todo: this should automatically marshal an interface{} instead of accepting a raw message.AdditionalFieldsjson.RawMessageNew TOld T}
typeBackgroundSubsystem¶added inv2.17.0
type BackgroundSubsystemstring
const (BackgroundSubsystemDormancyBackgroundSubsystem = "dormancy")
typeDiffer¶
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¶
type MockAuditor struct {// contains filtered or unexported fields}
funcNewMock¶
func NewMock() *MockAuditor
func (*MockAuditor)AuditLogs¶
func (a *MockAuditor) AuditLogs() []database.AuditLog
func (*MockAuditor)Contains¶added inv2.4.0
Contains returns true if, for each non-zero-valued field in expected,there exists a corresponding audit log in the mock auditor that matchesthe expected values. Returns false otherwise.
func (*MockAuditor)ResetLogs¶
func (a *MockAuditor) ResetLogs()
ResetLogs removes all audit logs from the mock auditor.This is helpful for testing to get a clean slate.
typeRequest¶
type Request[TAuditable] struct {Old TNew T// UserID is an 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// Action is an 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¶
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.
funcInitRequestWithCancel¶added inv2.12.5
func InitRequestWithCancel[TAuditable](whttp.ResponseWriter, p *RequestParams) (*Request[T], func(commitbool))
InitRequestWithCancel returns a commit function with a boolean arg.If the arg is false, future calls to commit() will not create an audit logentry.
func (*Request[T])UpdateOrganizationID¶added inv2.14.0
UpdateOrganizationID can be used if the organization ID is not knownat the initiation of an audit log request.
typeRequestParams¶
typeWorkspaceBuildBaggage¶added inv2.3.2
type WorkspaceBuildBaggage struct {IPstring}
funcBaggageFromContext¶added inv2.3.2
func BaggageFromContext(ctxcontext.Context)WorkspaceBuildBaggage
funcWorkspaceBuildBaggageFromRequest¶added inv2.3.2
func WorkspaceBuildBaggageFromRequest(r *http.Request)WorkspaceBuildBaggage