Documentation
¶
Overview ¶
Package gcpaudit lets GCP emulators record Cloud Audit Logs entries (protoPayload AuditLog) in the Logging emulator, which Eventarc triggers on google.cloud.audit.log.v1.written then match.
Index ¶
Constants ¶
const DefaultPrincipal = "emulator@gopherstack.iam.gserviceaccount.com"
DefaultPrincipal is the caller recorded when no identity is known: emulator requests are unauthenticated.
Variables ¶
This section is empty.
Functions ¶
func MethodName ¶
MethodName turns a gRPC full method (/pkg.Service/Method) into the audit methodName (pkg.Service.Method).
func ResourceName ¶
ResourceName picks the audited resource: the response's name, else the request's name, database or parent.
Types ¶
type Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
Emitter writes Records to a Sink. The zero value is ready to use and drops records until a sink is set.
func (*Emitter) Emit ¶
Emit records r; it is a no-op without a sink or a project. Call it outside backend locks.
func (*Emitter) UnaryInterceptor ¶
UnaryInterceptor records the RPCs selected by p after they run, with their status. Bodies are left out so that secret payloads never reach the log.
type Policy ¶
type Policy struct {
// NameFunc overrides ResourceName for methods whose resource is not in a top-level name field.
NameFunc func(req, resp proto.Message) string
// Data names methods (short, e.g. "Commit") that are Data Access records.
Data map[string]Kind
// ResourceType is the monitored resource type recorded; empty uses audited_resource.
ResourceType string
// ServiceName is the audit serviceName, e.g. secretmanager.googleapis.com.
ServiceName string
// AdminPrefixes are method-name prefixes (Create, Delete, ...) of mutating RPCs.
AdminPrefixes []string
}
Policy says which RPCs of one gRPC API are audited.
type Record ¶
type Record struct {
Time time.Time
Resource *monitoredres.MonitoredResource
Request *structpb.Struct
Response *structpb.Struct
Failure *status.Status
Project string
ServiceName string
MethodName string
ResourceName string
Principal string
Permission string
Kind Kind
}
Record is one audited API call.