...

Source file src/k8s.io/component-base/logs/datapol/externaltypes.go

Documentation: k8s.io/component-base/logs/datapol

     1  /*
     2  Copyright 2020 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 datapol
    18  
    19  import (
    20  	"fmt"
    21  	"reflect"
    22  )
    23  
    24  const (
    25  	httpHeader      = "net/http.Header"
    26  	httpCookie      = "net/http.Cookie"
    27  	x509Certificate = "crypto/x509.Certificate"
    28  )
    29  
    30  // GlobalDatapolicyMapping returns the list of sensitive datatypes are embedded
    31  // in types not native to Kubernetes.
    32  func GlobalDatapolicyMapping(v interface{}) []string {
    33  	return byType(reflect.TypeOf(v))
    34  }
    35  
    36  func byType(t reflect.Type) []string {
    37  	// Use string representation of the type to prevent taking a depency on the actual type.
    38  	switch fmt.Sprintf("%s.%s", t.PkgPath(), t.Name()) {
    39  	case httpHeader:
    40  		return []string{"password", "token"}
    41  	case httpCookie:
    42  		return []string{"token"}
    43  	case x509Certificate:
    44  		return []string{"security-key"}
    45  	default:
    46  		return nil
    47  	}
    48  
    49  }
    50  

View as plain text