Documentation
¶
Index ¶
- Constants
- Variables
- func Bind(functionPtr any, function func([]reflect.Value) []reflect.Value)
- func GenericAssign(args []reflect.Value) []reflect.Value
- func GenericClone(args []reflect.Value) []reflect.Value
- func GenericMap(args []reflect.Value) []reflect.Value
- func GetLimitParamForGraphQuery(params url.Values) (int, error)
- func GetOrderForNeo4jQuery(params url.Values) string
- func GetPageParamsForGraphQuery(_ context.Context, params url.Values) (int, int, string, error)
- func GetSkipParamForGraphQuery(params url.Values) (int, error)
- func HeaderMatches(headers http.Header, key string, target ...string) bool
- func IsValidClientVersion(userAgent string) error
- func IsValidEmail(maybeEmail string) bool
- func MarshalToMap(marshalable any) (map[string]any, error)
- func ReadRFC3339(valueStr string, defaultValue time.Time) (time.Time, error)
- func ReplaceFieldValueInJsonString(jsonString string, field string, value any) (string, error)
- func SwitchCase(input string, format string) (string, error)
- func WriteResultJson(w http.ResponseWriter, r any)
- func WriteResultRawJson(w http.ResponseWriter, r []byte)
- type ClientType
- type ClientVersion
- type Errors
- type JsonResult
Constants ¶
const ( HSTSSetting = "max-age=31536000; includeSubDomains; preload" // Header Templates ContentDispositionAttachmentTemplate = "attachment; filename=\"%s\"" HeaderValueWait = "wait" ErrorInvalidSkip string = "invalid skip: %v" ErrorInvalidLimit string = "invalid limit: %v" )
Variables ¶
var ( ErrInvalidSharpHoundVersion = errors.New("invalid sharphound version string") ErrInvalidAzureHoundVersion = errors.New("invalid azurehound version string") ErrRecommendSharphoundVersion = errors.New("please upgrade to sharphound v2.0.3 or above") ErrInvalidClientType = errors.New("invalid client type") )
var MapErrorsToStrings func(collection []error, iteratee func(value error) string) []string
NilErrorValue is the reflected zero value of errors.Error
Functions ¶
func Bind ¶
Bind sets a typed function pointer to a generic implementation of a function based on reflect.Value.
Caveat Emptor: These functions do not benefit from compiler type-checking and can panic during runtime in the same way dynamically typed languages behave. Albeit small, there is a performance impact when creating functions with Bind. This is due to the additional steps it takes to determine the type of an interface.
func GenericAssign ¶
GenericAssign is the implementation of a variadic assign function for dynamic types. The function assigns the enumerable properties of each source object from left to right to the returned object. Subsequent source objects overwrite the property assignments of previous source object.
var assignMap func(...map[string]interface{}) map[string]interface{}
func init() {
Bind(&assignMap, GenericAssign)
}
func main() {
m1 := map[string]interface{} {
"foo": "bar",
}
m2 := map[string]interface{} {
"foo": "baz",
}
m3 := map[string]interface{} {
"bar": "buzz",
}
if m4, err := assignMap(m1, m2, m3); err == nil {
fmt.Println(m4)
// Output: map[bar:buzz foo:baz]
}
}
func GenericClone ¶
GenericClone is the implementation of a shallow clone function for dynamic types.
var cloneMap func(map[string]interface{}) map[string]interface{}
func init() {
Bind(&cloneMap, GenericClone)
}
func main() {
m1 := map[string]interface{} {
"foo": "bar",
}
m2 := cloneMap(m1)
fmt.Println(m2)
// Output: map[foo:bar]
}
func GenericMap ¶
GenericMap is the implementation of a map function for dynamic types.
func GetOrderForNeo4jQuery ¶
func IsValidClientVersion ¶
IsValidClientVersion checks the version from a user agent to ensure it's a valid UserAgent and that the version of the client is not EOL (currently SHS v1.x and SHS < v2.0.3). Returns an error if invalid and nil if valid
func IsValidEmail ¶
func ReadRFC3339 ¶
ReadRFC3339 attempts to parse a RFC3339 string into a time.Time struct.
If the RFC3339 string is empty this function returns the given default value. If the string is not formatted as a valid RFC3339 datetime then this function will return the resulting error.
func ReplaceFieldValueInJsonString ¶
ReplaceFieldValueInJsonString replaces a field value at the root of a JSON object If the field does not exist in jsonString, it will effectively do nothing
func SwitchCase ¶
SwitchCase is a helper function to change string case. This was originally charted out to be used for formatting error responses
func WriteResultJson ¶
func WriteResultJson(w http.ResponseWriter, r any)
func WriteResultRawJson ¶
func WriteResultRawJson(w http.ResponseWriter, r []byte)
Types ¶
type ClientType ¶
type ClientType int
const ( ClientTypeSharpHound ClientType = 0 ClientTypeAzureHound ClientType = 1 )
type ClientVersion ¶
type ClientVersion struct {
ClientType ClientType
Major int
Minor int
Patch int
Extra int
}
func ParseAzurehoundVersion ¶
func ParseAzurehoundVersion(userAgent string) (ClientVersion, error)
func ParseClientVersion ¶
func ParseClientVersion(userAgent string) (ClientVersion, error)
func ParseSharpHoundVersion ¶
func ParseSharpHoundVersion(userAgent string) (ClientVersion, error)