Movatterモバイル変換


[0]ホーム

URL:


audit

package
v2.23.0Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2025 License:AGPL-3.0Imports:22Imported by:0

Details

Repository

github.com/coder/coder

Links

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcBackgroundAuditadded 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.

funcBackgroundTaskFieldsadded inv2.17.0

func BackgroundTaskFields(subsystemBackgroundSubsystem) map[string]string

funcBackgroundTaskFieldsBytesadded inv2.17.0

func BackgroundTaskFieldsBytes(ctxcontext.Context, loggerslog.Logger, subsystemBackgroundSubsystem) []byte

funcBaggageToContextadded inv2.3.2

func BaggageToContext(ctxcontext.Context, dBaggage) (context.Context,error)

funcEmpty

func Empty[TAuditable]() T

Empty returns a default value of type T.

funcParseIPadded inv2.21.0

func ParseIP(ipStrstring)pqtype.Inet

funcResourceID

func ResourceID[TAuditable](tgt T)uuid.UUID

funcResourceRequiresOrgIDadded inv2.9.0

func ResourceRequiresOrgID[TAuditable]()bool

ResourceRequiresOrgID will ensure given resources are always audited with anorganization ID.

funcResourceTarget

func ResourceTarget[TAuditable](tgt T)string

funcResourceType

func ResourceType[TAuditable](tgt T)database.ResourceType

Types

typeAdditionalFields

type AdditionalFields struct {WorkspaceNamestring               `json:"workspace_name"`BuildNumberstring               `json:"build_number"`BuildReasondatabase.BuildReason `json:"build_reason"`WorkspaceOwnerstring               `json:"workspace_owner"`WorkspaceIDuuid.UUID            `json:"workspace_id"`}

typeAuditable

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

type Auditor interface {Export(ctxcontext.Context, alogdatabase.AuditLog)error// contains filtered or unexported methods}

funcNewNop

func NewNop()Auditor

typeBackgroundAuditParamsadded 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}

typeBackgroundSubsystemadded inv2.17.0

type BackgroundSubsystemstring
const (BackgroundSubsystemDormancyBackgroundSubsystem = "dormancy")

typeBaggageadded inv2.3.2

type Baggage interface {Props() ([]baggage.Property,error)}

typeDiffer

type Differ struct {DiffFn func(old, newValany)Map}

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

type Map map[string]OldNew

Map is a map of changed fields in an audited resource. It maps field names tothe old and new value for that field.

funcDiff

func Diff[TAuditable](aAuditor, left, right T)Map

Diff compares two auditable resources and produces a Map of the changedvalues.

typeMockAuditor

type MockAuditor struct {// contains filtered or unexported fields}

funcNewMock

func NewMock() *MockAuditor

func (*MockAuditor)AuditLogs

func (a *MockAuditor) AuditLogs() []database.AuditLog

func (*MockAuditor)Containsadded inv2.4.0

func (a *MockAuditor) Contains(ttesting.TB, expecteddatabase.AuditLog)bool

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)Export

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.

typeOldNew

type OldNew struct {OldanyNewanySecretbool}

OldNew is a pair of values representing the old value and the new value.

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.

funcInitRequestWithCanceladded 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])UpdateOrganizationIDadded inv2.14.0

func (r *Request[T]) UpdateOrganizationID(iduuid.UUID)

UpdateOrganizationID can be used if the organization ID is not knownat the initiation of an audit log request.

typeRequestParams

type RequestParams struct {AuditAuditorLogslog.Logger// OrganizationID is only provided when possible. If an audit resource extends// beyond the org scope, leave this as the nil uuid.OrganizationIDuuid.UUIDRequest          *http.RequestActiondatabase.AuditActionAdditionalFields interface{}}

typeWorkspaceBuildBaggageadded inv2.3.2

type WorkspaceBuildBaggage struct {IPstring}

funcBaggageFromContextadded inv2.3.2

func BaggageFromContext(ctxcontext.Context)WorkspaceBuildBaggage

funcWorkspaceBuildBaggageFromRequestadded inv2.3.2

func WorkspaceBuildBaggageFromRequest(r *http.Request)WorkspaceBuildBaggage

func (WorkspaceBuildBaggage)Propsadded inv2.3.2

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp