util

package
v0.0.0-...-82180e8 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendIfMissing

func AppendIfMissing(slice []string, s string) []string

AppendIfMissing will check a slice for a value before appending it

func AppendToSlice

func AppendToSlice(trim bool, input, target []string) []string

AppendToSlice will append additional items to slice if not present already and return a new slice additional trim support is present, if necessary

func CleanURLSpaces

func CleanURLSpaces(dirtyStrings ...string) []string

CleanURLSpaces will take a string and replace any spaces with dashes so that is may be used in a url.

func CopyFiles

func CopyFiles(src, dest string) error

CopyFiles will copy files from src to dest directory and attempt to set correct permissions

func GenerateID

func GenerateID() string

GenerateID will create an ID for each finding based up the SHA1 of discrete data points associated with the finding.

func GenerateIDWithLen

func GenerateIDWithLen(i int) string

func GenerateSecretIDWithParams

func GenerateSecretIDWithParams(params ...string) string

func GetEntropyInt

func GetEntropyInt(s string) float64

get EntropyInt will calculate the entrophy based upon Shannon Entropy

func GetYamlFiles

func GetYamlFiles(dir string) ([]string, error)

GetYamlFiles will find all the yaml files in the provided directory path and return a string slice with all findings

func Int64ToPointer

func Int64ToPointer(i int64) *int64

func IsBinaryFile

func IsBinaryFile(filePath string) (bool, error)

func IsMaxFileSize

func IsMaxFileSize(filename string, maxFileSize int64) (bool, string)

IsMaxFileSize will determine if the file size is under the max limit set by maxFileSize

func IsTestFileOrPath

func IsTestFileOrPath(fullPath string) bool

IsTestFileOrPath will run various regex's against a target to determine if it is a test file or contained in a test directory.

func MakeHomeDir

func MakeHomeDir(path string) (string, error)

func MergeMaps

func MergeMaps(source, target map[string]int)

func PathExists

func PathExists(path string) bool

TODO THIS FUNC HAS TO RETURN ERROR, OTHERWISE WE DO THE SAME CHECK AGAIN LATER PathExists will check if a path exists or not and is used to validate user input

func Pluralize

func Pluralize(count int, singular string, plural string) string

Pluralize will take in a count and if the count is != 1 it will return the singular of the word.

func PointerToInt64

func PointerToInt64(p *int64) int64

func PointerToString

func PointerToString(s *string) string

func SetHomeDir

func SetHomeDir(h string) (string, error)

SetHomeDir will set the correct homedir.

func StringToPointer

func StringToPointer(s string) *string

func TruncateString

func TruncateString(str string, maxLength int) string

TruncateString will take an integer and cut a string at that length and append an ellipsis to it.

func WriteToFile

func WriteToFile(path string, input []byte) error

WriteToFile will create a new file or truncate the existing one and write the input byte stream.

Types

This section is empty.

Jump to

Keyboard shortcuts

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