redact

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package redact provides interfaces and methods to help implement redaction.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ServiceSkip is used to skip the redaction in grpc service in the server
	//
	// optional bool service_skip = 54123;
	E_ServiceSkip = &file_redact_v3_redact_proto_extTypes[1]
	// InternalService will make this service private and client will not be
	// able to receive any response for any of it's method, (unless skipped
	// explicitly) and will get PermissionDenied(7) error by default, to set
	// any other code set it in InternalServiceCode, it should be one of the
	// defined GRPC status code, and InternalServiceErrMessage for error
	// message, in which, one can use `%service%` or `%method%` tags to include
	// corresponding service name or method name, respectively.
	//
	// optional bool internal_service = 54124;
	E_InternalService = &file_redact_v3_redact_proto_extTypes[2]
	// optional uint32 internal_service_code = 54125;
	E_InternalServiceCode = &file_redact_v3_redact_proto_extTypes[3]
	// optional string internal_service_err_message = 54126;
	E_InternalServiceErrMessage = &file_redact_v3_redact_proto_extTypes[4]
)

Extension fields to descriptorpb.ServiceOptions.

View Source
var (
	// MethodSkip is used to skip the redactions for this method in the grpc server
	//
	// optional bool method_skip = 54123;
	E_MethodSkip = &file_redact_v3_redact_proto_extTypes[5]
	// InternalMethod, InternalMethodCode and InternalMethodErrMessage works same
	// as that of service level options: InternalService, InternalServiceCode and
	// InternalServiceErrMessage, but at Method level. All the validations and
	// functionalities are same for both. But the method level options will be used
	// whenever both are specified.
	//
	// optional bool internal_method = 54124;
	E_InternalMethod = &file_redact_v3_redact_proto_extTypes[6]
	// optional uint32 internal_method_code = 54125;
	E_InternalMethodCode = &file_redact_v3_redact_proto_extTypes[7]
	// optional string internal_method_err_message = 54126;
	E_InternalMethodErrMessage = &file_redact_v3_redact_proto_extTypes[8]
)

Extension fields to descriptorpb.MethodOptions.

View Source
var (
	// Nil will redact message to nil (can be override by field level, `empty` option)
	//
	// optional bool nil = 54123;
	E_Nil = &file_redact_v3_redact_proto_extTypes[9]
	// Empty will redact message to it's empty object
	//
	// optional bool empty = 54124;
	E_Empty = &file_redact_v3_redact_proto_extTypes[10]
	// Ignored skips generation of any redaction for this message.
	//
	// optional bool ignored = 54125;
	E_Ignored = &file_redact_v3_redact_proto_extTypes[11]
)

Extension fields to descriptorpb.MessageOptions.

View Source
var (
	// FileSkip is used to skip generation of any redaction for proto file
	//
	// optional bool file_skip = 90102;
	E_FileSkip = &file_redact_v3_redact_proto_extTypes[0]
)

Extension fields to descriptorpb.FileOptions.

View Source
var (
	// Redact: it redact the field with predefined defaults:
	//   - `0` for any number type
	//   - `"REDACTED"` for string type
	//   - `nil` for byte type
	//   - `0th value` for enum type
	//   - `nil` map for map type
	//   - `nil` for repeated field type
	//   - for message type, redaction is applied inside the message type
	//
	// bool redact = 54123;
	// Custom: specify the different values to be used for redaction on this field. By
	// default, if Custom value is not defined Redact should be true to apply redaction.
	// And if Custom value is to be assigned, one can skip the Redact field.
	//
	// optional redact.v3.FieldRules value = 54123;
	E_Value = &file_redact_v3_redact_proto_extTypes[12]
)

Extension fields to descriptorpb.FieldOptions.

View Source
var Falsy = Wrapper(func(_ context.Context) bool {
	return false
})

Falsy is the nil implementation for Bypass

View Source
var File_redact_v3_redact_proto protoreflect.FileDescriptor

Functions

func Apply

func Apply(in interface{})

Apply will apply redaction on the input, if it implements Redactor. It will do nothing if the object does not implement the interface.

Types

type Bypass

type Bypass interface {
	CheckInternal(ctx context.Context) bool
}

Bypass provides a way to bypass the internal marked methods to be ran through clients

type ElementRules

type ElementRules struct {

	// Empty specifies that after redaction the list/map will be empty
	Empty bool `protobuf:"varint,1,opt,name=empty,proto3" json:"empty,omitempty"`
	// Nested specifies that default rules is to be applied `recursively` on each
	// item of map/list
	Nested bool `protobuf:"varint,2,opt,name=nested,proto3" json:"nested,omitempty"`
	// Item specifies that some custom redaction rules to be applied `recursively`
	// on each item in map/list.
	Item *FieldRules `protobuf:"bytes,3,opt,name=item,proto3" json:"item,omitempty"`
	// contains filtered or unexported fields
}

ElementRules describe the constraints applied to `repeated` or `map` values

func (*ElementRules) Descriptor deprecated

func (*ElementRules) Descriptor() ([]byte, []int)

Deprecated: Use ElementRules.ProtoReflect.Descriptor instead.

func (*ElementRules) GetEmpty

func (x *ElementRules) GetEmpty() bool

func (*ElementRules) GetItem

func (x *ElementRules) GetItem() *FieldRules

func (*ElementRules) GetNested

func (x *ElementRules) GetNested() bool

func (*ElementRules) ProtoMessage

func (*ElementRules) ProtoMessage()

func (*ElementRules) ProtoReflect

func (x *ElementRules) ProtoReflect() protoreflect.Message

func (*ElementRules) Reset

func (x *ElementRules) Reset()

func (*ElementRules) String

func (x *ElementRules) String() string

type FieldRules

type FieldRules struct {

	// values for redacted field
	//
	// Types that are assignable to Values:
	//
	//	*FieldRules_Float
	//	*FieldRules_Double
	//	*FieldRules_Int32
	//	*FieldRules_Int64
	//	*FieldRules_Uint32
	//	*FieldRules_Uint64
	//	*FieldRules_Sint32
	//	*FieldRules_Sint64
	//	*FieldRules_Fixed32
	//	*FieldRules_Fixed64
	//	*FieldRules_Sfixed32
	//	*FieldRules_Sfixed64
	//	*FieldRules_Bool
	//	*FieldRules_String_
	//	*FieldRules_Bytes
	//	*FieldRules_Enum
	//	*FieldRules_Message
	//	*FieldRules_Element
	Values isFieldRules_Values `protobuf_oneof:"values"`
	// contains filtered or unexported fields
}

FieldRules encapsulates options to change the redacted values of any type of field. Depending on the field, the correct type value should be used.

func (*FieldRules) Descriptor deprecated

func (*FieldRules) Descriptor() ([]byte, []int)

Deprecated: Use FieldRules.ProtoReflect.Descriptor instead.

func (*FieldRules) GetBool

func (x *FieldRules) GetBool() bool

func (*FieldRules) GetBytes

func (x *FieldRules) GetBytes() []byte

func (*FieldRules) GetDouble

func (x *FieldRules) GetDouble() float64

func (*FieldRules) GetElement

func (x *FieldRules) GetElement() *ElementRules

func (*FieldRules) GetEnum

func (x *FieldRules) GetEnum() int32

func (*FieldRules) GetFixed32

func (x *FieldRules) GetFixed32() uint32

func (*FieldRules) GetFixed64

func (x *FieldRules) GetFixed64() uint64

func (*FieldRules) GetFloat

func (x *FieldRules) GetFloat() float32

func (*FieldRules) GetInt32

func (x *FieldRules) GetInt32() int32

func (*FieldRules) GetInt64

func (x *FieldRules) GetInt64() int64

func (*FieldRules) GetMessage

func (x *FieldRules) GetMessage() *MessageRules

func (*FieldRules) GetSfixed32

func (x *FieldRules) GetSfixed32() int32

func (*FieldRules) GetSfixed64

func (x *FieldRules) GetSfixed64() int64

func (*FieldRules) GetSint32

func (x *FieldRules) GetSint32() int32

func (*FieldRules) GetSint64

func (x *FieldRules) GetSint64() int64

func (*FieldRules) GetString_

func (x *FieldRules) GetString_() string

func (*FieldRules) GetUint32

func (x *FieldRules) GetUint32() uint32

func (*FieldRules) GetUint64

func (x *FieldRules) GetUint64() uint64

func (*FieldRules) GetValues

func (m *FieldRules) GetValues() isFieldRules_Values

func (*FieldRules) ProtoMessage

func (*FieldRules) ProtoMessage()

func (*FieldRules) ProtoReflect

func (x *FieldRules) ProtoReflect() protoreflect.Message

func (*FieldRules) Reset

func (x *FieldRules) Reset()

func (*FieldRules) String

func (x *FieldRules) String() string

type FieldRules_Bool

type FieldRules_Bool struct {
	Bool bool `protobuf:"varint,14,opt,name=bool,proto3,oneof"`
}

type FieldRules_Bytes

type FieldRules_Bytes struct {
	Bytes []byte `protobuf:"bytes,16,opt,name=bytes,proto3,oneof"`
}

type FieldRules_Double

type FieldRules_Double struct {
	Double float64 `protobuf:"fixed64,3,opt,name=double,proto3,oneof"`
}

type FieldRules_Element

type FieldRules_Element struct {
	// Element defines rules for repeated or map type fields
	Element *ElementRules `protobuf:"bytes,20,opt,name=element,proto3,oneof"`
}

type FieldRules_Enum

type FieldRules_Enum struct {
	Enum int32 `protobuf:"varint,17,opt,name=enum,proto3,oneof"`
}

type FieldRules_Fixed32

type FieldRules_Fixed32 struct {
	Fixed32 uint32 `protobuf:"fixed32,10,opt,name=fixed32,proto3,oneof"`
}

type FieldRules_Fixed64

type FieldRules_Fixed64 struct {
	Fixed64 uint64 `protobuf:"fixed64,11,opt,name=fixed64,proto3,oneof"`
}

type FieldRules_Float

type FieldRules_Float struct {
	// Scalar Field Types values
	Float float32 `protobuf:"fixed32,2,opt,name=float,proto3,oneof"`
}

type FieldRules_Int32

type FieldRules_Int32 struct {
	Int32 int32 `protobuf:"varint,4,opt,name=int32,proto3,oneof"`
}

type FieldRules_Int64

type FieldRules_Int64 struct {
	Int64 int64 `protobuf:"varint,5,opt,name=int64,proto3,oneof"`
}

type FieldRules_Message

type FieldRules_Message struct {
	// Message defines rules for singular message type fields only
	Message *MessageRules `protobuf:"bytes,19,opt,name=message,proto3,oneof"`
}

type FieldRules_Sfixed32

type FieldRules_Sfixed32 struct {
	Sfixed32 int32 `protobuf:"fixed32,12,opt,name=sfixed32,proto3,oneof"`
}

type FieldRules_Sfixed64

type FieldRules_Sfixed64 struct {
	Sfixed64 int64 `protobuf:"fixed64,13,opt,name=sfixed64,proto3,oneof"`
}

type FieldRules_Sint32

type FieldRules_Sint32 struct {
	Sint32 int32 `protobuf:"zigzag32,8,opt,name=sint32,proto3,oneof"`
}

type FieldRules_Sint64

type FieldRules_Sint64 struct {
	Sint64 int64 `protobuf:"zigzag64,9,opt,name=sint64,proto3,oneof"`
}

type FieldRules_String_

type FieldRules_String_ struct {
	String_ string `protobuf:"bytes,15,opt,name=string,proto3,oneof"`
}

type FieldRules_Uint32

type FieldRules_Uint32 struct {
	Uint32 uint32 `protobuf:"varint,6,opt,name=uint32,proto3,oneof"`
}

type FieldRules_Uint64

type FieldRules_Uint64 struct {
	Uint64 uint64 `protobuf:"varint,7,opt,name=uint64,proto3,oneof"`
}

type MessageRules

type MessageRules struct {

	// Skip specifies that the redaction rules of this field should not be evaluated
	Skip bool `protobuf:"varint,1,opt,name=skip,proto3" json:"skip,omitempty"`
	// Empty specifies that after redaction this field should be set to empty object
	Empty bool `protobuf:"varint,2,opt,name=empty,proto3" json:"empty,omitempty"`
	// Nil specifies that after redaction this field should be set to nil object
	Nil bool `protobuf:"varint,3,opt,name=nil,proto3" json:"nil,omitempty"`
	// Apply specifies that redaction is to be called for the message type
	Apply bool `protobuf:"varint,4,opt,name=apply,proto3" json:"apply,omitempty"`
	// contains filtered or unexported fields
}

MessageRules describe the constraints applied to embedded message for redaction. For message-type fields, rules are performed recursively.

func (*MessageRules) Descriptor deprecated

func (*MessageRules) Descriptor() ([]byte, []int)

Deprecated: Use MessageRules.ProtoReflect.Descriptor instead.

func (*MessageRules) GetApply

func (x *MessageRules) GetApply() bool

func (*MessageRules) GetEmpty

func (x *MessageRules) GetEmpty() bool

func (*MessageRules) GetNil

func (x *MessageRules) GetNil() bool

func (*MessageRules) GetSkip

func (x *MessageRules) GetSkip() bool

func (*MessageRules) ProtoMessage

func (*MessageRules) ProtoMessage()

func (*MessageRules) ProtoReflect

func (x *MessageRules) ProtoReflect() protoreflect.Message

func (*MessageRules) Reset

func (x *MessageRules) Reset()

func (*MessageRules) String

func (x *MessageRules) String() string

type Redactor

type Redactor interface {
	Redact()
}

Redactor provides the method to be used to Redact

type Wrapper

type Wrapper func(ctx context.Context) bool

Wrapper helps to implement Bypass

func (Wrapper) CheckInternal

func (w Wrapper) CheckInternal(ctx context.Context) bool

CheckInternal for Wrapper

Jump to

Keyboard shortcuts

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