github.com/blend/go-sdk@v1.20240719.1/sanitize/key_values_sanitizer.go (about)

     1  /*
     2  
     3  Copyright (c) 2024 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package sanitize
     9  
    10  // KeyValuesSanitizer is a type that can sanitize http header or query key values.
    11  //
    12  // Values are passed from `map[string][]string` typically,
    13  // hence the `key` and `values...` parameters.
    14  //
    15  // The `SanitizeValue` function should return the modified or
    16  // sanitized value for each of the input values, for a given key.
    17  type KeyValuesSanitizer interface {
    18  	SanitizeKeyValues(key string, values ...string) []string
    19  }
    20  
    21  // KeyValuesSanitizerFunc is a function implementation of ValueSanitizer.
    22  type KeyValuesSanitizerFunc func(key string, values ...string) []string
    23  
    24  // SanitizeKeyValues implements `KeyValuesSanitizer`.
    25  func (vsf KeyValuesSanitizerFunc) SanitizeKeyValues(key string, values ...string) []string {
    26  	return vsf(key, values...)
    27  }
    28  
    29  // DefaultKeyValuesSanitizerFunc is the default value sanitizer.
    30  //
    31  // For any given key's values it will simply return nil, implying that
    32  // the key was one of the banned keys and we should completely omit
    33  // the values.
    34  func DefaultKeyValuesSanitizerFunc(_ string, _ ...string) []string {
    35  	return nil
    36  }