policy

package
v1.14.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string
const (
	Block          Action = "block"
	AllowButWarn   Action = "allow_but_warn"
	AllowButRedact Action = "allow_but_redact"
	Allow          Action = "allow"
)

type Config

type Config struct {
	Rules map[Rule]Action `json:"rules"`
}

type CustomConfig

type CustomConfig struct {
	CustomRules []*CustomRule `json:"rules"`
}

type CustomPolicyDetector

type CustomPolicyDetector interface {
	Detect(input []string, requirements []string) (bool, error)
}

type CustomRule

type CustomRule struct {
	Definition string `json:"definition"`
	Action     Action `json:"action"`
}

type Policy

type Policy struct {
	Id           string        `json:"id"`
	Name         string        `json:"name"`
	CreatedAt    int64         `json:"createdAt"`
	UpdatedAt    int64         `json:"updatedAt"`
	Tags         []string      `json:"tags"`
	Config       *Config       `json:"config"`
	RegexConfig  *RegexConfig  `json:"regexConfig"`
	CustomConfig *CustomConfig `json:"customConfig"`
}

func (*Policy) Filter

func (p *Policy) Filter(client http.Client, input any, scanner Scanner, cd CustomPolicyDetector, log *zap.Logger) error

func (*Policy) Validate

func (p *Policy) Validate() error

type RegexConfig

type RegexConfig struct {
	RegularExpressionRules []*RegularExpressionRule `json:"rules"`
}

type RegularExpressionRule

type RegularExpressionRule struct {
	Definition string `json:"definition"`
	Action     Action `json:"action"`
}

type Request

type Request struct {
	Contents []string `json:"contents"`
	Policy   *Policy  `json:"policy"`
}

type Response

type Response struct {
	Contents       []string        `json:"contents"`
	Action         Action          `json:"action"`
	Warnings       map[string]bool `json:"warnings"`
	BlockedReasons map[string]bool `json:"blockedReasons"`
}

type Rule

type Rule string
const (
	Address                             Rule = "address"
	Age                                 Rule = "age"
	All                                 Rule = "all"
	AwsAccessKey                        Rule = "aws_access_key"
	AwsSecretKey                        Rule = "aws_secret_key"
	BankAccountNumber                   Rule = "bank_account_number"
	BankRouting                         Rule = "bank_routing"
	CaHealthNumber                      Rule = "ca_health_number"
	CaSocialInsuranceNumber             Rule = "ca_social_insurance_number"
	CreditDebitCvv                      Rule = "credit_debit_cvv"
	CreditDebitExpiry                   Rule = "credit_debit_expiry"
	CreditDebitNumber                   Rule = "credit_debit_number"
	DateTime                            Rule = "date_time"
	DriverId                            Rule = "driver_id"
	Email                               Rule = "email"
	InAadhaar                           Rule = "in_aadhaar"
	InNrega                             Rule = "in_nrega"
	InPermanentAccountNumber            Rule = "in_permanent_account_number"
	InVoterNumber                       Rule = "in_voter_number"
	InternationalBankAccountNumber      Rule = "international_bank_account_number"
	IpAddress                           Rule = "ip_address"
	LicensePlate                        Rule = "license_plate"
	MacAddress                          Rule = "mac_address"
	Name                                Rule = "name"
	PassportNumber                      Rule = "passport_number"
	Password                            Rule = "password"
	Phone                               Rule = "phone"
	Pin                                 Rule = "pin"
	Ssn                                 Rule = "ssn"
	SwiftCode                           Rule = "swift_code"
	UkNationalHealthServiceNumber       Rule = "uk_national_health_service_number"
	UkNationalInsuranceNumber           Rule = "uk_national_insurance_number"
	UkUniqueTaxpayerReferenceNumber     Rule = "uk_unique_taxpayer_reference_number"
	Url                                 Rule = "url"
	UsIndividualTaxIdentificationNumber Rule = "us_individual_tax_identification_number"
	Username                            Rule = "username"
	VehicleIdentificationNumber         Rule = "vehicle_identification_number"
)

type ScanResult

type ScanResult struct {
	Action                   Action
	ActionLock               sync.RWMutex
	BlockedEntities          []Rule
	WarnedEntities           []Rule
	BlockedRegexDefinitions  []string
	WarnedRegexDefinitions   []string
	BlockedCustomDefinitions []string
	Updated                  []string
}

type Scanner

type Scanner interface {
	Scan(input []string) (*pii.Result, error)
}

type UpdatePolicy

type UpdatePolicy struct {
	Name         string        `json:"name"`
	UpdatedAt    int64         `json:"updatedAt"`
	Tags         []string      `json:"tags"`
	Config       *Config       `json:"config"`
	RegexConfig  *RegexConfig  `json:"regexConfig"`
	CustomConfig *CustomConfig `json:"customConfig"`
}

func (*UpdatePolicy) Validate

func (p *UpdatePolicy) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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