safe

package
v0.0.0-...-16952c6 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package safe provides types and methods for safe stored data.

Index

Constants

View Source
const MaxStringLength = 8192

Variables

View Source
var ErrCharsDetected = errors.New("string is unsafe due to prohibited chars")

ErrCharsDetected means disallowed chars were found.

View Source
var ErrHTMLDetected = errors.New("string is unsafe due to detected html")

ErrHTMLDetected means html was found.

View Source
var ErrSQLDetected = errors.New("string is unsafe due to detected sql")

ErrSQLDetected means sql was found.

View Source
var ErrStringLength = errors.New("string is either zero-len or exceeds limit")

ErrStringLength means the string is zero-len or exceeds limit.

View Source
var ErrWSDetected = errors.New("string is unsafe due to detected whitespace")

ErrWSDetected means disallowed whitespace was found.

Functions

func StringIs

func StringIs(s string) error

StringIs looks for disallowed patterns and returns an appropriate error.

Types

type Password

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

Password is a stringy type intended for sanity storage.

func NewPassword

func NewPassword(raw string) (*Password, error)

NewPassword makes sure a string is suitable as a password. Since validation is delegated to a kdf verification function, this is just a length check.

func TrustedPassword

func TrustedPassword(trusted string) Password

TrustedPassword assumes you have already validated the input string.

func (Password) IsEmpty

func (p Password) IsEmpty() bool

func (Password) MarshalJSON

func (p Password) MarshalJSON() ([]byte, error)

func (*Password) Scan

func (p *Password) Scan(src interface{}) error

func (Password) String

func (p Password) String() string

func (*Password) UnmarshalJSON

func (p *Password) UnmarshalJSON(bs []byte) error

func (Password) Value

func (p Password) Value() (driver.Value, error)

type VarChar

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

VarChar is a stringy type intended for sanity storage.

func NewVarChar

func NewVarChar(raw string) (*VarChar, error)

NewVarChar makes sure a string is safe for db storage.

func TrustedVarChar

func TrustedVarChar(trusted string) VarChar

TrustedVarChar assumes you have already validated the input string.

func (VarChar) IsEmpty

func (v VarChar) IsEmpty() bool

func (VarChar) MarshalJSON

func (v VarChar) MarshalJSON() ([]byte, error)

func (*VarChar) Scan

func (v *VarChar) Scan(src interface{}) error

func (VarChar) String

func (v VarChar) String() string

func (*VarChar) UnmarshalJSON

func (v *VarChar) UnmarshalJSON(bs []byte) error

func (VarChar) Value

func (v VarChar) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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