Merge pull request #52981 from CaoShuFeng/audit_v1beta2

Automatic merge from submit-queue (batch tested with PRs 53119, 53753, 53795, 52981). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

add RequestReceivedTimestamp and StageTimestamp to audit event

fixes https://github.com/kubernetes/kubernetes/issues/52160

**Release note**:
```
Add RequestReceivedTimestamp and StageTimestamp with micro seconds to audit events.
```
pull/6/head
Kubernetes Submit Queue 2017-10-12 08:28:44 -07:00 committed by GitHub
commit 6901fc37d1
22 changed files with 778 additions and 211 deletions

View File

@ -77,15 +77,10 @@ const (
// Event captures all the information that can be included in an API audit log.
type Event struct {
metav1.TypeMeta
// ObjectMeta is included for interoperability with API infrastructure.
// +optional
metav1.ObjectMeta
// AuditLevel at which event was generated
Level Level
// Time the request reached the apiserver.
Timestamp metav1.Time
// Unique audit ID, generated for each request.
AuditID types.UID
// Stage of the request handling when this event instance was generated.
@ -121,10 +116,15 @@ type Event struct {
// +optional
RequestObject *runtime.Unknown
// API object returned in the response, in JSON. The ResponseObject is recorded after conversion
// to the external type, and serialized as JSON. Omitted for non-resource requests. Only logged
// to the external type, and serialized as JSON. Omitted for non-resource requests. Only logged
// at Response Level.
// +optional
ResponseObject *runtime.Unknown
// Time the request reached the apiserver.
RequestReceivedTimestamp metav1.MicroTime
// Time the request reached current audit stage.
StageTimestamp metav1.MicroTime
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

View File

@ -54,6 +54,7 @@ go_test(
srcs = ["conversion_test.go"],
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apiserver/pkg/apis/audit:go_default_library",

View File

@ -19,6 +19,7 @@ package v1alpha1
import (
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apiserver/pkg/apis/audit"
)
@ -52,3 +53,26 @@ func Convert_v1alpha1_ObjectReference_To_audit_ObjectReference(in *ObjectReferen
}
return nil
}
func Convert_v1alpha1_Event_To_audit_Event(in *Event, out *audit.Event, s conversion.Scope) error {
if err := autoConvert_v1alpha1_Event_To_audit_Event(in, out, s); err != nil {
return err
}
if out.StageTimestamp.IsZero() {
out.StageTimestamp = metav1.NewMicroTime(in.CreationTimestamp.Time)
}
if out.RequestReceivedTimestamp.IsZero() {
out.RequestReceivedTimestamp = metav1.NewMicroTime(in.Timestamp.Time)
}
return nil
}
func Convert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s conversion.Scope) error {
if err := autoConvert_audit_Event_To_v1alpha1_Event(in, out, s); err != nil {
return err
}
out.CreationTimestamp = metav1.NewTime(in.StageTimestamp.Time)
out.Timestamp = metav1.NewTime(in.RequestReceivedTimestamp.Time)
return nil
}

View File

@ -19,7 +19,9 @@ package v1alpha1
import (
"reflect"
"testing"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
auditinternal "k8s.io/apiserver/pkg/apis/audit"
@ -36,7 +38,7 @@ func init() {
RegisterConversions(scheme)
}
func TestConversion(t *testing.T) {
func TestConversionObjectReference(t *testing.T) {
scheme.Log(t)
testcases := []struct {
@ -92,3 +94,114 @@ func TestConversion(t *testing.T) {
})
}
}
func TestConversionEventToInternal(t *testing.T) {
scheme.Log(t)
time1 := time.Now()
time2 := time.Now()
testcases := []struct {
desc string
old *Event
expected *auditinternal.Event
}{
{
"StageTimestamp is empty",
&Event{
ObjectMeta: metav1.ObjectMeta{
CreationTimestamp: metav1.NewTime(time1),
},
},
&auditinternal.Event{
StageTimestamp: metav1.NewMicroTime(time1),
},
},
{
"StageTimestamp is not empty",
&Event{
ObjectMeta: metav1.ObjectMeta{
CreationTimestamp: metav1.NewTime(time1),
},
StageTimestamp: metav1.NewMicroTime(time2),
},
&auditinternal.Event{
StageTimestamp: metav1.NewMicroTime(time2),
},
},
{
"RequestReceivedTimestamp is empty",
&Event{
Timestamp: metav1.NewTime(time1),
},
&auditinternal.Event{
RequestReceivedTimestamp: metav1.NewMicroTime(time1),
},
},
{
"RequestReceivedTimestamp is not empty",
&Event{
Timestamp: metav1.NewTime(time1),
RequestReceivedTimestamp: metav1.NewMicroTime(time2),
},
&auditinternal.Event{
RequestReceivedTimestamp: metav1.NewMicroTime(time2),
},
},
}
for _, tc := range testcases {
t.Run(tc.desc, func(t *testing.T) {
internal := &auditinternal.Event{}
if err := scheme.Convert(tc.old, internal, nil); err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(internal, tc.expected) {
t.Errorf("expected\n\t%#v, got \n\t%#v", tc.expected, internal)
}
})
}
}
func TestConversionInternalToEvent(t *testing.T) {
scheme.Log(t)
now := time.Now()
testcases := []struct {
desc string
old *auditinternal.Event
expected *Event
}{
{
"convert stageTimestamp",
&auditinternal.Event{
StageTimestamp: metav1.NewMicroTime(now),
},
&Event{
ObjectMeta: metav1.ObjectMeta{
CreationTimestamp: metav1.NewTime(now),
},
StageTimestamp: metav1.NewMicroTime(now),
},
},
{
"convert RequestReceivedTimestamp",
&auditinternal.Event{
RequestReceivedTimestamp: metav1.NewMicroTime(now),
},
&Event{
Timestamp: metav1.NewTime(now),
RequestReceivedTimestamp: metav1.NewMicroTime(now),
},
},
}
for _, tc := range testcases {
t.Run(tc.desc, func(t *testing.T) {
event := &Event{}
if err := scheme.Convert(tc.old, event, nil); err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(event, tc.expected) {
t.Errorf("expected\n\t%#v, got \n\t%#v", tc.expected, event)
}
})
}
}

View File

@ -222,6 +222,24 @@ func (m *Event) MarshalTo(dAtA []byte) (int, error) {
}
i += n8
}
dAtA[i] = 0x7a
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.RequestReceivedTimestamp.Size()))
n9, err := m.RequestReceivedTimestamp.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n9
dAtA[i] = 0x82
i++
dAtA[i] = 0x1
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.StageTimestamp.Size()))
n10, err := m.StageTimestamp.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n10
return i, nil
}
@ -243,11 +261,11 @@ func (m *EventList) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0xa
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size()))
n9, err := m.ListMeta.MarshalTo(dAtA[i:])
n11, err := m.ListMeta.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n9
i += n11
if len(m.Items) > 0 {
for _, msg := range m.Items {
dAtA[i] = 0x12
@ -379,11 +397,11 @@ func (m *Policy) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0xa
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.ObjectMeta.Size()))
n10, err := m.ObjectMeta.MarshalTo(dAtA[i:])
n12, err := m.ObjectMeta.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n10
i += n12
if len(m.Rules) > 0 {
for _, msg := range m.Rules {
dAtA[i] = 0x12
@ -417,11 +435,11 @@ func (m *PolicyList) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0xa
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size()))
n11, err := m.ListMeta.MarshalTo(dAtA[i:])
n13, err := m.ListMeta.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n11
i += n13
if len(m.Items) > 0 {
for _, msg := range m.Items {
dAtA[i] = 0x12
@ -633,6 +651,10 @@ func (m *Event) Size() (n int) {
l = m.ResponseObject.Size()
n += 1 + l + sovGenerated(uint64(l))
}
l = m.RequestReceivedTimestamp.Size()
n += 1 + l + sovGenerated(uint64(l))
l = m.StageTimestamp.Size()
n += 2 + l + sovGenerated(uint64(l))
return n
}
@ -800,6 +822,8 @@ func (this *Event) String() string {
`ResponseStatus:` + strings.Replace(fmt.Sprintf("%v", this.ResponseStatus), "Status", "k8s_io_apimachinery_pkg_apis_meta_v1.Status", 1) + `,`,
`RequestObject:` + strings.Replace(fmt.Sprintf("%v", this.RequestObject), "Unknown", "k8s_io_apimachinery_pkg_runtime.Unknown", 1) + `,`,
`ResponseObject:` + strings.Replace(fmt.Sprintf("%v", this.ResponseObject), "Unknown", "k8s_io_apimachinery_pkg_runtime.Unknown", 1) + `,`,
`RequestReceivedTimestamp:` + strings.Replace(strings.Replace(this.RequestReceivedTimestamp.String(), "MicroTime", "k8s_io_apimachinery_pkg_apis_meta_v1.MicroTime", 1), `&`, ``, 1) + `,`,
`StageTimestamp:` + strings.Replace(strings.Replace(this.StageTimestamp.String(), "MicroTime", "k8s_io_apimachinery_pkg_apis_meta_v1.MicroTime", 1), `&`, ``, 1) + `,`,
`}`,
}, "")
return s
@ -1348,6 +1372,66 @@ func (m *Event) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 15:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field RequestReceivedTimestamp", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenerated
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenerated
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.RequestReceivedTimestamp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 16:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field StageTimestamp", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenerated
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenerated
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.StageTimestamp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenerated(dAtA[iNdEx:])
@ -2486,76 +2570,80 @@ func init() {
}
var fileDescriptorGenerated = []byte{
// 1129 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xcd, 0x6e, 0x23, 0x45,
0x10, 0xce, 0xac, 0xe3, 0x8d, 0xa7, 0xb3, 0xf9, 0xd9, 0x5e, 0xc4, 0x8e, 0x72, 0xb0, 0x83, 0x91,
0x90, 0x05, 0x61, 0x26, 0x09, 0x81, 0x5d, 0x0e, 0x1c, 0x62, 0x2d, 0x02, 0x4b, 0x21, 0x84, 0x4e,
0xbc, 0x12, 0x3f, 0x07, 0xc6, 0x76, 0xc5, 0x1e, 0xe2, 0xf9, 0xa1, 0xbb, 0xc7, 0x28, 0x37, 0x0e,
0x3c, 0x00, 0x77, 0x1e, 0x66, 0x85, 0x04, 0x52, 0x8e, 0x7b, 0xdc, 0x93, 0x45, 0xcc, 0x5b, 0xe4,
0x84, 0xba, 0xa7, 0x7b, 0x7a, 0xec, 0xac, 0x85, 0x73, 0xd9, 0xdb, 0x74, 0xd5, 0xf7, 0x7d, 0x5d,
0x55, 0x53, 0x55, 0x33, 0xe8, 0x9b, 0x8b, 0xa7, 0xcc, 0x0d, 0x62, 0xef, 0x22, 0xed, 0x00, 0x8d,
0x80, 0x03, 0xf3, 0x46, 0x10, 0xf5, 0x62, 0xea, 0x29, 0x87, 0x9f, 0x04, 0x0c, 0xe8, 0x08, 0xa8,
0x97, 0x5c, 0xf4, 0xe5, 0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, 0x7e, 0xa8, 0x56, 0x4f, 0xda, 0xb4, 0x22, 0x7f, 0x55, 0x3b, 0x95, 0x92,
0x0c, 0x42, 0x12, 0xca, 0x57, 0x08, 0xb7, 0x97, 0x0d, 0xa1, 0x7c, 0x9c, 0x70, 0x12, 0xcb, 0x31,
0xcd, 0xce, 0x89, 0xa2, 0xca, 0xc4, 0xe3, 0xc5, 0x33, 0x91, 0x9f, 0x4c, 0xa6, 0x73, 0x5f, 0x3b,
0x65, 0x1c, 0x84, 0xd2, 0x36, 0xe6, 0xf6, 0x8a, 0xf1, 0x3d, 0xed, 0x73, 0x4e, 0x32, 0x08, 0xfc,
0x05, 0xda, 0xf0, 0x03, 0x3f, 0xa1, 0x6a, 0x93, 0x43, 0x6e, 0xaf, 0x2a, 0xa3, 0xfb, 0xb2, 0x97,
0x8e, 0xf2, 0x2a, 0x32, 0x8b, 0xc5, 0x8f, 0x10, 0x0a, 0x46, 0x54, 0xa8, 0x0d, 0xc1, 0xed, 0x92,
0xb2, 0x7c, 0xa0, 0xaa, 0x3a, 0x95, 0x9a, 0x27, 0x60, 0x06, 0xda, 0x74, 0x2e, 0xaf, 0xaa, 0x4b,
0x2f, 0xaf, 0xaa, 0x4b, 0xaf, 0xae, 0xaa, 0x4b, 0xbf, 0x4d, 0xab, 0xd6, 0xe5, 0xb4, 0x6a, 0xbd,
0x9c, 0x56, 0xad, 0x57, 0xd3, 0xaa, 0xf5, 0xcf, 0xb4, 0x6a, 0xfd, 0xf9, 0x6f, 0x75, 0xe9, 0xfb,
0x52, 0x92, 0x84, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x9e, 0x6c, 0xe1, 0x29, 0x5b, 0x0d, 0x00,
0x00,
}

View File

@ -89,6 +89,14 @@ message Event {
// at Response Level.
// +optional
optional k8s.io.apimachinery.pkg.runtime.Unknown responseObject = 14;
// Time the request reached the apiserver.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.MicroTime requestReceivedTimestamp = 15;
// Time the request reached current audit stage.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.MicroTime stageTimestamp = 16;
}
// EventList is a list of audit Events.

View File

@ -126,6 +126,12 @@ type Event struct {
// at Response Level.
// +optional
ResponseObject *runtime.Unknown `json:"responseObject,omitempty" protobuf:"bytes,14,opt,name=responseObject"`
// Time the request reached the apiserver.
// +optional
RequestReceivedTimestamp metav1.MicroTime `json:"requestReceivedTimestamp" protobuf:"bytes,15,opt,name=requestReceivedTimestamp"`
// Time the request reached current audit stage.
// +optional
StageTimestamp metav1.MicroTime `json:"stageTimestamp" protobuf:"bytes,16,opt,name=stageTimestamp"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

View File

@ -56,9 +56,9 @@ func RegisterConversions(scheme *runtime.Scheme) error {
}
func autoConvert_v1alpha1_Event_To_audit_Event(in *Event, out *audit.Event, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
// WARNING: in.ObjectMeta requires manual conversion: does not exist in peer-type
out.Level = audit.Level(in.Level)
out.Timestamp = in.Timestamp
// WARNING: in.Timestamp requires manual conversion: does not exist in peer-type
out.AuditID = types.UID(in.AuditID)
out.Stage = audit.Stage(in.Stage)
out.RequestURI = in.RequestURI
@ -81,18 +81,13 @@ func autoConvert_v1alpha1_Event_To_audit_Event(in *Event, out *audit.Event, s co
out.ResponseStatus = (*v1.Status)(unsafe.Pointer(in.ResponseStatus))
out.RequestObject = (*runtime.Unknown)(unsafe.Pointer(in.RequestObject))
out.ResponseObject = (*runtime.Unknown)(unsafe.Pointer(in.ResponseObject))
out.RequestReceivedTimestamp = in.RequestReceivedTimestamp
out.StageTimestamp = in.StageTimestamp
return nil
}
// Convert_v1alpha1_Event_To_audit_Event is an autogenerated conversion function.
func Convert_v1alpha1_Event_To_audit_Event(in *Event, out *audit.Event, s conversion.Scope) error {
return autoConvert_v1alpha1_Event_To_audit_Event(in, out, s)
}
func autoConvert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.Level = Level(in.Level)
out.Timestamp = in.Timestamp
out.AuditID = types.UID(in.AuditID)
out.Stage = Stage(in.Stage)
out.RequestURI = in.RequestURI
@ -115,14 +110,11 @@ func autoConvert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s co
out.ResponseStatus = (*v1.Status)(unsafe.Pointer(in.ResponseStatus))
out.RequestObject = (*runtime.Unknown)(unsafe.Pointer(in.RequestObject))
out.ResponseObject = (*runtime.Unknown)(unsafe.Pointer(in.ResponseObject))
out.RequestReceivedTimestamp = in.RequestReceivedTimestamp
out.StageTimestamp = in.StageTimestamp
return nil
}
// Convert_audit_Event_To_v1alpha1_Event is an autogenerated conversion function.
func Convert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s conversion.Scope) error {
return autoConvert_audit_Event_To_v1alpha1_Event(in, out, s)
}
func autoConvert_v1alpha1_EventList_To_audit_EventList(in *EventList, out *audit.EventList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
if in.Items != nil {

View File

@ -126,6 +126,8 @@ func (in *Event) DeepCopyInto(out *Event) {
(*in).DeepCopyInto(*out)
}
}
in.RequestReceivedTimestamp.DeepCopyInto(&out.RequestReceivedTimestamp)
in.StageTimestamp.DeepCopyInto(&out.StageTimestamp)
return
}

View File

@ -3,11 +3,13 @@ package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = [
"conversion.go",
"doc.go",
"generated.pb.go",
"register.go",
@ -47,3 +49,15 @@ filegroup(
srcs = ["generated.proto"],
visibility = ["//visibility:public"],
)
go_test(
name = "go_default_test",
srcs = ["conversion_test.go"],
library = ":go_default_library",
deps = [
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apiserver/pkg/apis/audit:go_default_library",
],
)

View File

@ -0,0 +1,45 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apiserver/pkg/apis/audit"
)
func Convert_v1beta1_Event_To_audit_Event(in *Event, out *audit.Event, s conversion.Scope) error {
if err := autoConvert_v1beta1_Event_To_audit_Event(in, out, s); err != nil {
return err
}
if out.StageTimestamp.IsZero() {
out.StageTimestamp = metav1.NewMicroTime(in.CreationTimestamp.Time)
}
if out.RequestReceivedTimestamp.IsZero() {
out.RequestReceivedTimestamp = metav1.NewMicroTime(in.Timestamp.Time)
}
return nil
}
func Convert_audit_Event_To_v1beta1_Event(in *audit.Event, out *Event, s conversion.Scope) error {
if err := autoConvert_audit_Event_To_v1beta1_Event(in, out, s); err != nil {
return err
}
out.CreationTimestamp = metav1.NewTime(in.StageTimestamp.Time)
out.Timestamp = metav1.NewTime(in.RequestReceivedTimestamp.Time)
return nil
}

View File

@ -0,0 +1,150 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
"reflect"
"testing"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
auditinternal "k8s.io/apiserver/pkg/apis/audit"
)
var scheme = runtime.NewScheme()
func init() {
addKnownTypes(scheme)
internalGV := schema.GroupVersion{Group: auditinternal.GroupName, Version: runtime.APIVersionInternal}
scheme.AddKnownTypes(internalGV,
&auditinternal.Event{},
)
RegisterConversions(scheme)
}
func TestConversionEventToInternal(t *testing.T) {
scheme.Log(t)
time1 := time.Now()
time2 := time.Now()
testcases := []struct {
desc string
old *Event
expected *auditinternal.Event
}{
{
"StageTimestamp is empty",
&Event{
ObjectMeta: metav1.ObjectMeta{
CreationTimestamp: metav1.NewTime(time1),
},
},
&auditinternal.Event{
StageTimestamp: metav1.NewMicroTime(time1),
},
},
{
"StageTimestamp is not empty",
&Event{
ObjectMeta: metav1.ObjectMeta{
CreationTimestamp: metav1.NewTime(time1),
},
StageTimestamp: metav1.NewMicroTime(time2),
},
&auditinternal.Event{
StageTimestamp: metav1.NewMicroTime(time2),
},
},
{
"RequestReceivedTimestamp is empty",
&Event{
Timestamp: metav1.NewTime(time1),
},
&auditinternal.Event{
RequestReceivedTimestamp: metav1.NewMicroTime(time1),
},
},
{
"RequestReceivedTimestamp is not empty",
&Event{
Timestamp: metav1.NewTime(time1),
RequestReceivedTimestamp: metav1.NewMicroTime(time2),
},
&auditinternal.Event{
RequestReceivedTimestamp: metav1.NewMicroTime(time2),
},
},
}
for _, tc := range testcases {
t.Run(tc.desc, func(t *testing.T) {
internal := &auditinternal.Event{}
if err := scheme.Convert(tc.old, internal, nil); err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(internal, tc.expected) {
t.Errorf("expected\n\t%#v, got \n\t%#v", tc.expected, internal)
}
})
}
}
func TestConversionInternalToEvent(t *testing.T) {
scheme.Log(t)
now := time.Now()
testcases := []struct {
desc string
old *auditinternal.Event
expected *Event
}{
{
"convert stageTimestamp",
&auditinternal.Event{
StageTimestamp: metav1.NewMicroTime(now),
},
&Event{
ObjectMeta: metav1.ObjectMeta{
CreationTimestamp: metav1.NewTime(now),
},
StageTimestamp: metav1.NewMicroTime(now),
},
},
{
"convert RequestReceivedTimestamp",
&auditinternal.Event{
RequestReceivedTimestamp: metav1.NewMicroTime(now),
},
&Event{
Timestamp: metav1.NewTime(now),
RequestReceivedTimestamp: metav1.NewMicroTime(now),
},
},
}
for _, tc := range testcases {
t.Run(tc.desc, func(t *testing.T) {
event := &Event{}
if err := scheme.Convert(tc.old, event, nil); err != nil {
t.Errorf("unexpected error: %v", err)
}
if !reflect.DeepEqual(event, tc.expected) {
t.Errorf("expected\n\t%#v, got \n\t%#v", tc.expected, event)
}
})
}
}

View File

@ -222,6 +222,24 @@ func (m *Event) MarshalTo(dAtA []byte) (int, error) {
}
i += n8
}
dAtA[i] = 0x7a
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.RequestReceivedTimestamp.Size()))
n9, err := m.RequestReceivedTimestamp.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n9
dAtA[i] = 0x82
i++
dAtA[i] = 0x1
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.StageTimestamp.Size()))
n10, err := m.StageTimestamp.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n10
return i, nil
}
@ -243,11 +261,11 @@ func (m *EventList) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0xa
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size()))
n9, err := m.ListMeta.MarshalTo(dAtA[i:])
n11, err := m.ListMeta.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n9
i += n11
if len(m.Items) > 0 {
for _, msg := range m.Items {
dAtA[i] = 0x12
@ -383,11 +401,11 @@ func (m *Policy) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0xa
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.ObjectMeta.Size()))
n10, err := m.ObjectMeta.MarshalTo(dAtA[i:])
n12, err := m.ObjectMeta.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n10
i += n12
if len(m.Rules) > 0 {
for _, msg := range m.Rules {
dAtA[i] = 0x12
@ -421,11 +439,11 @@ func (m *PolicyList) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0xa
i++
i = encodeVarintGenerated(dAtA, i, uint64(m.ListMeta.Size()))
n11, err := m.ListMeta.MarshalTo(dAtA[i:])
n13, err := m.ListMeta.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n11
i += n13
if len(m.Items) > 0 {
for _, msg := range m.Items {
dAtA[i] = 0x12
@ -637,6 +655,10 @@ func (m *Event) Size() (n int) {
l = m.ResponseObject.Size()
n += 1 + l + sovGenerated(uint64(l))
}
l = m.RequestReceivedTimestamp.Size()
n += 1 + l + sovGenerated(uint64(l))
l = m.StageTimestamp.Size()
n += 2 + l + sovGenerated(uint64(l))
return n
}
@ -806,6 +828,8 @@ func (this *Event) String() string {
`ResponseStatus:` + strings.Replace(fmt.Sprintf("%v", this.ResponseStatus), "Status", "k8s_io_apimachinery_pkg_apis_meta_v1.Status", 1) + `,`,
`RequestObject:` + strings.Replace(fmt.Sprintf("%v", this.RequestObject), "Unknown", "k8s_io_apimachinery_pkg_runtime.Unknown", 1) + `,`,
`ResponseObject:` + strings.Replace(fmt.Sprintf("%v", this.ResponseObject), "Unknown", "k8s_io_apimachinery_pkg_runtime.Unknown", 1) + `,`,
`RequestReceivedTimestamp:` + strings.Replace(strings.Replace(this.RequestReceivedTimestamp.String(), "MicroTime", "k8s_io_apimachinery_pkg_apis_meta_v1.MicroTime", 1), `&`, ``, 1) + `,`,
`StageTimestamp:` + strings.Replace(strings.Replace(this.StageTimestamp.String(), "MicroTime", "k8s_io_apimachinery_pkg_apis_meta_v1.MicroTime", 1), `&`, ``, 1) + `,`,
`}`,
}, "")
return s
@ -1355,6 +1379,66 @@ func (m *Event) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 15:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field RequestReceivedTimestamp", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenerated
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenerated
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.RequestReceivedTimestamp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 16:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field StageTimestamp", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowGenerated
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthGenerated
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.StageTimestamp.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipGenerated(dAtA[iNdEx:])
@ -2522,78 +2606,81 @@ func init() {
}
var fileDescriptorGenerated = []byte{
// 1153 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0x45,
0x14, 0xcf, 0xd6, 0x71, 0xe2, 0x9d, 0x34, 0x7f, 0x3a, 0x45, 0x74, 0x95, 0x83, 0x1d, 0x8c, 0x04,
0x11, 0xa4, 0xbb, 0x4d, 0x5b, 0x48, 0x2e, 0x1c, 0x62, 0x15, 0x81, 0xa5, 0x10, 0xa2, 0x49, 0x5c,
0x21, 0xe0, 0xc0, 0xd8, 0x7e, 0xb1, 0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 0xdf,
0x90, 0x1a, 0x2a, 0xcb, 0x6f, 0x62, 0x36, 0xdd, 0xb6, 0x44, 0xca, 0x4f, 0x17, 0x27, 0xa9, 0x1d,
0xbb, 0x08, 0xc9, 0x07, 0xd5, 0xa2, 0xd9, 0x48, 0xaf, 0xc9, 0x8b, 0x6a, 0xe5, 0x56, 0x52, 0x40,
0x48, 0x41, 0xf9, 0xb9, 0xe6, 0xce, 0xa2, 0x11, 0x94, 0x5f, 0x71, 0x4e, 0x52, 0x3b, 0xee, 0x17,
0x77, 0x4a, 0x59, 0x15, 0x62, 0x6f, 0xee, 0x42, 0x4c, 0x2e, 0x31, 0x33, 0xe4, 0xaf, 0x5d, 0x48,
0x2e, 0x42, 0xf9, 0xc4, 0x73, 0x67, 0xc9, 0x84, 0x9e, 0xaf, 0x04, 0x4e, 0x0a, 0x08, 0xfc, 0x05,
0x5a, 0x0f, 0xa3, 0x30, 0x93, 0x6a, 0x91, 0x43, 0xee, 0x2c, 0x2b, 0xd2, 0x7d, 0x39, 0x48, 0x47,
0x93, 0x2e, 0x32, 0x8d, 0xc5, 0x7b, 0x08, 0x45, 0x81, 0x2f, 0xd4, 0xaf, 0x10, 0x77, 0x2a, 0x8a,
0xf9, 0x40, 0xb5, 0x74, 0x6e, 0x35, 0xbf, 0x4a, 0x05, 0x68, 0xe3, 0xe1, 0xe5, 0x55, 0x75, 0xe1,
0xe5, 0x55, 0x75, 0xe1, 0xd5, 0x55, 0x75, 0xe1, 0xb7, 0x71, 0xd5, 0xba, 0x1c, 0x57, 0xad, 0x97,
0xe3, 0xaa, 0xf5, 0x6a, 0x5c, 0xb5, 0xfe, 0x1d, 0x57, 0xad, 0xdf, 0xff, 0xab, 0x2e, 0x7c, 0xbf,
0xac, 0x6b, 0xf0, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x19, 0x44, 0x81, 0xf3, 0xba, 0x0c, 0x00,
0x00,
// 1211 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08,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x17, 0x68, 0xd3, 0x0f, 0xfc, 0x44, 0xaa,
0x45, 0x8e, 0xb8, 0xbd, 0xa6, 0x48, 0xf7, 0x64, 0x23, 0x1d, 0x4f, 0xbb, 0xc8, 0x2c, 0x16, 0xef,
0x23, 0x14, 0x0c, 0xa9, 0x50, 0x77, 0x09, 0xb7, 0x0b, 0x8a, 0x79, 0x5f, 0x1d, 0xe9, 0xd4, 0x6a,
0xde, 0x8a, 0x19, 0x68, 0xfd, 0xc1, 0xe5, 0x55, 0x79, 0xe5, 0xd5, 0x55, 0x79, 0xe5, 0xf5, 0x55,
0x79, 0xe5, 0xd7, 0x49, 0xd9, 0xba, 0x9c, 0x94, 0xad, 0x57, 0x93, 0xb2, 0xf5, 0x7a, 0x52, 0xb6,
0xfe, 0x9e, 0x94, 0xad, 0xdf, 0xff, 0x29, 0xaf, 0x7c, 0xb7, 0xa6, 0x6b, 0xf0, 0x6f, 0x00, 0x00,
0x00, 0xff, 0xff, 0xfd, 0x2a, 0x16, 0x68, 0xbb, 0x0d, 0x00, 0x00,
}

View File

@ -35,12 +35,15 @@ option go_package = "v1beta1";
message Event {
// ObjectMeta is included for interoperability with API infrastructure.
// +optional
// DEPRECATED: Use StageTimestamp which supports micro second instead of ObjectMeta.CreateTimestamp
// and the rest of the object is not used
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// AuditLevel at which event was generated
optional string level = 2;
// Time the request reached the apiserver.
// DEPRECATED: Use RequestReceivedTimestamp which supports micro second instead.
optional k8s.io.apimachinery.pkg.apis.meta.v1.Time timestamp = 3;
// Unique audit ID, generated for each request.
@ -90,6 +93,14 @@ message Event {
// at Response Level.
// +optional
optional k8s.io.apimachinery.pkg.runtime.Unknown responseObject = 14;
// Time the request reached the apiserver.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.MicroTime requestReceivedTimestamp = 15;
// Time the request reached current audit stage.
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.MicroTime stageTimestamp = 16;
}
// EventList is a list of audit Events.

View File

@ -73,12 +73,15 @@ type Event struct {
metav1.TypeMeta `json:",inline"`
// ObjectMeta is included for interoperability with API infrastructure.
// +optional
// DEPRECATED: Use StageTimestamp which supports micro second instead of ObjectMeta.CreateTimestamp
// and the rest of the object is not used
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// AuditLevel at which event was generated
Level Level `json:"level" protobuf:"bytes,2,opt,name=level,casttype=Level"`
// Time the request reached the apiserver.
// DEPRECATED: Use RequestReceivedTimestamp which supports micro second instead.
Timestamp metav1.Time `json:"timestamp" protobuf:"bytes,3,opt,name=timestamp"`
// Unique audit ID, generated for each request.
AuditID types.UID `json:"auditID" protobuf:"bytes,4,opt,name=auditID,casttype=k8s.io/apimachinery/pkg/types.UID"`
@ -119,6 +122,12 @@ type Event struct {
// at Response Level.
// +optional
ResponseObject *runtime.Unknown `json:"responseObject,omitempty" protobuf:"bytes,14,opt,name=responseObject"`
// Time the request reached the apiserver.
// +optional
RequestReceivedTimestamp metav1.MicroTime `json:"requestReceivedTimestamp" protobuf:"bytes,15,opt,name=requestReceivedTimestamp"`
// Time the request reached current audit stage.
// +optional
StageTimestamp metav1.MicroTime `json:"stageTimestamp" protobuf:"bytes,16,opt,name=stageTimestamp"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

View File

@ -56,9 +56,9 @@ func RegisterConversions(scheme *runtime.Scheme) error {
}
func autoConvert_v1beta1_Event_To_audit_Event(in *Event, out *audit.Event, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
// WARNING: in.ObjectMeta requires manual conversion: does not exist in peer-type
out.Level = audit.Level(in.Level)
out.Timestamp = in.Timestamp
// WARNING: in.Timestamp requires manual conversion: does not exist in peer-type
out.AuditID = types.UID(in.AuditID)
out.Stage = audit.Stage(in.Stage)
out.RequestURI = in.RequestURI
@ -73,18 +73,13 @@ func autoConvert_v1beta1_Event_To_audit_Event(in *Event, out *audit.Event, s con
out.ResponseStatus = (*v1.Status)(unsafe.Pointer(in.ResponseStatus))
out.RequestObject = (*runtime.Unknown)(unsafe.Pointer(in.RequestObject))
out.ResponseObject = (*runtime.Unknown)(unsafe.Pointer(in.ResponseObject))
out.RequestReceivedTimestamp = in.RequestReceivedTimestamp
out.StageTimestamp = in.StageTimestamp
return nil
}
// Convert_v1beta1_Event_To_audit_Event is an autogenerated conversion function.
func Convert_v1beta1_Event_To_audit_Event(in *Event, out *audit.Event, s conversion.Scope) error {
return autoConvert_v1beta1_Event_To_audit_Event(in, out, s)
}
func autoConvert_audit_Event_To_v1beta1_Event(in *audit.Event, out *Event, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.Level = Level(in.Level)
out.Timestamp = in.Timestamp
out.AuditID = types.UID(in.AuditID)
out.Stage = Stage(in.Stage)
out.RequestURI = in.RequestURI
@ -99,17 +94,24 @@ func autoConvert_audit_Event_To_v1beta1_Event(in *audit.Event, out *Event, s con
out.ResponseStatus = (*v1.Status)(unsafe.Pointer(in.ResponseStatus))
out.RequestObject = (*runtime.Unknown)(unsafe.Pointer(in.RequestObject))
out.ResponseObject = (*runtime.Unknown)(unsafe.Pointer(in.ResponseObject))
out.RequestReceivedTimestamp = in.RequestReceivedTimestamp
out.StageTimestamp = in.StageTimestamp
return nil
}
// Convert_audit_Event_To_v1beta1_Event is an autogenerated conversion function.
func Convert_audit_Event_To_v1beta1_Event(in *audit.Event, out *Event, s conversion.Scope) error {
return autoConvert_audit_Event_To_v1beta1_Event(in, out, s)
}
func autoConvert_v1beta1_EventList_To_audit_EventList(in *EventList, out *audit.EventList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]audit.Event)(unsafe.Pointer(&in.Items))
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]audit.Event, len(*in))
for i := range *in {
if err := Convert_v1beta1_Event_To_audit_Event(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
@ -120,7 +122,17 @@ func Convert_v1beta1_EventList_To_audit_EventList(in *EventList, out *audit.Even
func autoConvert_audit_EventList_To_v1beta1_EventList(in *audit.EventList, out *EventList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]Event)(unsafe.Pointer(&in.Items))
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Event, len(*in))
for i := range *in {
if err := Convert_audit_Event_To_v1beta1_Event(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}

View File

@ -126,6 +126,8 @@ func (in *Event) DeepCopyInto(out *Event) {
(*in).DeepCopyInto(*out)
}
}
in.RequestReceivedTimestamp.DeepCopyInto(&out.RequestReceivedTimestamp)
in.StageTimestamp.DeepCopyInto(&out.StageTimestamp)
return
}

View File

@ -71,8 +71,6 @@ func GetGeneratedDeepCopyFuncs() []conversion.GeneratedDeepCopyFunc {
func (in *Event) DeepCopyInto(out *Event) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Timestamp.DeepCopyInto(&out.Timestamp)
in.User.DeepCopyInto(&out.User)
if in.ImpersonatedUser != nil {
in, out := &in.ImpersonatedUser, &out.ImpersonatedUser
@ -124,6 +122,8 @@ func (in *Event) DeepCopyInto(out *Event) {
(*in).DeepCopyInto(*out)
}
}
in.RequestReceivedTimestamp.DeepCopyInto(&out.RequestReceivedTimestamp)
in.StageTimestamp.DeepCopyInto(&out.StageTimestamp)
return
}

View File

@ -61,7 +61,7 @@ func EventString(ev *auditinternal.Event) string {
}
return fmt.Sprintf("%s AUDIT: id=%q stage=%q ip=%q method=%q user=%q groups=%q as=%q asgroups=%q namespace=%q uri=%q response=\"%s\"",
ev.Timestamp.Format(time.RFC3339Nano), ev.AuditID, ev.Stage, ip, ev.Verb, username, groups, asuser, asgroups, namespace, ev.RequestURI, response)
ev.RequestReceivedTimestamp.Format(time.RFC3339Nano), ev.AuditID, ev.Stage, ip, ev.Verb, username, groups, asuser, asgroups, namespace, ev.RequestURI, response)
}
func auditStringSlice(inList []string) string {

View File

@ -40,7 +40,7 @@ import (
func NewEventFromRequest(req *http.Request, level auditinternal.Level, attribs authorizer.Attributes) (*auditinternal.Event, error) {
ev := &auditinternal.Event{
Timestamp: metav1.NewTime(time.Now()),
RequestReceivedTimestamp: metav1.NewMicroTime(time.Now()),
Verb: attribs.GetVerb(),
RequestURI: req.URL.RequestURI(),
}

View File

@ -148,7 +148,12 @@ func processAuditEvent(sink audit.Sink, ev *auditinternal.Event, omitStages []au
return
}
}
ev.CreationTimestamp = metav1.NewTime(time.Now())
if ev.Stage == auditinternal.StageRequestReceived {
ev.StageTimestamp = metav1.NewMicroTime(ev.RequestReceivedTimestamp.Time)
} else {
ev.StageTimestamp = metav1.NewMicroTime(time.Now())
}
audit.ObserveEvent()
sink.ProcessEvents(ev)
}

View File

@ -73,10 +73,10 @@ func TestLogEventsLegacy(t *testing.T) {
SourceIPs: []string{
"127.0.0.1",
},
Timestamp: metav1.NewTime(time.Now()),
AuditID: types.UID(uuid.NewRandom().String()),
Stage: auditinternal.StageRequestReceived,
Verb: "get",
RequestReceivedTimestamp: metav1.NewMicroTime(time.Now()),
AuditID: types.UID(uuid.NewRandom().String()),
Stage: auditinternal.StageRequestReceived,
Verb: "get",
User: auditinternal.UserInfo{
Username: "admin",
Groups: []string{
@ -130,13 +130,11 @@ func TestLogEventsJson(t *testing.T) {
SourceIPs: []string{
"127.0.0.1",
},
// When encoding to json format, the nanosecond part of timestamp is
// lost and it will become zero when we decode event back, so we rounding
// timestamp down to a multiple of second.
Timestamp: metav1.NewTime(time.Now().Truncate(time.Second)),
AuditID: types.UID(uuid.NewRandom().String()),
Stage: auditinternal.StageRequestReceived,
Verb: "get",
RequestReceivedTimestamp: metav1.NewMicroTime(time.Now().Truncate(time.Microsecond)),
StageTimestamp: metav1.NewMicroTime(time.Now().Truncate(time.Microsecond)),
AuditID: types.UID(uuid.NewRandom().String()),
Stage: auditinternal.StageRequestReceived,
Verb: "get",
User: auditinternal.UserInfo{
Username: "admin",
Groups: []string{