obfuscation

package
v0.0.0-...-97c5a11 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: BSD-3-Clause, MIT Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BodyObfuscator

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

BodyObfuscator can be used to obfuscate properties in JSON bodies.

func DefaultBodyObfuscator

func DefaultBodyObfuscator() BodyObfuscator

DefaultBodyObfuscator returns a default body obfuscator. This will be equivalent to calling NewBodyObfuscator with an empty rule map.

func NewBodyObfuscator

func NewBodyObfuscator(customRules map[string]Rule) BodyObfuscator

NewBodyObfuscator returns a body obfuscator. This will contain some pre-defined obfuscation rules, as well as any provided custom rules.

func (BodyObfuscator) ObfuscateBody

func (o BodyObfuscator) ObfuscateBody(body string) (string, error)

ObfuscateBody obfuscates the given body as necessary

type Capable

type Capable interface {
	// SetBodyObfuscator sets the body obfuscator to use.
	SetBodyObfuscator(bodyObfuscator BodyObfuscator)
	// SetHeaderObfuscator sets the header obfuscator to use.
	SetHeaderObfuscator(headerObfuscator HeaderObfuscator)
}

Capable indicates support for obfuscating bodies and headers.

type HeaderObfuscator

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

HeaderObfuscator can be used to obfuscate headers.

func DefaultHeaderObfuscator

func DefaultHeaderObfuscator() HeaderObfuscator

DefaultHeaderObfuscator returns a default header obfuscator. This will be equivalent to calling NewHeaderObfuscator with an empty rule map.

func NewHeaderObfuscator

func NewHeaderObfuscator(customRules map[string]Rule) HeaderObfuscator

NewHeaderObfuscator returns a header obfuscator. This will contain some pre-defined obfuscation rules, as well as any provided custom rules.

func (HeaderObfuscator) ObfuscateHeader

func (o HeaderObfuscator) ObfuscateHeader(name, value string) string

ObfuscateHeader obfuscates the value for the given header as necessary.

type Rule

type Rule func(value string) string

Rule defines how a single value is obfuscated. This can be as simple as returning a fixed mask, or as complex as necessary.

func All

func All() Rule

All returns an obfuscation rule that will replace all characters with *.

func FixedLength

func FixedLength(fixedLength int) Rule

FixedLength returns an obfuscation rule that will replace values with a fixed length string containing only *.

func KeepingEndCount

func KeepingEndCount(count int) Rule

KeepingEndCount returns an obfuscation rule that will keep a fixed number of characters at the end, then replaces all other characters with *.

func KeepingStartCount

func KeepingStartCount(count int) Rule

KeepingStartCount returns an obfuscation rule that will keep a fixed number of characters at the start, then replaces all other characters with *.

Jump to

Keyboard shortcuts

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