mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-23 23:35:24 +00:00
Add decimal to hexadecimal helper function (#2076)
* Add decimal to hexadecimal auxiliary functions * Fixed unit test * Modify the helper function name and check the unit test. * dsl function update Co-authored-by: Sandeep Singh <sandeep@projectdiscovery.io>
This commit is contained in:
parent
841f2e8977
commit
aebd32b198
@ -496,6 +496,13 @@ func init() {
|
|||||||
"to_string": makeDslFunction(1, func(args ...interface{}) (interface{}, error) {
|
"to_string": makeDslFunction(1, func(args ...interface{}) (interface{}, error) {
|
||||||
return types.ToString(args[0]), nil
|
return types.ToString(args[0]), nil
|
||||||
}),
|
}),
|
||||||
|
"dec_to_hex": makeDslFunction(1, func(args ...interface{}) (interface{}, error) {
|
||||||
|
if number, ok := args[0].(float64); ok {
|
||||||
|
hexNum := strconv.FormatInt(int64(number), 16)
|
||||||
|
return types.ToString(hexNum), nil
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("invalid number: %T", args[0])
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
dslFunctions = make(map[string]dslFunction, len(tempDslFunctions))
|
dslFunctions = make(map[string]dslFunction, len(tempDslFunctions))
|
||||||
|
|||||||
@ -112,6 +112,7 @@ func TestGetPrintableDslFunctionSignatures(t *testing.T) {
|
|||||||
[93mconcat[0m(args [38;5;208m...interface{}[0m)[38;5;208m string[0m
|
[93mconcat[0m(args [38;5;208m...interface{}[0m)[38;5;208m string[0m
|
||||||
[93mcontains[0m(arg1, arg2 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
[93mcontains[0m(arg1, arg2 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
||||||
[93mdate[0m(arg1 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
[93mdate[0m(arg1 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
||||||
|
[93mdec_to_hex[0m(arg1 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
||||||
[93mgenerate_java_gadget[0m(arg1, arg2, arg3 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
[93mgenerate_java_gadget[0m(arg1, arg2, arg3 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
||||||
[93mgzip[0m(arg1 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
[93mgzip[0m(arg1 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
||||||
[93mgzip_decode[0m(arg1 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
[93mgzip_decode[0m(arg1 [38;5;208minterface{}[0m)[38;5;208m interface{}[0m
|
||||||
@ -220,6 +221,7 @@ func TestDslExpressions(t *testing.T) {
|
|||||||
`print_debug(1+2, "Hello")`: nil,
|
`print_debug(1+2, "Hello")`: nil,
|
||||||
`to_number('4')`: float64(4),
|
`to_number('4')`: float64(4),
|
||||||
`to_string(4)`: "4",
|
`to_string(4)`: "4",
|
||||||
|
`dec_to_hex(7001)`: "1b59",
|
||||||
`compare_versions('v1.0.0', '<1.1.1')`: true,
|
`compare_versions('v1.0.0', '<1.1.1')`: true,
|
||||||
`compare_versions('v1.1.1', '>v1.1.0')`: true,
|
`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,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user