mirror of https://github.com/daffainfo/nuclei.git
Add time_format dslExpression
parent
80f3cec293
commit
f2ca75c536
|
@ -496,6 +496,15 @@ func init() {
|
|||
"to_string": makeDslFunction(1, func(args ...interface{}) (interface{}, error) {
|
||||
return types.ToString(args[0]), nil
|
||||
}),
|
||||
"hmacsha256": makeDslFunction(2, func(args ...interface{}) (interface{}, error) {
|
||||
h := hmac.New(sha256.New, []byte(args[1].(string)))
|
||||
h.Write([]byte(args[0].(string)))
|
||||
return hex.EncodeToString(h.Sum(nil)), nil
|
||||
}),
|
||||
"time_format": makeDslFunction(1, func(args ...interface{}) (interface{}, error) {
|
||||
t := time.Now()
|
||||
return string(t.Format(args[0].(string))), nil
|
||||
}),
|
||||
}
|
||||
|
||||
dslFunctions = make(map[string]dslFunction, len(tempDslFunctions))
|
||||
|
|
|
@ -224,6 +224,8 @@ func TestDslExpressions(t *testing.T) {
|
|||
`compare_versions('v1.1.1', '>v1.1.0')`: true,
|
||||
`compare_versions('v1.0.0', '>v0.0.1,<v1.0.1')`: true,
|
||||
`compare_versions('v1.0.0', '>v0.0.1', '<v1.0.1')`: true,
|
||||
`hmacsha256('test','scrt')`: "1f1bff5574f18426eb376d6dd5368a754e67a798aa2074644d5e3fd4c90c7a92",
|
||||
`time_format("02-01-2006 15:04:05")`: now.Format("02-01-2006 15:04:05"),
|
||||
}
|
||||
|
||||
for dslExpression, expectedResult := range dslExpressions {
|
||||
|
|
Loading…
Reference in New Issue