k8s.io/apiserver@v0.31.1/pkg/audit/evaluator.go (about) 1 /* 2 Copyright 2021 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package audit 18 19 import ( 20 "k8s.io/apiserver/pkg/apis/audit" 21 "k8s.io/apiserver/pkg/authorization/authorizer" 22 ) 23 24 // RequestAuditConfig is the evaluated audit configuration that is applicable to 25 // a given request. PolicyRuleEvaluator evaluates the audit policy against the 26 // authorizer attributes and returns a RequestAuditConfig that applies to the request. 27 type RequestAuditConfig struct { 28 // Level at which the request is being audited at 29 Level audit.Level 30 31 // OmitStages is the stages that need to be omitted from being audited. 32 OmitStages []audit.Stage 33 34 // OmitManagedFields indicates whether to omit the managed fields of the request 35 // and response bodies from being written to the API audit log. 36 OmitManagedFields bool 37 } 38 39 // PolicyRuleEvaluator exposes methods for evaluating the policy rules. 40 type PolicyRuleEvaluator interface { 41 // EvaluatePolicyRule evaluates the audit policy of the apiserver against 42 // the given authorizer attributes and returns the audit configuration that 43 // is applicable to the given equest. 44 EvaluatePolicyRule(authorizer.Attributes) RequestAuditConfig 45 }