Skip to content

Conversation

@danilrwx
Copy link
Contributor

@danilrwx danilrwx commented Oct 22, 2025

Description

Improving audit events names. Also add ignoring system service acconts.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: module
type: fix
summary: Improving audit events names. Also add ignoring system service acconts.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Oct 22, 2025

Reviewer's Guide

This PR refactors audit event generation by renaming events to descriptive messages that include resource names and initiating users, adds filters to ignore internal system service accounts, refines conditions under which events are logged, and adjusts server logging levels.

Class diagram for updated audit event classes

classDiagram
    class VMAccess {
        +IsMatched() bool
        +Fill() error
        eventLog: VMEventLog
        event: AuditEvent
        -- Updated Fill():
        -- eventLog.Name now includes VM name, connection stage, subresource, and user
        -- IsMatched() now ignores most system service accounts
    }
    class IntegrityCheckVM {
        +IsMatched() bool
        +Fill() error
        eventLog: IntegrityCheckEventLog
        event: AuditEvent
        -- Updated Fill():
        -- eventLog.Name now includes VM name
        -- IsMatched() now ignores most system service accounts
    }
    class VMOPControl {
        +IsMatched() bool
        +Fill() error
        eventLog: VMEventLog
        event: AuditEvent
        -- Updated Fill():
        -- eventLog.Name now includes VM name and user for each operation
        -- IsMatched() now ignores most system service accounts
    }
    class VMControl {
        +Fill() error
        eventLog: VMEventLog
        event: AuditEvent
        -- Updated Fill():
        -- eventLog.Name now includes VM name for OS stop/restart, and abnormal kill includes user
        -- Some system actions are now ignored
    }
    class VMManage {
        +IsMatched() bool
        +Fill() error
        eventLog: VMEventLog
        event: AuditEvent
        -- Updated Fill():
        -- eventLog.Name now includes VM name and user for create/update/delete
        -- IsMatched() now ignores most system service accounts
    }
    class ModuleComponentControl {
        +IsMatched() bool
        +Fill() error
        eventLog: EventLog
        event: AuditEvent
        -- Updated Fill():
        -- eventLog.Name now includes component name and user for create/delete
        -- IsMatched() now ignores most system service accounts
    }
    class Forbid {
        +IsMatched() bool
        +Fill() error
        eventLog: EventLog
        event: AuditEvent
        -- Updated Fill():
        -- eventLog.Name now includes user, verb, and resource in forbidden operation
        -- IsMatched() now ignores most system service accounts
    }
    class ModuleControl {
        +IsMatched() bool
        eventLog: EventLog
        event: AuditEvent
        -- IsMatched() now ignores most system service accounts
    }
Loading

File-Level Changes

Change Details Files
Descriptive audit event names
  • Replaced generic event log Name assignments with fmt.Sprintf including resource name and user
  • Updated unit tests to assert the new descriptive message formats
pkg/audit/events/vm/vmop_control.go
pkg/audit/events/vm/vm_control.go
pkg/audit/events/vm/vm_access.go
pkg/audit/events/vm/vm_manage.go
pkg/audit/events/integrity/integrity_check_vm.go
pkg/audit/events/module/module_component_control.go
pkg/audit/events/module/module_control.go
pkg/audit/events/forbid/forbid.go
pkg/audit/events/vm/vmop_control_test.go
pkg/audit/events/vm/vm_control_test.go
pkg/audit/events/vm/vm_access_test.go
pkg/audit/events/vm/vm_manage_test.go
pkg/audit/events/integrity/integrity_check_vm_test.go
pkg/audit/events/module/module_component_control_test.go
pkg/audit/events/forbid/forbid_test.go
Exclude internal system accounts from audits
  • Added username prefix checks in IsMatched methods to skip events from system: users except specific serviceaccounts
  • Unified filtering logic across multiple event matchers
pkg/audit/events/vm/vmop_control.go
pkg/audit/events/vm/vm_control.go
pkg/audit/events/vm/vm_access.go
pkg/audit/events/vm/vm_manage.go
pkg/audit/events/integrity/integrity_check_vm.go
pkg/audit/events/module/module_component_control.go
pkg/audit/events/module/module_control.go
pkg/audit/events/forbid/forbid.go
Refine event logging conditions
  • In VMAccess, skip events at StageResponseStarted
  • Introduced shoulntLog handling in VMControl and corresponding tests to suppress undesired logs
  • Suppressed IntegrityCheck logs when checksums match
pkg/audit/events/vm/vm_access.go
pkg/audit/events/vm/vm_control_test.go
pkg/audit/events/integrity/integrity_check_vm.go
Adjust server logging level
  • Changed audit TCP server log calls from Info to Debug for startup and new connections
pkg/audit/server/server.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@danilrwx danilrwx requested a review from diafour October 22, 2025 12:16
@danilrwx danilrwx marked this pull request as ready for review October 22, 2025 12:17
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Description
Improving audit events names. Also add ignoring system service acconts.

Signed-off-by: Daniil Antoshin <[email protected]>
@danilrwx danilrwx force-pushed the fix/audit/cse-rename-audit-events branch from d90ee3b to f9d1365 Compare October 22, 2025 12:43
@diafour diafour merged commit 4234377 into release-1.0-cse Oct 22, 2025
26 of 28 checks passed
@diafour diafour deleted the fix/audit/cse-rename-audit-events branch October 22, 2025 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants