mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-29 22:23:02 +00:00
update
- Added AddHelperFunction comment/usage - AddHelperFunction returns err on duplicate key definitions
This commit is contained in:
parent
013311b6b2
commit
7ebab7875b
@ -7,6 +7,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"math"
|
"math"
|
||||||
@ -234,15 +235,18 @@ var functions = map[string]govaluate.ExpressionFunction{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// HelperFunctions contains the dsl helper functions
|
// HelperFunctions returns the dsl helper functions
|
||||||
func HelperFunctions() map[string]govaluate.ExpressionFunction {
|
func HelperFunctions() map[string]govaluate.ExpressionFunction {
|
||||||
return functions
|
return functions
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddHelperFunction(key string, value func(args ...interface{}) (interface{}, error)) {
|
// AddHelperFunction allows creation of additiona helper functions to be supported with templates
|
||||||
|
func AddHelperFunction(key string, value func(args ...interface{}) (interface{}, error)) error {
|
||||||
if _, ok := functions[key]; !ok {
|
if _, ok := functions[key]; !ok {
|
||||||
functions[key] = value
|
functions[key] = value
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
return errors.New("duplicate helper function key defined")
|
||||||
}
|
}
|
||||||
|
|
||||||
func reverseString(s string) string {
|
func reverseString(s string) string {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user