Skip to content

chore: rearrange audit logging code into enterprise folder #3741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 31, 2022
Prev Previous commit
Next Next commit
spike comments
  • Loading branch information
coadler committed Aug 31, 2022
commit 10a0d3b1d892d69e25643eb02cb89a75abb441a0
1 change: 0 additions & 1 deletion coderd/audit.go

This file was deleted.

24 changes: 14 additions & 10 deletions codersdk/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,32 @@ const (
AuditActionDelete AuditAction = "delete"
)

type AuditDiff map[string]struct {
type AuditDiff map[string]AuditDiffField

type AuditDiffField struct {
Old any
New any
Secret bool
}

type AuditLog struct {
ID uuid.UUID `json:"id"`
RequestID uuid.UUID `json:"request_id"`
Time time.Time `json:"time"`
OrganizationID uuid.UUID `json:"organization_id"`
IP netip.Addr `json:"ip"`
UserAgent string `json:"user_agent"`
ResourceType ResourceType `json:"resource_type"`
ResourceID uuid.UUID `json:"resource_id"`
ID uuid.UUID `json:"id"`
RequestID uuid.UUID `json:"request_id"`
Time time.Time `json:"time"`
OrganizationID uuid.UUID `json:"organization_id"`
IP netip.Addr `json:"ip"`
UserAgent string `json:"user_agent"`
ResourceType ResourceType `json:"resource_type"`
ResourceID uuid.UUID `json:"resource_id"`
// ResourceTarget is the name of the resource.
ResourceTarget string `json:"resource_target"`
Action AuditAction `json:"action"`
Diff AuditDiff `json:"diff"`
StatusCode int32 `json:"status_code"`
AdditionalFields json.RawMessage `json:"additional_fields"`
Description string `json:"description"`

User *User `json:"user"`
User *User `json:"user"`
// Resource is the full object of the resource the audit log is for.
Resource json.RawMessage `json:"resource"`
}
13 changes: 10 additions & 3 deletions site/src/api/typesGenerated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,16 @@ export interface AssignableRoles extends Role {
}

// From codersdk/audit.go
// Embedded anonymous struct, please fix by naming it
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AuditDiff = Record<string, any>
export type AuditDiff = Record<string, AuditDiffField>

// From codersdk/audit.go
export interface AuditDiffField {
// eslint-disable-next-line
readonly Old: any
// eslint-disable-next-line
readonly New: any
readonly Secret: boolean
}

// From codersdk/audit.go
export interface AuditLog {
Expand Down