utils

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: LGPL-3.0 Imports: 21 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyURL = url.URL{}

Functions

func AddQueryValues

func AddQueryValues(s string, qs url.Values) (string, error)

AddQueryValues adds queryValue to url

func CalcSHA256

func CalcSHA256(buf []byte) []byte

CalcSHA256 computes checksum of sha256 from byte array

func CalcSHA256Hex

func CalcSHA256Hex(buf []byte) (hexStr string)

CalcSHA256Hex computes checksum of sha256 hash and encode it to hex

func CheckObjectName added in v1.6.0

func CheckObjectName(objectName string) bool

CheckObjectName This code block checks for unsupported or potentially risky formats in object names. The checks are essential for ensuring the security and compatibility of the object names within the system. 1. ".." in object names: Checked to prevent path traversal attacks which might access directories outside the intended scope. 2. Object name being "/": The root directory should not be used as an object name due to potential security risks and ambiguity. 3. "\\" in object names: Backslashes are checked because they are often not supported in UNIX-like file systems and can cause issues in path parsing. 4. SQL Injection patterns in object names: Ensures that the object name does not contain patterns that could be used for SQL injection attacks, maintaining the integrity of the database.

func CloseResponse

func CloseResponse(resp *http.Response)

CloseResponse closes the response body

func DecodeURIComponent

func DecodeURIComponent(s string) (string, error)

func EncodePath

func EncodePath(pathName string) string

EncodePath encodes the strings from UTF-8 byte representations to HTML hex escape sequences

func GetContentLength

func GetContentLength(reader io.Reader) (int64, error)

GetContentLength returns the size of reader

func GetECPieceSize added in v0.2.3

func GetECPieceSize(payloadSize uint64, segmentIdx uint32, maxSegmentSize uint64, dataChunkNum uint32) int64

func GetEndpointURL

func GetEndpointURL(endpoint string, secure bool) (*url.URL, error)

GetEndpointURL - constructs a new endpoint.

func GetSegmentCount added in v0.2.3

func GetSegmentCount(payloadSize uint64, maxSegmentSize uint64) uint32

func GetSegmentSize added in v0.2.3

func GetSegmentSize(payloadSize uint64, segmentIdx uint32, maxSegmentSize uint64) int64

func IsDomainNameValid

func IsDomainNameValid(hostName string) bool

IsDomainNameValid validates if input string is a valid domain name.

func IsIPValid

func IsIPValid(ip string) bool

func IsSQLInjection added in v1.6.0

func IsSQLInjection(input string) bool

func IsValidObjectPrefix

func IsValidObjectPrefix(prefix string) bool

IsValidObjectPrefix checks if the given object prefix is valid: - does not have invalid path segments - is a valid UTF-8 string - does not contain double slashes "//"

func NewPrincipalWithAccount

func NewPrincipalWithAccount(principalAddr sdk.AccAddress) (types.Principal, error)

NewPrincipalWithAccount return the marshaled Principal string which indicates the account

func NewPrincipalWithGroupId

func NewPrincipalWithGroupId(groupId uint64) (types.Principal, error)

NewPrincipalWithGroupId return the marshaled Principal string which indicates the group

func NewStatement

func NewStatement(actions []permTypes.ActionType, effect permTypes.Effect,
	resource []string, opts types.NewStatementOptions,
) permTypes.Statement

NewStatement return the statement of permission module

func ParseRange added in v0.2.3

func ParseRange(rangeStr string) (bool, int64, int64)

func ReadFull added in v0.2.3

func ReadFull(r io.Reader, buf []byte) (n int, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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