jsonsecurity

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MaskSymbol = "*"

Variables

This section is empty.

Functions

func ReplaceGlobals

func ReplaceGlobals(masker *Masker)

Types

type Config

type Config struct {
	MaxDepth int
	Triggers map[string]TriggerOpts
}

type MaskResult

type MaskResult struct {
	// Key masked key. (Maybe useful in future)
	Key string

	// Value masked value.
	Value interface{}
}

MaskResult represents the result of masking.

type Masker

type Masker struct {
	// contains filtered or unexported fields
}

Masker struct allows you to use a single Masker object to manipulate json masking. cfg stores the config that is applied for all masking operations executed via Mask method.

func GlobalMasker

func GlobalMasker() *Masker

func NewMasker

func NewMasker(cfg Config) (*Masker, error)

NewMasker returns a new Masker instance.

func (*Masker) Mask

func (m *Masker) Mask(data []byte) ([]byte, error)

Mask masks data given in parameters using specified config.

Example:

Data = `{"password": "qwerty123", "email": "example@example.com"}`

Using PASSWORD label for "password" and EMAIL for "email" we will reach the next result:

Output = `{"password": "*********", "email": "e******@example.com"}` TODO(Gorkovets Roman): Definitely needs rework due to multiple serialization and deserialization. Inefficient af.

type MaskerFunc

type MaskerFunc func(key string, value interface{}) (MaskResult, error)

MaskerFunc masks given key-value pair and returns MaskResult structure which defines further behavior of masking algorithm.

type MaskerLabel

type MaskerLabel string

MaskerLabel defines the way we mask the data in config.

const MaskerLabelCVV MaskerLabel = "CVV"
const MaskerLabelCardNumber MaskerLabel = "CARD_NUMBER"
const MaskerLabelEmail MaskerLabel = "EMAIL"
const MaskerLabelName MaskerLabel = "NAME"
const MaskerLabelPassword MaskerLabel = "PASSWORD"
const MaskerLabelPhoneNumber MaskerLabel = "PHONE_NUMBER"

type TriggerOpts

type TriggerOpts struct {
	CaseSensitive bool
	MaskMethod    MaskerLabel
	ShouldAppear  bool
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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