Documentation
¶
Overview ¶
Package datamasking erases selected data and composes encryption providers.
New creates a Masker. Masker.Erase replaces fields selected by EraseOptions using the default mask, a custom mask, a dynamic mask or a replacement callback. Ordered FieldRule entries control overlapping selectors. Operations work on private copies rather than mutating caller-owned payloads.
Providers and missing fields ¶
Encryption and decryption use an application-supplied Provider, which owns ciphertext format and authenticated context. The optional datamasking/kms module implements that interface with the AWS Encryption SDK; erasure needs no provider.
Config.IgnoreMissing selects warning behavior for absent selectors. Strict mode reports missing fields. Null and Undefined retain their documented semantics. Review the guide for supported input types and selector syntax.
For usage and compatibility details, see the user guide.
Index ¶
Examples ¶
Constants ¶
const DefaultMask = "*****"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EraseOptions ¶
type Masker ¶
type Masker struct {
// contains filtered or unexported fields
}
func (*Masker) Erase ¶
Example ¶
package main
import (
"context"
"fmt"
"github.com/rambow-cloud/powertools-lambda-go/datamasking"
)
func main() {
masker := datamasking.New(datamasking.Config{})
input := map[string]any{"email": "user@example.com", "order": "order-123"}
value, err := masker.Erase(context.Background(), input,
datamasking.EraseOptions{Fields: []string{"email"}})
if err != nil {
panic(err)
}
masked := value.(map[string]any)
fmt.Println(masked["email"], masked["order"])
fmt.Println(input["email"])
}
Output: ***** order-123 user@example.com
type Provider ¶
type Provider interface {
Encrypt(context.Context, string, map[string]string) (string, error)
Decrypt(context.Context, string, map[string]string) (string, error)
}
Provider owns ciphertext format, cryptography and authenticated context. Implementations must support concurrent calls and honor cancellation.
type Rule ¶
Rule uses pointers to retain explicit false and empty custom masks. Replace is an application-owned string replacement strategy, with precedence over CustomMask and DynamicMask. The optional commons/regex module provides Regexp.Replacer for ECMAScript string replacement without a core dependency.