UCloud logo UCloud logo UCloud
v2025.1.0
  1. UCloud/Core
  2. 1. Introduction
  3. 2. Projects
  4. 3. Accounting
  5. 4. Orchestration
  6. UCloud/IM for Slurm-based HPC
  7. 5. Installation
  8. 6. Architecture and Networking
  9. 7. User and Project Management
  10. 8. Filesystem Integration
    1. 8.1. Inter-provider file transfers
  11. 9. Slurm Integration
    1. 9.1. Application Management
    2. 9.2. Built-in Applications
  12. 10. Reference
    1. 10.1. Configuration
    2. 10.2. CLI
  13. 11. Appendix
    1. 11.1. Built-in Application Index
  14. UCloud/IM for Kubernetes
  15. 12. Installation
  16. 13. Architecture and Networking
  17. 14. Filesystem Integration
  18. 15. Compute Jobs
    1. 15.1. Public Links
    2. 15.2. Public IPs
    3. 15.3. License Servers
    4. 15.4. SSH Servers
  19. 16. Integrated applications
    1. 16.1. Syncthing
    2. 16.2. Integrated terminal
  20. 17. Reference
    1. 17.1. Configuration
  21. H: Procedures
  22. 18. H: Procedures
  23. 19. H: Introduction
  24. 20. H: Auditing
  25. 21. H: Auditing scenario
  26. 22. H: GitHub actions
  27. 23. H: Deployment
  28. 24. H: 3rd party dependencies (risk assesment)
  1. Links
  2. Source Code
  3. Releases

Auditing

Auditing is automatically performed for all RPC calls implemented. If you have written any rpc.Call then auditing is entirely automatic. There are, however, a few cases you need to be aware of. We outline the most important things in this document.

How Does It Work?

The auditing feature is written as a piece of middleware. It logs all calls made to the backend. It is further enriched by metadata provided by the rpc.Call. The resulting audit log is dispatched to the postgres database and stored in audit_logs.logs.

The following information audited for each request (See the source code in shared for the most up-to-date version):

type HttpCallLogEntry struct {
	JobId             string                              `json:"jobId"`
	RequestName       string                              `json:"requestName"`
	UserAgent         util.Option[string]                 `json:"userAgent"`
	RemoteOrigin      string                              `json:"remoteOrigin"`
	Token             util.Option[SecurityPrincipalToken] `json:"token"`
	RequestSize       uint64                              `json:"requestSize"`
	RequestJson       util.Option[json.RawMessage]        `json:"requestJson"`
	ResponseCode      int                                 `json:"responseCode"`
	ResponseTime      uint64                              `json:"responseTime"`
	ResponseTimeNanos uint64                              `json:"responseTimeNanos"`
	Expiry            uint64                              `json:"expiry"`
	Project           util.Option[string]                 `json:"project"`
	ReceivedAt        time.Time                           `json:"receivedAt"`
}

type SecurityPrincipalToken struct {
	Principal              SecurityPrincipal   `json:"principal"`
	IssuedAt               uint64              `json:"issuedAt"`
	ExpiresAt              uint64              `json:"expiresAt"`
	PublicSessionReference util.Option[string] `json:"publicSessionReference"`
}

type SecurityPrincipal struct {
	Username                 string              `json:"username"`
	Role                     string              `json:"role"`
}

Dealing With Sensitive Request Data

In this section, “sensitive data” is any kind of data which shouldn’t be accessible through the audit logs. It may include any kind of data that would by law be classified as sensitive, but it may also contain other types of data.

We don’t want sensitive data in our logs. The audit log should allow us to clearly audit the actions of a user, but it should not contain sensitive data, such as passwords. If you are writing a call which will need to accept sensitive data you need to declare an alternative request type which has this sensitive data redacted.

In the call description you should add the following to the RPC:

Audit: rpc.AuditRules{
    Transformer: func(request any) json.RawMessage {
        return json.RawMessage("{}")
    },
},

Verification Procedure

The following document describes how to verify that auditing works as intended: Auditing Scenario.

Previous H: Introduction
Next H: Auditing scenario