utils

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NUMBER_CHARSET = "123456789" // remove 0 to make sure it is not confused with O
	START_CHARSET  = "ghijklmnopqrstuvwxyz"
	CHARSET        = "0123456789abcdefghijklmnopqrstuvwxyz"
	HEX_CHARSET    = "0123456789abcdef"
)

Variables

This section is empty.

Functions

func AddCacheBuster

func AddCacheBuster(request []byte, cacheBuster string) []byte

func AddOrReplaceHeader

func AddOrReplaceHeader(request []byte, header string, value string) []byte

func AppendToHeader

func AppendToHeader(request []byte, header, value string) []byte

func AppendToQuery

func AppendToQuery(request []byte, suffix string) []byte

func BasicEncodeParam

func BasicEncodeParam(payload string) string

func EnvTruthy

func EnvTruthy(name string) bool

EnvTruthy reads os.Getenv(name) through Truthy. Empty / unset / unrecognized returns false.

func EscapeJSONString

func EscapeJSONString(input string) string

func GenerateCanary

func GenerateCanary() string

func GetBodyStart

func GetBodyStart(response []byte) int

func GetCertificateFromHostname

func GetCertificateFromHostname(host string) []string

func GetExtensionOfPath

func GetExtensionOfPath(url string) string

func GetFileByName

func GetFileByName(filename string) (string, error)

GetFileByName retrieves the content of a file from the embedded assets by its name.

func GetHeader

func GetHeader(request []byte, header string) string

func GetHeaderOffsets

func GetHeaderOffsets(request []byte, header string) []int

GetHeaderOffsets return the offsets of the headers in the request/response

the header name is case-insensitive

func GetPathFromRequest

func GetPathFromRequest(request []byte) string

GetPathFromRequest returns the path from a request INCLUDE QUERY ALSO

func IsBlank

func IsBlank(value string) bool

func IsMediaAndJSURL

func IsMediaAndJSURL(url string) bool

IsMediaAndJSURL checks if a URL is a media or JS file return true if it is a media or JS file

func IsMediaURL

func IsMediaURL(url string) bool

func IsNumeric

func IsNumeric(s string) bool

func IsURL

func IsURL(input string) bool

IsURL tests a string to determine if it is a well-structured url or not.

func MD5Enc

func MD5Enc(input string) string

func MightBeFunction

func MightBeFunction(value string) bool

func MightBeIdentifier

func MightBeIdentifier(value string) bool

MightBeIdentifier checks if the string is a possible identifier based on specific allowed characters

func MightBeOrderBy

func MightBeOrderBy(name, value string) bool

MightBeOrderBy checks if the given name or value suggests an 'order by' or 'sort' operation

func RandomFromChoices

func RandomFromChoices(n int, choices string) string

RandomFromChoices 从choices里面随机获取

func RandomNumber

func RandomNumber(length int) string

RandomNumber returns a random number with the specified length

func RandomNumberInRange

func RandomNumberInRange(from, to int) string

func RandomString

func RandomString(length int) string

func RandomUpper

func RandomUpper(s string) string

func Replace

func Replace(request []byte, find []byte, replace []byte) []byte

func ReplaceFirst

func ReplaceFirst(request []byte, find []byte, replace []byte) []byte

func SetHeader

func SetHeader(request []byte, header string, value string) []byte

func Sha1

func Sha1(input string) string

func SplitPathRecursive

func SplitPathRecursive(input string) []string

func StringSliceContains

func StringSliceContains(slice []string, item string) bool

StringSliceContains checks if a string slice contains a string.

func StructToJsonString

func StructToJsonString(item interface{}) string

StructToJsonString renders item as indented JSON. Values that cannot be marshaled (channels, functions, cyclic refs) yield "" rather than panicking, since this is a best-effort display helper.

func Truthy

func Truthy(s string) bool

Truthy reports whether s reads as a positive boolean flag — case-insensitive "1", "true", "yes", "on". Used for env-var and CLI-token parsing where the no/false form is conventionally absence.

func UnwrapError

func UnwrapError(err error) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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