Merge pull request #22 from crowdsecurity/add_expr_helpers
add new expr helpers
This commit is contained in:
commit
c020ff8c64
|
@ -2,6 +2,7 @@ package exprhelpers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
@ -15,6 +16,14 @@ func Atof(x string) float64 {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func StartsWith(s string, pref string) bool {
|
||||||
|
return strings.HasPrefix(s, pref)
|
||||||
|
}
|
||||||
|
|
||||||
|
func EndsWith(s string, suff string) bool {
|
||||||
|
return strings.HasSuffix(s, suff)
|
||||||
|
}
|
||||||
|
|
||||||
func GetExprEnv(ctx map[string]interface{}) map[string]interface{} {
|
func GetExprEnv(ctx map[string]interface{}) map[string]interface{} {
|
||||||
|
|
||||||
var ExprLib = map[string]interface{}{"Atof": Atof, "JsonExtract": JsonExtract, "JsonExtractLib": JsonExtractLib}
|
var ExprLib = map[string]interface{}{"Atof": Atof, "JsonExtract": JsonExtract, "JsonExtractLib": JsonExtractLib}
|
||||||
|
|
Loading…
Reference in a new issue