Commit 74f50193 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #46065 from timstclair/audit-api

Automatic merge from submit-queue (batch tested with PRs 45913, 46065, 46352, 46363, 46373) Update audit API with missing pieces Follow-up to https://github.com/kubernetes/kubernetes/pull/45315 to resolve pending decisions & issues, including: - Audit ID format - Identifying audit event "stage" - Request/Response object format (resolve conversion issue) - Add a subresource field to the `ObjectReference` For https://github.com/kubernetes/features/issues/22 ~~TODO: Add generated code once we've reached consensus on the types.~~ /cc @deads2k @ihmccreery @sttts @soltysh @ericchiang
parents fe5b3033 4c54970d
...@@ -22,6 +22,14 @@ import ( ...@@ -22,6 +22,14 @@ import (
"k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/types"
) )
// Header keys used by the audit system.
const (
// Header to hold the audit ID as the request is propagated through the serving hierarchy. The
// Audit-ID header should be set by the first server to receive the request (e.g. the federation
// server or kube-aggregator).
HeaderAuditID = "Audit-ID"
)
// Level defines the amount of information logged during auditing // Level defines the amount of information logged during auditing
type Level string type Level string
...@@ -39,6 +47,22 @@ const ( ...@@ -39,6 +47,22 @@ const (
LevelRequestResponse Level = "RequestResponse" LevelRequestResponse Level = "RequestResponse"
) )
// Stage defines the stages in request handling that audit events may be generated.
type Stage string
// Valid audit stages.
const (
// The stage for events generated as soon as the audit handler receives the request, and before it
// is delegated down the handler chain.
StageRequestReceived = "RequestReceived"
// The stage for events generated once the response headers are sent, but before the response body
// is sent. This stage is only generated for long-running requests (e.g. watch).
StageResponseStarted = "ResponseStarted"
// The stage for events generated once the response body has been completed, and no more bytes
// will be sent.
StageResponseComplete = "ResponseComplete"
)
// Event captures all the information that can be included in an API audit log. // Event captures all the information that can be included in an API audit log.
type Event struct { type Event struct {
metav1.TypeMeta metav1.TypeMeta
...@@ -53,6 +77,9 @@ type Event struct { ...@@ -53,6 +77,9 @@ type Event struct {
Timestamp metav1.Time Timestamp metav1.Time
// Unique audit ID, generated for each request. // Unique audit ID, generated for each request.
AuditID types.UID AuditID types.UID
// Stage of the request handling when this event instance was generated.
Stage Stage
// RequestURI is the request URI as sent by the client to a server. // RequestURI is the request URI as sent by the client to a server.
RequestURI string RequestURI string
// Verb is the kubernetes verb associated with the request. // Verb is the kubernetes verb associated with the request.
...@@ -81,12 +108,12 @@ type Event struct { ...@@ -81,12 +108,12 @@ type Event struct {
// merging. It is an external versioned object type, and may not be a valid object on its own. // merging. It is an external versioned object type, and may not be a valid object on its own.
// Omitted for non-resource requests. Only logged at Request Level and higher. // Omitted for non-resource requests. Only logged at Request Level and higher.
// +optional // +optional
RequestObject runtime.Unknown RequestObject *runtime.Unknown
// API object returned in the response, in JSON. The ResponseObject is recorded after conversion // 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. // at Response Level.
// +optional // +optional
ResponseObject runtime.Unknown ResponseObject *runtime.Unknown
} }
// EventList is a list of audit Events. // EventList is a list of audit Events.
...@@ -191,6 +218,8 @@ type ObjectReference struct { ...@@ -191,6 +218,8 @@ type ObjectReference struct {
APIVersion string APIVersion string
// +optional // +optional
ResourceVersion string ResourceVersion string
// +optional
Subresource string
} }
// UserInfo holds the information about the user needed to implement the // UserInfo holds the information about the user needed to implement the
......
...@@ -65,7 +65,7 @@ func init() { ...@@ -65,7 +65,7 @@ func init() {
} }
if false { // reference the types, but skip this branch at build/run time if false { // reference the types, but skip this branch at build/run time
var v0 pkg1_v1.TypeMeta var v0 pkg1_v1.TypeMeta
var v1 pkg4_runtime.RawExtension var v1 pkg4_runtime.Unknown
var v2 pkg2_types.UID var v2 pkg2_types.UID
var v3 pkg3_v1.UserInfo var v3 pkg3_v1.UserInfo
var v4 time.Time var v4 time.Time
...@@ -99,6 +99,32 @@ func (x *Level) CodecDecodeSelf(d *codec1978.Decoder) { ...@@ -99,6 +99,32 @@ func (x *Level) CodecDecodeSelf(d *codec1978.Decoder) {
} }
} }
func (x Stage) CodecEncodeSelf(e *codec1978.Encoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperEncoder(e)
_, _, _ = h, z, r
yym1 := z.EncBinary()
_ = yym1
if false {
} else if z.HasExtensions() && z.EncExt(x) {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x))
}
}
func (x *Stage) CodecDecodeSelf(d *codec1978.Decoder) {
var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r
yym1 := z.DecBinary()
_ = yym1
if false {
} else if z.HasExtensions() && z.DecExt(x) {
} else {
*((*string)(x)) = r.DecodeString()
}
}
func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
var h codecSelfer1234 var h codecSelfer1234
z, r := codec1978.GenHelperEncoder(e) z, r := codec1978.GenHelperEncoder(e)
...@@ -113,24 +139,23 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -113,24 +139,23 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
} else { } else {
yysep2 := !z.EncBinary() yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [15]bool var yyq2 [16]bool
_, _, _ = yysep2, yyq2, yy2arr2 _, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false const yyr2 bool = false
yyq2[0] = x.Kind != "" yyq2[0] = x.Kind != ""
yyq2[1] = x.APIVersion != "" yyq2[1] = x.APIVersion != ""
yyq2[2] = true yyq2[2] = true
yyq2[5] = x.AuditID != "" yyq2[10] = x.ImpersonatedUser != nil
yyq2[9] = x.ImpersonatedUser != nil yyq2[11] = len(x.SourceIPs) != 0
yyq2[10] = len(x.SourceIPs) != 0 yyq2[12] = x.ObjectRef != nil
yyq2[11] = x.ObjectRef != nil yyq2[13] = x.ResponseStatus != nil
yyq2[12] = x.ResponseStatus != nil yyq2[14] = x.RequestObject != nil
yyq2[13] = true yyq2[15] = x.ResponseObject != nil
yyq2[14] = true
var yynn2 int var yynn2 int
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
r.EncodeArrayStart(15) r.EncodeArrayStart(16)
} else { } else {
yynn2 = 5 yynn2 = 7
for _, b := range yyq2 { for _, b := range yyq2 {
if b { if b {
yynn2++ yynn2++
...@@ -260,35 +285,38 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -260,35 +285,38 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[5] { yym23 := z.EncBinary()
yym23 := z.EncBinary() _ = yym23
_ = yym23 if false {
if false { } else if z.HasExtensions() && z.EncExt(x.AuditID) {
} else if z.HasExtensions() && z.EncExt(x.AuditID) {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.AuditID))
}
} else { } else {
r.EncodeString(codecSelferC_UTF81234, "") r.EncodeString(codecSelferC_UTF81234, string(x.AuditID))
} }
} else { } else {
if yyq2[5] { z.EncSendContainerState(codecSelfer_containerMapKey1234)
z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("auditID"))
r.EncodeString(codecSelferC_UTF81234, string("auditID")) z.EncSendContainerState(codecSelfer_containerMapValue1234)
z.EncSendContainerState(codecSelfer_containerMapValue1234) yym24 := z.EncBinary()
yym24 := z.EncBinary() _ = yym24
_ = yym24 if false {
if false { } else if z.HasExtensions() && z.EncExt(x.AuditID) {
} else if z.HasExtensions() && z.EncExt(x.AuditID) { } else {
} else { r.EncodeString(codecSelferC_UTF81234, string(x.AuditID))
r.EncodeString(codecSelferC_UTF81234, string(x.AuditID))
}
} }
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
yym26 := z.EncBinary() x.Stage.CodecEncodeSelf(e)
_ = yym26 } else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("stage"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
x.Stage.CodecEncodeSelf(e)
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
yym29 := z.EncBinary()
_ = yym29
if false { if false {
} else { } else {
r.EncodeString(codecSelferC_UTF81234, string(x.RequestURI)) r.EncodeString(codecSelferC_UTF81234, string(x.RequestURI))
...@@ -297,8 +325,8 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -297,8 +325,8 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("requestURI")) r.EncodeString(codecSelferC_UTF81234, string("requestURI"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym27 := z.EncBinary() yym30 := z.EncBinary()
_ = yym27 _ = yym30
if false { if false {
} else { } else {
r.EncodeString(codecSelferC_UTF81234, string(x.RequestURI)) r.EncodeString(codecSelferC_UTF81234, string(x.RequestURI))
...@@ -306,8 +334,8 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -306,8 +334,8 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
yym29 := z.EncBinary() yym32 := z.EncBinary()
_ = yym29 _ = yym32
if false { if false {
} else { } else {
r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) r.EncodeString(codecSelferC_UTF81234, string(x.Verb))
...@@ -316,8 +344,8 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -316,8 +344,8 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("verb")) r.EncodeString(codecSelferC_UTF81234, string("verb"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym30 := z.EncBinary() yym33 := z.EncBinary()
_ = yym30 _ = yym33
if false { if false {
} else { } else {
r.EncodeString(codecSelferC_UTF81234, string(x.Verb)) r.EncodeString(codecSelferC_UTF81234, string(x.Verb))
...@@ -325,35 +353,35 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -325,35 +353,35 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
yy32 := &x.User yy35 := &x.User
yym33 := z.EncBinary() yym36 := z.EncBinary()
_ = yym33 _ = yym36
if false { if false {
} else if z.HasExtensions() && z.EncExt(yy32) { } else if z.HasExtensions() && z.EncExt(yy35) {
} else { } else {
z.EncFallback(yy32) z.EncFallback(yy35)
} }
} else { } else {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("user")) r.EncodeString(codecSelferC_UTF81234, string("user"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
yy34 := &x.User yy37 := &x.User
yym35 := z.EncBinary() yym38 := z.EncBinary()
_ = yym35 _ = yym38
if false { if false {
} else if z.HasExtensions() && z.EncExt(yy34) { } else if z.HasExtensions() && z.EncExt(yy37) {
} else { } else {
z.EncFallback(yy34) z.EncFallback(yy37)
} }
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[9] { if yyq2[10] {
if x.ImpersonatedUser == nil { if x.ImpersonatedUser == nil {
r.EncodeNil() r.EncodeNil()
} else { } else {
yym37 := z.EncBinary() yym40 := z.EncBinary()
_ = yym37 _ = yym40
if false { if false {
} else if z.HasExtensions() && z.EncExt(x.ImpersonatedUser) { } else if z.HasExtensions() && z.EncExt(x.ImpersonatedUser) {
} else { } else {
...@@ -364,15 +392,15 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -364,15 +392,15 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
r.EncodeNil() r.EncodeNil()
} }
} else { } else {
if yyq2[9] { if yyq2[10] {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("impersonatedUser")) r.EncodeString(codecSelferC_UTF81234, string("impersonatedUser"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.ImpersonatedUser == nil { if x.ImpersonatedUser == nil {
r.EncodeNil() r.EncodeNil()
} else { } else {
yym38 := z.EncBinary() yym41 := z.EncBinary()
_ = yym38 _ = yym41
if false { if false {
} else if z.HasExtensions() && z.EncExt(x.ImpersonatedUser) { } else if z.HasExtensions() && z.EncExt(x.ImpersonatedUser) {
} else { } else {
...@@ -383,12 +411,12 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -383,12 +411,12 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[10] { if yyq2[11] {
if x.SourceIPs == nil { if x.SourceIPs == nil {
r.EncodeNil() r.EncodeNil()
} else { } else {
yym40 := z.EncBinary() yym43 := z.EncBinary()
_ = yym40 _ = yym43
if false { if false {
} else { } else {
z.F.EncSliceStringV(x.SourceIPs, false, e) z.F.EncSliceStringV(x.SourceIPs, false, e)
...@@ -398,15 +426,15 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -398,15 +426,15 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
r.EncodeNil() r.EncodeNil()
} }
} else { } else {
if yyq2[10] { if yyq2[11] {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("sourceIPs")) r.EncodeString(codecSelferC_UTF81234, string("sourceIPs"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.SourceIPs == nil { if x.SourceIPs == nil {
r.EncodeNil() r.EncodeNil()
} else { } else {
yym41 := z.EncBinary() yym44 := z.EncBinary()
_ = yym41 _ = yym44
if false { if false {
} else { } else {
z.F.EncSliceStringV(x.SourceIPs, false, e) z.F.EncSliceStringV(x.SourceIPs, false, e)
...@@ -416,7 +444,7 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -416,7 +444,7 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[11] { if yyq2[12] {
if x.ObjectRef == nil { if x.ObjectRef == nil {
r.EncodeNil() r.EncodeNil()
} else { } else {
...@@ -426,7 +454,7 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -426,7 +454,7 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
r.EncodeNil() r.EncodeNil()
} }
} else { } else {
if yyq2[11] { if yyq2[12] {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("objectRef")) r.EncodeString(codecSelferC_UTF81234, string("objectRef"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
...@@ -439,12 +467,12 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -439,12 +467,12 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[12] { if yyq2[13] {
if x.ResponseStatus == nil { if x.ResponseStatus == nil {
r.EncodeNil() r.EncodeNil()
} else { } else {
yym46 := z.EncBinary() yym49 := z.EncBinary()
_ = yym46 _ = yym49
if false { if false {
} else if z.HasExtensions() && z.EncExt(x.ResponseStatus) { } else if z.HasExtensions() && z.EncExt(x.ResponseStatus) {
} else { } else {
...@@ -455,15 +483,15 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -455,15 +483,15 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
r.EncodeNil() r.EncodeNil()
} }
} else { } else {
if yyq2[12] { if yyq2[13] {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("responseStatus")) r.EncodeString(codecSelferC_UTF81234, string("responseStatus"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.ResponseStatus == nil { if x.ResponseStatus == nil {
r.EncodeNil() r.EncodeNil()
} else { } else {
yym47 := z.EncBinary() yym50 := z.EncBinary()
_ = yym47 _ = yym50
if false { if false {
} else if z.HasExtensions() && z.EncExt(x.ResponseStatus) { } else if z.HasExtensions() && z.EncExt(x.ResponseStatus) {
} else { } else {
...@@ -474,67 +502,79 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -474,67 +502,79 @@ func (x *Event) CodecEncodeSelf(e *codec1978.Encoder) {
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[13] { if yyq2[14] {
yy49 := &x.RequestObject if x.RequestObject == nil {
yym50 := z.EncBinary() r.EncodeNil()
_ = yym50
if false {
} else if z.HasExtensions() && z.EncExt(yy49) {
} else if !yym50 && z.IsJSONHandle() {
z.EncJSONMarshal(yy49)
} else { } else {
z.EncFallback(yy49) yym52 := z.EncBinary()
_ = yym52
if false {
} else if z.HasExtensions() && z.EncExt(x.RequestObject) {
} else if !yym52 && z.IsJSONHandle() {
z.EncJSONMarshal(x.RequestObject)
} else {
z.EncFallback(x.RequestObject)
}
} }
} else { } else {
r.EncodeNil() r.EncodeNil()
} }
} else { } else {
if yyq2[13] { if yyq2[14] {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("requestObject")) r.EncodeString(codecSelferC_UTF81234, string("requestObject"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
yy51 := &x.RequestObject if x.RequestObject == nil {
yym52 := z.EncBinary() r.EncodeNil()
_ = yym52
if false {
} else if z.HasExtensions() && z.EncExt(yy51) {
} else if !yym52 && z.IsJSONHandle() {
z.EncJSONMarshal(yy51)
} else { } else {
z.EncFallback(yy51) yym53 := z.EncBinary()
_ = yym53
if false {
} else if z.HasExtensions() && z.EncExt(x.RequestObject) {
} else if !yym53 && z.IsJSONHandle() {
z.EncJSONMarshal(x.RequestObject)
} else {
z.EncFallback(x.RequestObject)
}
} }
} }
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234) z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[14] { if yyq2[15] {
yy54 := &x.ResponseObject if x.ResponseObject == nil {
yym55 := z.EncBinary() r.EncodeNil()
_ = yym55
if false {
} else if z.HasExtensions() && z.EncExt(yy54) {
} else if !yym55 && z.IsJSONHandle() {
z.EncJSONMarshal(yy54)
} else { } else {
z.EncFallback(yy54) yym55 := z.EncBinary()
_ = yym55
if false {
} else if z.HasExtensions() && z.EncExt(x.ResponseObject) {
} else if !yym55 && z.IsJSONHandle() {
z.EncJSONMarshal(x.ResponseObject)
} else {
z.EncFallback(x.ResponseObject)
}
} }
} else { } else {
r.EncodeNil() r.EncodeNil()
} }
} else { } else {
if yyq2[14] { if yyq2[15] {
z.EncSendContainerState(codecSelfer_containerMapKey1234) z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("responseObject")) r.EncodeString(codecSelferC_UTF81234, string("responseObject"))
z.EncSendContainerState(codecSelfer_containerMapValue1234) z.EncSendContainerState(codecSelfer_containerMapValue1234)
yy56 := &x.ResponseObject if x.ResponseObject == nil {
yym57 := z.EncBinary() r.EncodeNil()
_ = yym57
if false {
} else if z.HasExtensions() && z.EncExt(yy56) {
} else if !yym57 && z.IsJSONHandle() {
z.EncJSONMarshal(yy56)
} else { } else {
z.EncFallback(yy56) yym56 := z.EncBinary()
_ = yym56
if false {
} else if z.HasExtensions() && z.EncExt(x.ResponseObject) {
} else if !yym56 && z.IsJSONHandle() {
z.EncJSONMarshal(x.ResponseObject)
} else {
z.EncFallback(x.ResponseObject)
}
} }
} }
} }
...@@ -673,41 +713,48 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { ...@@ -673,41 +713,48 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
*((*string)(yyv13)) = r.DecodeString() *((*string)(yyv13)) = r.DecodeString()
} }
} }
case "stage":
if r.TryDecodeAsNil() {
x.Stage = ""
} else {
yyv15 := &x.Stage
yyv15.CodecDecodeSelf(d)
}
case "requestURI": case "requestURI":
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.RequestURI = "" x.RequestURI = ""
} else { } else {
yyv15 := &x.RequestURI yyv16 := &x.RequestURI
yym16 := z.DecBinary() yym17 := z.DecBinary()
_ = yym16 _ = yym17
if false { if false {
} else { } else {
*((*string)(yyv15)) = r.DecodeString() *((*string)(yyv16)) = r.DecodeString()
} }
} }
case "verb": case "verb":
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Verb = "" x.Verb = ""
} else { } else {
yyv17 := &x.Verb yyv18 := &x.Verb
yym18 := z.DecBinary() yym19 := z.DecBinary()
_ = yym18 _ = yym19
if false { if false {
} else { } else {
*((*string)(yyv17)) = r.DecodeString() *((*string)(yyv18)) = r.DecodeString()
} }
} }
case "user": case "user":
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.User = pkg3_v1.UserInfo{} x.User = pkg3_v1.UserInfo{}
} else { } else {
yyv19 := &x.User yyv20 := &x.User
yym20 := z.DecBinary() yym21 := z.DecBinary()
_ = yym20 _ = yym21
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv19) { } else if z.HasExtensions() && z.DecExt(yyv20) {
} else { } else {
z.DecFallback(yyv19, false) z.DecFallback(yyv20, false)
} }
} }
case "impersonatedUser": case "impersonatedUser":
...@@ -719,8 +766,8 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { ...@@ -719,8 +766,8 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
if x.ImpersonatedUser == nil { if x.ImpersonatedUser == nil {
x.ImpersonatedUser = new(pkg3_v1.UserInfo) x.ImpersonatedUser = new(pkg3_v1.UserInfo)
} }
yym22 := z.DecBinary() yym23 := z.DecBinary()
_ = yym22 _ = yym23
if false { if false {
} else if z.HasExtensions() && z.DecExt(x.ImpersonatedUser) { } else if z.HasExtensions() && z.DecExt(x.ImpersonatedUser) {
} else { } else {
...@@ -731,12 +778,12 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { ...@@ -731,12 +778,12 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.SourceIPs = nil x.SourceIPs = nil
} else { } else {
yyv23 := &x.SourceIPs yyv24 := &x.SourceIPs
yym24 := z.DecBinary() yym25 := z.DecBinary()
_ = yym24 _ = yym25
if false { if false {
} else { } else {
z.F.DecSliceStringX(yyv23, false, d) z.F.DecSliceStringX(yyv24, false, d)
} }
} }
case "objectRef": case "objectRef":
...@@ -759,8 +806,8 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { ...@@ -759,8 +806,8 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
if x.ResponseStatus == nil { if x.ResponseStatus == nil {
x.ResponseStatus = new(pkg1_v1.Status) x.ResponseStatus = new(pkg1_v1.Status)
} }
yym27 := z.DecBinary() yym28 := z.DecBinary()
_ = yym27 _ = yym28
if false { if false {
} else if z.HasExtensions() && z.DecExt(x.ResponseStatus) { } else if z.HasExtensions() && z.DecExt(x.ResponseStatus) {
} else { } else {
...@@ -769,32 +816,40 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { ...@@ -769,32 +816,40 @@ func (x *Event) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
} }
case "requestObject": case "requestObject":
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.RequestObject = pkg4_runtime.RawExtension{} if x.RequestObject != nil {
x.RequestObject = nil
}
} else { } else {
yyv28 := &x.RequestObject if x.RequestObject == nil {
yym29 := z.DecBinary() x.RequestObject = new(pkg4_runtime.Unknown)
_ = yym29 }
yym30 := z.DecBinary()
_ = yym30
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv28) { } else if z.HasExtensions() && z.DecExt(x.RequestObject) {
} else if !yym29 && z.IsJSONHandle() { } else if !yym30 && z.IsJSONHandle() {
z.DecJSONUnmarshal(yyv28) z.DecJSONUnmarshal(x.RequestObject)
} else { } else {
z.DecFallback(yyv28, false) z.DecFallback(x.RequestObject, false)
} }
} }
case "responseObject": case "responseObject":
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.ResponseObject = pkg4_runtime.RawExtension{} if x.ResponseObject != nil {
x.ResponseObject = nil
}
} else { } else {
yyv30 := &x.ResponseObject if x.ResponseObject == nil {
yym31 := z.DecBinary() x.ResponseObject = new(pkg4_runtime.Unknown)
_ = yym31 }
yym32 := z.DecBinary()
_ = yym32
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv30) { } else if z.HasExtensions() && z.DecExt(x.ResponseObject) {
} else if !yym31 && z.IsJSONHandle() { } else if !yym32 && z.IsJSONHandle() {
z.DecJSONUnmarshal(yyv30) z.DecJSONUnmarshal(x.ResponseObject)
} else { } else {
z.DecFallback(yyv30, false) z.DecFallback(x.ResponseObject, false)
} }
} }
default: default:
...@@ -808,16 +863,16 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -808,16 +863,16 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
var h codecSelfer1234 var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d) z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r _, _, _ = h, z, r
var yyj32 int var yyj33 int
var yyb32 bool var yyb33 bool
var yyhl32 bool = l >= 0 var yyhl33 bool = l >= 0
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -825,21 +880,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -825,21 +880,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Kind = "" x.Kind = ""
} else { } else {
yyv33 := &x.Kind yyv34 := &x.Kind
yym34 := z.DecBinary() yym35 := z.DecBinary()
_ = yym34 _ = yym35
if false { if false {
} else { } else {
*((*string)(yyv33)) = r.DecodeString() *((*string)(yyv34)) = r.DecodeString()
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -847,21 +902,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -847,21 +902,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.APIVersion = "" x.APIVersion = ""
} else { } else {
yyv35 := &x.APIVersion yyv36 := &x.APIVersion
yym36 := z.DecBinary() yym37 := z.DecBinary()
_ = yym36 _ = yym37
if false { if false {
} else { } else {
*((*string)(yyv35)) = r.DecodeString() *((*string)(yyv36)) = r.DecodeString()
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -869,22 +924,22 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -869,22 +924,22 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.ObjectMeta = pkg1_v1.ObjectMeta{} x.ObjectMeta = pkg1_v1.ObjectMeta{}
} else { } else {
yyv37 := &x.ObjectMeta yyv38 := &x.ObjectMeta
yym38 := z.DecBinary() yym39 := z.DecBinary()
_ = yym38 _ = yym39
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv37) { } else if z.HasExtensions() && z.DecExt(yyv38) {
} else { } else {
z.DecFallback(yyv37, false) z.DecFallback(yyv38, false)
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -892,16 +947,16 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -892,16 +947,16 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Level = "" x.Level = ""
} else { } else {
yyv39 := &x.Level yyv40 := &x.Level
yyv39.CodecDecodeSelf(d) yyv40.CodecDecodeSelf(d)
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -909,26 +964,26 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -909,26 +964,26 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Timestamp = pkg1_v1.Time{} x.Timestamp = pkg1_v1.Time{}
} else { } else {
yyv40 := &x.Timestamp yyv41 := &x.Timestamp
yym41 := z.DecBinary() yym42 := z.DecBinary()
_ = yym41 _ = yym42
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv40) { } else if z.HasExtensions() && z.DecExt(yyv41) {
} else if yym41 { } else if yym42 {
z.DecBinaryUnmarshal(yyv40) z.DecBinaryUnmarshal(yyv41)
} else if !yym41 && z.IsJSONHandle() { } else if !yym42 && z.IsJSONHandle() {
z.DecJSONUnmarshal(yyv40) z.DecJSONUnmarshal(yyv41)
} else { } else {
z.DecFallback(yyv40, false) z.DecFallback(yyv41, false)
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -936,22 +991,39 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -936,22 +991,39 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.AuditID = "" x.AuditID = ""
} else { } else {
yyv42 := &x.AuditID yyv43 := &x.AuditID
yym43 := z.DecBinary() yym44 := z.DecBinary()
_ = yym43 _ = yym44
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv42) { } else if z.HasExtensions() && z.DecExt(yyv43) {
} else { } else {
*((*string)(yyv42)) = r.DecodeString() *((*string)(yyv43)) = r.DecodeString()
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.Stage = ""
} else {
yyv45 := &x.Stage
yyv45.CodecDecodeSelf(d)
}
yyj33++
if yyhl33 {
yyb33 = yyj33 > l
} else {
yyb33 = r.CheckBreak()
}
if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -959,21 +1031,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -959,21 +1031,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.RequestURI = "" x.RequestURI = ""
} else { } else {
yyv44 := &x.RequestURI yyv46 := &x.RequestURI
yym45 := z.DecBinary() yym47 := z.DecBinary()
_ = yym45 _ = yym47
if false { if false {
} else { } else {
*((*string)(yyv44)) = r.DecodeString() *((*string)(yyv46)) = r.DecodeString()
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -981,21 +1053,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -981,21 +1053,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Verb = "" x.Verb = ""
} else { } else {
yyv46 := &x.Verb yyv48 := &x.Verb
yym47 := z.DecBinary() yym49 := z.DecBinary()
_ = yym47 _ = yym49
if false { if false {
} else { } else {
*((*string)(yyv46)) = r.DecodeString() *((*string)(yyv48)) = r.DecodeString()
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -1003,22 +1075,22 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -1003,22 +1075,22 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.User = pkg3_v1.UserInfo{} x.User = pkg3_v1.UserInfo{}
} else { } else {
yyv48 := &x.User yyv50 := &x.User
yym49 := z.DecBinary() yym51 := z.DecBinary()
_ = yym49 _ = yym51
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv48) { } else if z.HasExtensions() && z.DecExt(yyv50) {
} else { } else {
z.DecFallback(yyv48, false) z.DecFallback(yyv50, false)
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -1031,21 +1103,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -1031,21 +1103,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if x.ImpersonatedUser == nil { if x.ImpersonatedUser == nil {
x.ImpersonatedUser = new(pkg3_v1.UserInfo) x.ImpersonatedUser = new(pkg3_v1.UserInfo)
} }
yym51 := z.DecBinary() yym53 := z.DecBinary()
_ = yym51 _ = yym53
if false { if false {
} else if z.HasExtensions() && z.DecExt(x.ImpersonatedUser) { } else if z.HasExtensions() && z.DecExt(x.ImpersonatedUser) {
} else { } else {
z.DecFallback(x.ImpersonatedUser, false) z.DecFallback(x.ImpersonatedUser, false)
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -1053,21 +1125,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -1053,21 +1125,21 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.SourceIPs = nil x.SourceIPs = nil
} else { } else {
yyv52 := &x.SourceIPs yyv54 := &x.SourceIPs
yym53 := z.DecBinary() yym55 := z.DecBinary()
_ = yym53 _ = yym55
if false { if false {
} else { } else {
z.F.DecSliceStringX(yyv52, false, d) z.F.DecSliceStringX(yyv54, false, d)
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -1082,13 +1154,13 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -1082,13 +1154,13 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
} }
x.ObjectRef.CodecDecodeSelf(d) x.ObjectRef.CodecDecodeSelf(d)
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -1101,76 +1173,84 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { ...@@ -1101,76 +1173,84 @@ func (x *Event) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
if x.ResponseStatus == nil { if x.ResponseStatus == nil {
x.ResponseStatus = new(pkg1_v1.Status) x.ResponseStatus = new(pkg1_v1.Status)
} }
yym56 := z.DecBinary() yym58 := z.DecBinary()
_ = yym56 _ = yym58
if false { if false {
} else if z.HasExtensions() && z.DecExt(x.ResponseStatus) { } else if z.HasExtensions() && z.DecExt(x.ResponseStatus) {
} else { } else {
z.DecFallback(x.ResponseStatus, false) z.DecFallback(x.ResponseStatus, false)
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
z.DecSendContainerState(codecSelfer_containerArrayElem1234) z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.RequestObject = pkg4_runtime.RawExtension{} if x.RequestObject != nil {
x.RequestObject = nil
}
} else { } else {
yyv57 := &x.RequestObject if x.RequestObject == nil {
yym58 := z.DecBinary() x.RequestObject = new(pkg4_runtime.Unknown)
_ = yym58 }
yym60 := z.DecBinary()
_ = yym60
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv57) { } else if z.HasExtensions() && z.DecExt(x.RequestObject) {
} else if !yym58 && z.IsJSONHandle() { } else if !yym60 && z.IsJSONHandle() {
z.DecJSONUnmarshal(yyv57) z.DecJSONUnmarshal(x.RequestObject)
} else { } else {
z.DecFallback(yyv57, false) z.DecFallback(x.RequestObject, false)
} }
} }
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
z.DecSendContainerState(codecSelfer_containerArrayElem1234) z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.ResponseObject = pkg4_runtime.RawExtension{} if x.ResponseObject != nil {
x.ResponseObject = nil
}
} else { } else {
yyv59 := &x.ResponseObject if x.ResponseObject == nil {
yym60 := z.DecBinary() x.ResponseObject = new(pkg4_runtime.Unknown)
_ = yym60 }
yym62 := z.DecBinary()
_ = yym62
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv59) { } else if z.HasExtensions() && z.DecExt(x.ResponseObject) {
} else if !yym60 && z.IsJSONHandle() { } else if !yym62 && z.IsJSONHandle() {
z.DecJSONUnmarshal(yyv59) z.DecJSONUnmarshal(x.ResponseObject)
} else { } else {
z.DecFallback(yyv59, false) z.DecFallback(x.ResponseObject, false)
} }
} }
for { for {
yyj32++ yyj33++
if yyhl32 { if yyhl33 {
yyb32 = yyj32 > l yyb33 = yyj33 > l
} else { } else {
yyb32 = r.CheckBreak() yyb33 = r.CheckBreak()
} }
if yyb32 { if yyb33 {
break break
} }
z.DecSendContainerState(codecSelfer_containerArrayElem1234) z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj32-1, "") z.DecStructFieldNotFound(yyj33-1, "")
} }
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
} }
...@@ -3104,7 +3184,7 @@ func (x *ObjectReference) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -3104,7 +3184,7 @@ func (x *ObjectReference) CodecEncodeSelf(e *codec1978.Encoder) {
} else { } else {
yysep2 := !z.EncBinary() yysep2 := !z.EncBinary()
yy2arr2 := z.EncBasicHandle().StructToArray yy2arr2 := z.EncBasicHandle().StructToArray
var yyq2 [6]bool var yyq2 [7]bool
_, _, _ = yysep2, yyq2, yy2arr2 _, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false const yyr2 bool = false
yyq2[0] = x.Resource != "" yyq2[0] = x.Resource != ""
...@@ -3113,9 +3193,10 @@ func (x *ObjectReference) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -3113,9 +3193,10 @@ func (x *ObjectReference) CodecEncodeSelf(e *codec1978.Encoder) {
yyq2[3] = x.UID != "" yyq2[3] = x.UID != ""
yyq2[4] = x.APIVersion != "" yyq2[4] = x.APIVersion != ""
yyq2[5] = x.ResourceVersion != "" yyq2[5] = x.ResourceVersion != ""
yyq2[6] = x.Subresource != ""
var yynn2 int var yynn2 int
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
r.EncodeArrayStart(6) r.EncodeArrayStart(7)
} else { } else {
yynn2 = 0 yynn2 = 0
for _, b := range yyq2 { for _, b := range yyq2 {
...@@ -3279,6 +3360,31 @@ func (x *ObjectReference) CodecEncodeSelf(e *codec1978.Encoder) { ...@@ -3279,6 +3360,31 @@ func (x *ObjectReference) CodecEncodeSelf(e *codec1978.Encoder) {
} }
} }
if yyr2 || yy2arr2 { if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[6] {
yym22 := z.EncBinary()
_ = yym22
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.Subresource))
}
} else {
r.EncodeString(codecSelferC_UTF81234, "")
}
} else {
if yyq2[6] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("subresource"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym23 := z.EncBinary()
_ = yym23
if false {
} else {
r.EncodeString(codecSelferC_UTF81234, string(x.Subresource))
}
}
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayEnd1234) z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
} else { } else {
z.EncSendContainerState(codecSelfer_containerMapEnd1234) z.EncSendContainerState(codecSelfer_containerMapEnd1234)
...@@ -3412,6 +3518,18 @@ func (x *ObjectReference) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { ...@@ -3412,6 +3518,18 @@ func (x *ObjectReference) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
*((*string)(yyv14)) = r.DecodeString() *((*string)(yyv14)) = r.DecodeString()
} }
} }
case "subresource":
if r.TryDecodeAsNil() {
x.Subresource = ""
} else {
yyv16 := &x.Subresource
yym17 := z.DecBinary()
_ = yym17
if false {
} else {
*((*string)(yyv16)) = r.DecodeString()
}
}
default: default:
z.DecStructFieldNotFound(-1, yys3) z.DecStructFieldNotFound(-1, yys3)
} // end switch yys3 } // end switch yys3
...@@ -3423,16 +3541,16 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) ...@@ -3423,16 +3541,16 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder)
var h codecSelfer1234 var h codecSelfer1234
z, r := codec1978.GenHelperDecoder(d) z, r := codec1978.GenHelperDecoder(d)
_, _, _ = h, z, r _, _, _ = h, z, r
var yyj16 int var yyj18 int
var yyb16 bool var yyb18 bool
var yyhl16 bool = l >= 0 var yyhl18 bool = l >= 0
yyj16++ yyj18++
if yyhl16 { if yyhl18 {
yyb16 = yyj16 > l yyb18 = yyj18 > l
} else { } else {
yyb16 = r.CheckBreak() yyb18 = r.CheckBreak()
} }
if yyb16 { if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -3440,21 +3558,21 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) ...@@ -3440,21 +3558,21 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder)
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Resource = "" x.Resource = ""
} else { } else {
yyv17 := &x.Resource yyv19 := &x.Resource
yym18 := z.DecBinary() yym20 := z.DecBinary()
_ = yym18 _ = yym20
if false { if false {
} else { } else {
*((*string)(yyv17)) = r.DecodeString() *((*string)(yyv19)) = r.DecodeString()
} }
} }
yyj16++ yyj18++
if yyhl16 { if yyhl18 {
yyb16 = yyj16 > l yyb18 = yyj18 > l
} else { } else {
yyb16 = r.CheckBreak() yyb18 = r.CheckBreak()
} }
if yyb16 { if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -3462,21 +3580,21 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) ...@@ -3462,21 +3580,21 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder)
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Namespace = "" x.Namespace = ""
} else { } else {
yyv19 := &x.Namespace yyv21 := &x.Namespace
yym20 := z.DecBinary() yym22 := z.DecBinary()
_ = yym20 _ = yym22
if false { if false {
} else { } else {
*((*string)(yyv19)) = r.DecodeString() *((*string)(yyv21)) = r.DecodeString()
} }
} }
yyj16++ yyj18++
if yyhl16 { if yyhl18 {
yyb16 = yyj16 > l yyb18 = yyj18 > l
} else { } else {
yyb16 = r.CheckBreak() yyb18 = r.CheckBreak()
} }
if yyb16 { if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -3484,21 +3602,21 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) ...@@ -3484,21 +3602,21 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder)
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.Name = "" x.Name = ""
} else { } else {
yyv21 := &x.Name yyv23 := &x.Name
yym22 := z.DecBinary() yym24 := z.DecBinary()
_ = yym22 _ = yym24
if false { if false {
} else { } else {
*((*string)(yyv21)) = r.DecodeString() *((*string)(yyv23)) = r.DecodeString()
} }
} }
yyj16++ yyj18++
if yyhl16 { if yyhl18 {
yyb16 = yyj16 > l yyb18 = yyj18 > l
} else { } else {
yyb16 = r.CheckBreak() yyb18 = r.CheckBreak()
} }
if yyb16 { if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -3506,22 +3624,22 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) ...@@ -3506,22 +3624,22 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder)
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.UID = "" x.UID = ""
} else { } else {
yyv23 := &x.UID yyv25 := &x.UID
yym24 := z.DecBinary() yym26 := z.DecBinary()
_ = yym24 _ = yym26
if false { if false {
} else if z.HasExtensions() && z.DecExt(yyv23) { } else if z.HasExtensions() && z.DecExt(yyv25) {
} else { } else {
*((*string)(yyv23)) = r.DecodeString() *((*string)(yyv25)) = r.DecodeString()
} }
} }
yyj16++ yyj18++
if yyhl16 { if yyhl18 {
yyb16 = yyj16 > l yyb18 = yyj18 > l
} else { } else {
yyb16 = r.CheckBreak() yyb18 = r.CheckBreak()
} }
if yyb16 { if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -3529,21 +3647,21 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) ...@@ -3529,21 +3647,21 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder)
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.APIVersion = "" x.APIVersion = ""
} else { } else {
yyv25 := &x.APIVersion yyv27 := &x.APIVersion
yym26 := z.DecBinary() yym28 := z.DecBinary()
_ = yym26 _ = yym28
if false { if false {
} else { } else {
*((*string)(yyv25)) = r.DecodeString() *((*string)(yyv27)) = r.DecodeString()
} }
} }
yyj16++ yyj18++
if yyhl16 { if yyhl18 {
yyb16 = yyj16 > l yyb18 = yyj18 > l
} else { } else {
yyb16 = r.CheckBreak() yyb18 = r.CheckBreak()
} }
if yyb16 { if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return return
} }
...@@ -3551,26 +3669,48 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) ...@@ -3551,26 +3669,48 @@ func (x *ObjectReference) codecDecodeSelfFromArray(l int, d *codec1978.Decoder)
if r.TryDecodeAsNil() { if r.TryDecodeAsNil() {
x.ResourceVersion = "" x.ResourceVersion = ""
} else { } else {
yyv27 := &x.ResourceVersion yyv29 := &x.ResourceVersion
yym28 := z.DecBinary() yym30 := z.DecBinary()
_ = yym28 _ = yym30
if false { if false {
} else { } else {
*((*string)(yyv27)) = r.DecodeString() *((*string)(yyv29)) = r.DecodeString()
}
}
yyj18++
if yyhl18 {
yyb18 = yyj18 > l
} else {
yyb18 = r.CheckBreak()
}
if yyb18 {
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
return
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.Subresource = ""
} else {
yyv31 := &x.Subresource
yym32 := z.DecBinary()
_ = yym32
if false {
} else {
*((*string)(yyv31)) = r.DecodeString()
} }
} }
for { for {
yyj16++ yyj18++
if yyhl16 { if yyhl18 {
yyb16 = yyj16 > l yyb18 = yyj18 > l
} else { } else {
yyb16 = r.CheckBreak() yyb18 = r.CheckBreak()
} }
if yyb16 { if yyb18 {
break break
} }
z.DecSendContainerState(codecSelfer_containerArrayElem1234) z.DecSendContainerState(codecSelfer_containerArrayElem1234)
z.DecStructFieldNotFound(yyj16-1, "") z.DecStructFieldNotFound(yyj18-1, "")
} }
z.DecSendContainerState(codecSelfer_containerArrayEnd1234) z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
} }
...@@ -3614,7 +3754,7 @@ func (x codecSelfer1234) decSliceEvent(v *[]Event, d *codec1978.Decoder) { ...@@ -3614,7 +3754,7 @@ func (x codecSelfer1234) decSliceEvent(v *[]Event, d *codec1978.Decoder) {
yyrg1 := len(yyv1) > 0 yyrg1 := len(yyv1) > 0
yyv21 := yyv1 yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 544) yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 496)
if yyrt1 { if yyrt1 {
if yyrl1 <= cap(yyv1) { if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1] yyv1 = yyv1[:yyrl1]
......
...@@ -23,6 +23,14 @@ import ( ...@@ -23,6 +23,14 @@ import (
authnv1 "k8s.io/client-go/pkg/apis/authentication/v1" authnv1 "k8s.io/client-go/pkg/apis/authentication/v1"
) )
// Header keys used by the audit system.
const (
// Header to hold the audit ID as the request is propagated through the serving hierarchy. The
// Audit-ID header should be set by the first server to receive the request (e.g. the federation
// server or kube-aggregator).
HeaderAuditID = "Audit-ID"
)
// Level defines the amount of information logged during auditing // Level defines the amount of information logged during auditing
type Level string type Level string
...@@ -40,6 +48,22 @@ const ( ...@@ -40,6 +48,22 @@ const (
LevelRequestResponse Level = "RequestResponse" LevelRequestResponse Level = "RequestResponse"
) )
// Stage defines the stages in request handling that audit events may be generated.
type Stage string
// Valid audit stages.
const (
// The stage for events generated as soon as the audit handler receives the request, and before it
// is delegated down the handler chain.
StageRequestReceived = "RequestReceived"
// The stage for events generated once the response headers are sent, but before the response body
// is sent. This stage is only generated for long-running requests (e.g. watch).
StageResponseStarted = "ResponseStarted"
// The stage for events generated once the response body has been completed, and no more bytes
// will be sent.
StageResponseComplete = "ResponseComplete"
)
// Event captures all the information that can be included in an API audit log. // Event captures all the information that can be included in an API audit log.
type Event struct { type Event struct {
metav1.TypeMeta `json:",inline"` metav1.TypeMeta `json:",inline"`
...@@ -53,7 +77,10 @@ type Event struct { ...@@ -53,7 +77,10 @@ type Event struct {
// Time the request reached the apiserver. // Time the request reached the apiserver.
Timestamp metav1.Time `json:"timestamp"` Timestamp metav1.Time `json:"timestamp"`
// Unique audit ID, generated for each request. // Unique audit ID, generated for each request.
AuditID types.UID `json:"auditID,omitempty"` AuditID types.UID `json:"auditID"`
// Stage of the request handling when this event instance was generated.
Stage Stage `json:"stage"`
// RequestURI is the request URI as sent by the client to a server. // RequestURI is the request URI as sent by the client to a server.
RequestURI string `json:"requestURI"` RequestURI string `json:"requestURI"`
// Verb is the kubernetes verb associated with the request. // Verb is the kubernetes verb associated with the request.
...@@ -82,12 +109,12 @@ type Event struct { ...@@ -82,12 +109,12 @@ type Event struct {
// merging. It is an external versioned object type, and may not be a valid object on its own. // merging. It is an external versioned object type, and may not be a valid object on its own.
// Omitted for non-resource requests. Only logged at Request Level and higher. // Omitted for non-resource requests. Only logged at Request Level and higher.
// +optional // +optional
RequestObject runtime.RawExtension `json:"requestObject,omitempty"` RequestObject *runtime.Unknown `json:"requestObject,omitempty"`
// API object returned in the response, in JSON. The ResponseObject is recorded after conversion // 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. // at Response Level.
// +optional // +optional
ResponseObject runtime.RawExtension `json:"responseObject,omitempty"` ResponseObject *runtime.Unknown `json:"responseObject,omitempty"`
} }
// EventList is a list of audit Events. // EventList is a list of audit Events.
...@@ -192,4 +219,6 @@ type ObjectReference struct { ...@@ -192,4 +219,6 @@ type ObjectReference struct {
APIVersion string `json:"apiVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty"`
// +optional // +optional
ResourceVersion string `json:"resourceVersion,omitempty"` ResourceVersion string `json:"resourceVersion,omitempty"`
// +optional
Subresource string `json:"subresource,omitempty"`
} }
...@@ -60,6 +60,7 @@ func autoConvert_v1alpha1_Event_To_audit_Event(in *Event, out *audit.Event, s co ...@@ -60,6 +60,7 @@ func autoConvert_v1alpha1_Event_To_audit_Event(in *Event, out *audit.Event, s co
out.Level = audit.Level(in.Level) out.Level = audit.Level(in.Level)
out.Timestamp = in.Timestamp out.Timestamp = in.Timestamp
out.AuditID = types.UID(in.AuditID) out.AuditID = types.UID(in.AuditID)
out.Stage = audit.Stage(in.Stage)
out.RequestURI = in.RequestURI out.RequestURI = in.RequestURI
out.Verb = in.Verb out.Verb = in.Verb
// TODO: Inefficient conversion - can we improve it? // TODO: Inefficient conversion - can we improve it?
...@@ -70,14 +71,8 @@ func autoConvert_v1alpha1_Event_To_audit_Event(in *Event, out *audit.Event, s co ...@@ -70,14 +71,8 @@ func autoConvert_v1alpha1_Event_To_audit_Event(in *Event, out *audit.Event, s co
out.SourceIPs = *(*[]string)(unsafe.Pointer(&in.SourceIPs)) out.SourceIPs = *(*[]string)(unsafe.Pointer(&in.SourceIPs))
out.ObjectRef = (*audit.ObjectReference)(unsafe.Pointer(in.ObjectRef)) out.ObjectRef = (*audit.ObjectReference)(unsafe.Pointer(in.ObjectRef))
out.ResponseStatus = (*v1.Status)(unsafe.Pointer(in.ResponseStatus)) out.ResponseStatus = (*v1.Status)(unsafe.Pointer(in.ResponseStatus))
// TODO: Inefficient conversion - can we improve it? out.RequestObject = (*runtime.Unknown)(unsafe.Pointer(in.RequestObject))
if err := s.Convert(&in.RequestObject, &out.RequestObject, 0); err != nil { out.ResponseObject = (*runtime.Unknown)(unsafe.Pointer(in.ResponseObject))
return err
}
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.ResponseObject, &out.ResponseObject, 0); err != nil {
return err
}
return nil return nil
} }
...@@ -91,6 +86,7 @@ func autoConvert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s co ...@@ -91,6 +86,7 @@ func autoConvert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s co
out.Level = Level(in.Level) out.Level = Level(in.Level)
out.Timestamp = in.Timestamp out.Timestamp = in.Timestamp
out.AuditID = types.UID(in.AuditID) out.AuditID = types.UID(in.AuditID)
out.Stage = Stage(in.Stage)
out.RequestURI = in.RequestURI out.RequestURI = in.RequestURI
out.Verb = in.Verb out.Verb = in.Verb
// TODO: Inefficient conversion - can we improve it? // TODO: Inefficient conversion - can we improve it?
...@@ -101,14 +97,8 @@ func autoConvert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s co ...@@ -101,14 +97,8 @@ func autoConvert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s co
out.SourceIPs = *(*[]string)(unsafe.Pointer(&in.SourceIPs)) out.SourceIPs = *(*[]string)(unsafe.Pointer(&in.SourceIPs))
out.ObjectRef = (*ObjectReference)(unsafe.Pointer(in.ObjectRef)) out.ObjectRef = (*ObjectReference)(unsafe.Pointer(in.ObjectRef))
out.ResponseStatus = (*v1.Status)(unsafe.Pointer(in.ResponseStatus)) out.ResponseStatus = (*v1.Status)(unsafe.Pointer(in.ResponseStatus))
// TODO: Inefficient conversion - can we improve it? out.RequestObject = (*runtime.Unknown)(unsafe.Pointer(in.RequestObject))
if err := s.Convert(&in.RequestObject, &out.RequestObject, 0); err != nil { out.ResponseObject = (*runtime.Unknown)(unsafe.Pointer(in.ResponseObject))
return err
}
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.ResponseObject, &out.ResponseObject, 0); err != nil {
return err
}
return nil return nil
} }
...@@ -119,17 +109,7 @@ func Convert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s conver ...@@ -119,17 +109,7 @@ func Convert_audit_Event_To_v1alpha1_Event(in *audit.Event, out *Event, s conver
func autoConvert_v1alpha1_EventList_To_audit_EventList(in *EventList, out *audit.EventList, s conversion.Scope) error { func autoConvert_v1alpha1_EventList_To_audit_EventList(in *EventList, out *audit.EventList, s conversion.Scope) error {
out.ListMeta = in.ListMeta out.ListMeta = in.ListMeta
if in.Items != nil { out.Items = *(*[]audit.Event)(unsafe.Pointer(&in.Items))
in, out := &in.Items, &out.Items
*out = make([]audit.Event, len(*in))
for i := range *in {
if err := Convert_v1alpha1_Event_To_audit_Event(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil return nil
} }
...@@ -140,16 +120,10 @@ func Convert_v1alpha1_EventList_To_audit_EventList(in *EventList, out *audit.Eve ...@@ -140,16 +120,10 @@ func Convert_v1alpha1_EventList_To_audit_EventList(in *EventList, out *audit.Eve
func autoConvert_audit_EventList_To_v1alpha1_EventList(in *audit.EventList, out *EventList, s conversion.Scope) error { func autoConvert_audit_EventList_To_v1alpha1_EventList(in *audit.EventList, out *EventList, s conversion.Scope) error {
out.ListMeta = in.ListMeta out.ListMeta = in.ListMeta
if in.Items != nil { 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_v1alpha1_Event(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = make([]Event, 0) out.Items = make([]Event, 0)
} else {
out.Items = *(*[]Event)(unsafe.Pointer(&in.Items))
} }
return nil return nil
} }
...@@ -188,6 +162,7 @@ func autoConvert_v1alpha1_ObjectReference_To_audit_ObjectReference(in *ObjectRef ...@@ -188,6 +162,7 @@ func autoConvert_v1alpha1_ObjectReference_To_audit_ObjectReference(in *ObjectRef
out.UID = types.UID(in.UID) out.UID = types.UID(in.UID)
out.APIVersion = in.APIVersion out.APIVersion = in.APIVersion
out.ResourceVersion = in.ResourceVersion out.ResourceVersion = in.ResourceVersion
out.Subresource = in.Subresource
return nil return nil
} }
...@@ -203,6 +178,7 @@ func autoConvert_audit_ObjectReference_To_v1alpha1_ObjectReference(in *audit.Obj ...@@ -203,6 +178,7 @@ func autoConvert_audit_ObjectReference_To_v1alpha1_ObjectReference(in *audit.Obj
out.UID = types.UID(in.UID) out.UID = types.UID(in.UID)
out.APIVersion = in.APIVersion out.APIVersion = in.APIVersion
out.ResourceVersion = in.ResourceVersion out.ResourceVersion = in.ResourceVersion
out.Subresource = in.Subresource
return nil return nil
} }
......
...@@ -89,15 +89,21 @@ func DeepCopy_v1alpha1_Event(in interface{}, out interface{}, c *conversion.Clon ...@@ -89,15 +89,21 @@ func DeepCopy_v1alpha1_Event(in interface{}, out interface{}, c *conversion.Clon
*out = newVal.(*v1.Status) *out = newVal.(*v1.Status)
} }
} }
if newVal, err := c.DeepCopy(&in.RequestObject); err != nil { if in.RequestObject != nil {
return err in, out := &in.RequestObject, &out.RequestObject
} else { if newVal, err := c.DeepCopy(*in); err != nil {
out.RequestObject = *newVal.(*runtime.RawExtension) return err
} else {
*out = newVal.(*runtime.Unknown)
}
} }
if newVal, err := c.DeepCopy(&in.ResponseObject); err != nil { if in.ResponseObject != nil {
return err in, out := &in.ResponseObject, &out.ResponseObject
} else { if newVal, err := c.DeepCopy(*in); err != nil {
out.ResponseObject = *newVal.(*runtime.RawExtension) return err
} else {
*out = newVal.(*runtime.Unknown)
}
} }
return nil return nil
} }
......
...@@ -89,15 +89,21 @@ func DeepCopy_audit_Event(in interface{}, out interface{}, c *conversion.Cloner) ...@@ -89,15 +89,21 @@ func DeepCopy_audit_Event(in interface{}, out interface{}, c *conversion.Cloner)
*out = newVal.(*v1.Status) *out = newVal.(*v1.Status)
} }
} }
if newVal, err := c.DeepCopy(&in.RequestObject); err != nil { if in.RequestObject != nil {
return err in, out := &in.RequestObject, &out.RequestObject
} else { if newVal, err := c.DeepCopy(*in); err != nil {
out.RequestObject = *newVal.(*runtime.Unknown) return err
} else {
*out = newVal.(*runtime.Unknown)
}
} }
if newVal, err := c.DeepCopy(&in.ResponseObject); err != nil { if in.ResponseObject != nil {
return err in, out := &in.ResponseObject, &out.ResponseObject
} else { if newVal, err := c.DeepCopy(*in); err != nil {
out.ResponseObject = *newVal.(*runtime.Unknown) return err
} else {
*out = newVal.(*runtime.Unknown)
}
} }
return nil return nil
} }
......
...@@ -40,10 +40,7 @@ import ( ...@@ -40,10 +40,7 @@ import (
authenticationv1 "k8s.io/client-go/pkg/apis/authentication/v1" authenticationv1 "k8s.io/client-go/pkg/apis/authentication/v1"
) )
const ( // NewEventFromRequest generates an audit event for the request.
AuditIDHeader = "X-Request-ID"
)
func NewEventFromRequest(req *http.Request, policy *auditinternal.Policy, attribs authorizer.Attributes) (*auditinternal.Event, error) { func NewEventFromRequest(req *http.Request, policy *auditinternal.Policy, attribs authorizer.Attributes) (*auditinternal.Event, error) {
ev := &auditinternal.Event{ ev := &auditinternal.Event{
Timestamp: metav1.NewTime(time.Now()), Timestamp: metav1.NewTime(time.Now()),
...@@ -61,7 +58,7 @@ func NewEventFromRequest(req *http.Request, policy *auditinternal.Policy, attrib ...@@ -61,7 +58,7 @@ func NewEventFromRequest(req *http.Request, policy *auditinternal.Policy, attrib
// prefer the id from the headers. If not available, create a new one. // prefer the id from the headers. If not available, create a new one.
// TODO(audit): do we want to forbid the header for non-front-proxy users? // TODO(audit): do we want to forbid the header for non-front-proxy users?
ids := req.Header[AuditIDHeader] ids := req.Header[auditinternal.HeaderAuditID]
if len(ids) > 0 { if len(ids) > 0 {
ev.AuditID = types.UID(ids[0]) ev.AuditID = types.UID(ids[0])
} else { } else {
...@@ -157,7 +154,7 @@ func LogRequestPatch(ae *audit.Event, patch []byte) { ...@@ -157,7 +154,7 @@ func LogRequestPatch(ae *audit.Event, patch []byte) {
return return
} }
ae.RequestObject = runtime.Unknown{ ae.RequestObject = &runtime.Unknown{
Raw: patch, Raw: patch,
ContentType: runtime.ContentTypeJSON, ContentType: runtime.ContentTypeJSON,
} }
...@@ -182,21 +179,21 @@ func LogResponseObject(ae *audit.Event, obj runtime.Object, gv schema.GroupVersi ...@@ -182,21 +179,21 @@ func LogResponseObject(ae *audit.Event, obj runtime.Object, gv schema.GroupVersi
} }
} }
func encodeObject(obj runtime.Object, gv schema.GroupVersion, serializer runtime.NegotiatedSerializer) (runtime.Unknown, error) { func encodeObject(obj runtime.Object, gv schema.GroupVersion, serializer runtime.NegotiatedSerializer) (*runtime.Unknown, error) {
supported := serializer.SupportedMediaTypes() supported := serializer.SupportedMediaTypes()
for i := range supported { for i := range supported {
if supported[i].MediaType == "application/json" { if supported[i].MediaType == "application/json" {
enc := serializer.EncoderForVersion(supported[i].Serializer, gv) enc := serializer.EncoderForVersion(supported[i].Serializer, gv)
var buf bytes.Buffer var buf bytes.Buffer
if err := enc.Encode(obj, &buf); err != nil { if err := enc.Encode(obj, &buf); err != nil {
return runtime.Unknown{}, fmt.Errorf("encoding failed: %v", err) return nil, fmt.Errorf("encoding failed: %v", err)
} }
return runtime.Unknown{ return &runtime.Unknown{
Raw: buf.Bytes(), Raw: buf.Bytes(),
ContentType: runtime.ContentTypeJSON, ContentType: runtime.ContentTypeJSON,
}, nil }, nil
} }
} }
return runtime.Unknown{}, fmt.Errorf("no json encoder found") return nil, fmt.Errorf("no json encoder found")
} }
...@@ -65,8 +65,22 @@ func TestAudit(t *testing.T) { ...@@ -65,8 +65,22 @@ func TestAudit(t *testing.T) {
simpleCPrimeJSON, _ := runtime.Encode(testCodec, simpleCPrime) simpleCPrimeJSON, _ := runtime.Encode(testCodec, simpleCPrime)
// event checks // event checks
noRequestBody := func(i int) eventCheck {
return func(events []*auditinternal.Event) error {
if events[i].RequestObject == nil {
return nil
}
return fmt.Errorf("expected RequestBody to be nil, got non-nill '%s'", events[i].RequestObject.Raw)
}
}
requestBodyIs := func(i int, text string) eventCheck { requestBodyIs := func(i int, text string) eventCheck {
return func(events []*auditinternal.Event) error { return func(events []*auditinternal.Event) error {
if events[i].RequestObject == nil {
if text != "" {
return fmt.Errorf("expected RequestBody %q, got <nil>", text)
}
return nil
}
if string(events[i].RequestObject.Raw) != text { if string(events[i].RequestObject.Raw) != text {
return fmt.Errorf("expected RequestBody %q, got %q", text, string(events[i].RequestObject.Raw)) return fmt.Errorf("expected RequestBody %q, got %q", text, string(events[i].RequestObject.Raw))
} }
...@@ -81,12 +95,12 @@ func TestAudit(t *testing.T) { ...@@ -81,12 +95,12 @@ func TestAudit(t *testing.T) {
return nil return nil
} }
} }
responseBodyIs := func(i int, text string) eventCheck { noResponseBody := func(i int) eventCheck {
return func(events []*auditinternal.Event) error { return func(events []*auditinternal.Event) error {
if string(events[i].ResponseObject.Raw) != text { if events[i].ResponseObject == nil {
return fmt.Errorf("expected ResponseBody %q, got %q", text, string(events[i].ResponseObject.Raw)) return nil
} }
return nil return fmt.Errorf("expected ResponseBody to be nil, got non-nill '%s'", events[i].ResponseObject.Raw)
} }
} }
responseBodyMatches := func(i int, pattern string) eventCheck { responseBodyMatches := func(i int, pattern string) eventCheck {
...@@ -115,7 +129,7 @@ func TestAudit(t *testing.T) { ...@@ -115,7 +129,7 @@ func TestAudit(t *testing.T) {
200, 200,
1, 1,
[]eventCheck{ []eventCheck{
requestBodyIs(0, ""), noRequestBody(0),
responseBodyMatches(0, `{.*"name":"c".*}`), responseBodyMatches(0, `{.*"name":"c".*}`),
}, },
}, },
...@@ -132,7 +146,7 @@ func TestAudit(t *testing.T) { ...@@ -132,7 +146,7 @@ func TestAudit(t *testing.T) {
200, 200,
1, 1,
[]eventCheck{ []eventCheck{
requestBodyMatches(0, ""), noRequestBody(0),
responseBodyMatches(0, `{.*"name":"a".*"name":"b".*}`), responseBodyMatches(0, `{.*"name":"a".*"name":"b".*}`),
}, },
}, },
...@@ -158,8 +172,8 @@ func TestAudit(t *testing.T) { ...@@ -158,8 +172,8 @@ func TestAudit(t *testing.T) {
405, 405,
1, 1,
[]eventCheck{ []eventCheck{
requestBodyIs(0, ""), // the 405 is thrown long before the create handler would be executed noRequestBody(0), // the 405 is thrown long before the create handler would be executed
responseBodyIs(0, ""), // the 405 is thrown long before the create handler would be executed noResponseBody(0), // the 405 is thrown long before the create handler would be executed
}, },
}, },
{ {
...@@ -171,8 +185,8 @@ func TestAudit(t *testing.T) { ...@@ -171,8 +185,8 @@ func TestAudit(t *testing.T) {
200, 200,
1, 1,
[]eventCheck{ []eventCheck{
requestBodyMatches(0, ""), noRequestBody(0),
responseBodyMatches(0, ""), responseBodyMatches(0, `{.*"kind":"Status".*"status":"Success".*}`),
}, },
}, },
{ {
...@@ -185,7 +199,7 @@ func TestAudit(t *testing.T) { ...@@ -185,7 +199,7 @@ func TestAudit(t *testing.T) {
1, 1,
[]eventCheck{ []eventCheck{
requestBodyMatches(0, "DeleteOptions"), requestBodyMatches(0, "DeleteOptions"),
responseBodyMatches(0, ""), responseBodyMatches(0, `{.*"kind":"Status".*"status":"Success".*}`),
}, },
}, },
{ {
...@@ -247,8 +261,8 @@ func TestAudit(t *testing.T) { ...@@ -247,8 +261,8 @@ func TestAudit(t *testing.T) {
200, 200,
2, 2,
[]eventCheck{ []eventCheck{
requestBodyMatches(0, ""), noRequestBody(0),
responseBodyMatches(0, ""), noResponseBody(0),
}, },
}, },
} { } {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment