anon

package
v0.0.0-...-12b6520 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package anon contains functions and data structures related to the map of anonymized fields. In the elasticsearch index and requests context, this map is used to guarantee that we do not expose sensitive information but keep the same experimental behavior. For instance, an anonymized request using the anonmap of an index anonymization must must hit the same set of shards as the original version.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Anonymizer

type Anonymizer struct {
	FMap FieldsMap
	FRE  FieldsRegexp
}

Anonymizer anonymizes arbitrary object fields based on regular expressions.

func (*Anonymizer) Anonymize

func (a *Anonymizer) Anonymize(objSlice ...map[string]interface{})

Anonymize anonymizes the passed-in objects updating its fields.

func (*Anonymizer) WriteFieldsMapToFile

func (a *Anonymizer) WriteFieldsMapToFile(path string) error

WriteFieldsMapToFile writes a JSON version of the anonymized fields map to the specified file path.

type FieldsMap

type FieldsMap map[string]map[string]string

FieldsMap maps fields to their associated anonymized values.

func MustReadFieldsMap

func MustReadFieldsMap(path string) FieldsMap

MustReadFieldsMap it is like ReadFieldsMapFromFile, but panic in case of errors.

func ReadFieldsMapFromFile

func ReadFieldsMapFromFile(path string) (FieldsMap, error)

ReadFieldsMapFromFile loads the map of anonymized fields from a file path.

func (FieldsMap) Anonymize

func (fields FieldsMap) Anonymize(fieldName, key string) string

Anonymize returns an anonymous version of the field key and updates the backing map, making sure that sucessive calls of this method return the same anonymous value.

func (FieldsMap) WriteJSONToFile

func (fields FieldsMap) WriteJSONToFile(path string) error

WriteJSONToFile writes a JSON version of the anonymized fields map to the specified file path.

type FieldsRegexp

type FieldsRegexp map[string]*regexp.Regexp

FieldsRegexp keeps the regular expressions to be applied while anonymizing fields.

func FieldsRegexpFromStringSlice

func FieldsRegexpFromStringSlice(fSlice []string) (FieldsRegexp, error)

FieldsRegexpFromStringSlice creates a new, populated FieldRegexp from a string slice. The field name-regexp separator is "::".

func MustParseFieldsRE

func MustParseFieldsRE(fSlice []string) FieldsRegexp

MustParseFieldsRE is like FieldsRegexpFromStringSlice but panics in case of errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL