utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareDates

func CompareDates(date1, date2 time.Time) bool

func ConvertToStringSlice

func ConvertToStringSlice(rawMsg json.RawMessage) []string

func ConvertURLToDomain

func ConvertURLToDomain(inputURL string) string

func CreateFileRequest

func CreateFileRequest(src, content, fileType string) types.FileRequest

CreateFileRequest constructs a FileRequest with content details.

func CurrentDate

func CurrentDate() time.Time

func ExtractTitle

func ExtractTitle(doc *html.Node) string

ExtractTitle retrieves the title from the parsed HTML.

func GenerateID

func GenerateID() string

func Get24HoursAgo

func Get24HoursAgo() time.Time

func GetCurrentTime

func GetCurrentTime() time.Time

func IPNetsToStrings

func IPNetsToStrings(ipnets []*net.IPNet) []string

func IPsToStrings

func IPsToStrings(ips []net.IP) []string

func IsFont

func IsFont(node *html.Node) bool

IsFont checks if a link element points to a font.

func IsLocalURL

func IsLocalURL(input string) bool

Check if the URL is local or remote. If local then return true, otherwise false.

func IsNumeric

func IsNumeric(s string) bool

IsNumeric checks if a string is a number

func IsStylesheet

func IsStylesheet(node *html.Node) bool

IsStylesheet checks if a link element is a stylesheet.

func MD5

func MD5(data string) string

func NewSecret

func NewSecret(regex string) string

func NormalizeURL

func NormalizeURL(input string) string

NormalizeURL formats the URL into a standard form, adds 'https' if necessary, removes 'www.' and trailing slashes.

func ParseQuery

func ParseQuery(query string) (map[string][]string, error)

func ParseUint

func ParseUint(input string) (uint, error)

ParseUint safely parses a string to uint, with an upper bound check for 32-bit systems.

func ProcessFontNode

func ProcessFontNode(node *html.Node) types.FileRequest

ProcessFontNode extracts data from a link element if it's a font.

func ProcessLinkNode

func ProcessLinkNode(node *html.Node) types.FileRequest

ProcessLinkNode extracts data from a link element if it's a stylesheet.

func ProcessScriptNode

func ProcessScriptNode(node *html.Node) types.FileRequest

ProcessScriptNode extracts data from a script element.

func ProcessStyleNode

func ProcessStyleNode(node *html.Node) types.FileRequest

ProcessStyleNode extracts data from a style element.

func SHA1

func SHA1(data string) string

func SHA256

func SHA256(data string) string

func SafeString

func SafeString(s string) string

SafeString returns a default value if the string is empty

func StripProtocol

func StripProtocol(url string) string

func TraverseHTML

func TraverseHTML(node *html.Node, fn func(*html.Node))

TraverseHTML recursively walks through the HTML nodes and applies the given function.

func URIsToStrings

func URIsToStrings(uris []*url.URL) []string

func ValidateURL

func ValidateURL(input string) bool

ValidateURL checks if a URL is valid, looking for malformed URLs, SQL injection patterns, and illegal characters.

Types

type FileType

type FileType string
const (
	ApplicationJavascript FileType = "application/javascript"
	TextCSS               FileType = "text/css"
	Font                  FileType = "font"
	XHR                   FileType = "xhr"
)

type Match

type Match struct {
	Match  string `json:"match"`
	Line   int    `json:"line"`
	Source string `json:"source"`
}

func GenericScan

func GenericScan(rule types.Rule, script types.FileRequest) []Match

type RegexPattern

type RegexPattern struct {
	Pattern string `json:"pattern"`
	Name    string
}

type RegexReturn

type RegexReturn struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Matches     []Match `json:"matches"`
}

Jump to

Keyboard shortcuts

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