From a5d818a2e6fbbf9772dc2b125e607f30b3218610 Mon Sep 17 00:00:00 2001 From: Ice3man543 Date: Thu, 26 Aug 2021 23:27:42 +0530 Subject: [PATCH 1/2] Fixed a schema issue with dns types --- v2/pkg/protocols/dns/dns.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/v2/pkg/protocols/dns/dns.go b/v2/pkg/protocols/dns/dns.go index 106671fa..7812ead1 100644 --- a/v2/pkg/protocols/dns/dns.go +++ b/v2/pkg/protocols/dns/dns.go @@ -46,13 +46,13 @@ type Request struct { // // Usually it's enough to just leave it as INET. // values: - // - "INET" - // - "CSNET" - // - "CHAOS" - // - "HESIOD" - // - "NONE" - // - "ANY" - Class string `yaml:"class,omitempty" jsonschema:"title=class of DNS request,description=Class is the class of the DNS request,enum=INET,enum=CSNET,enum=CHAOS,enum=HESIOD,enum=NONE,enum=ANY"` + // - "inet" + // - "csnet" + // - "chaos" + // - "hesiod" + // - "none" + // - "any" + Class string `yaml:"class,omitempty" jsonschema:"title=class of DNS request,description=Class is the class of the DNS request,enum=inet,enum=csnet,enum=chaos,enum=hesiod,enum=none,enum=any"` // description: | // Retries is the number of retries for the DNS request // examples: From 004ed31fdc3cc91babe87f50499ee08be1e072dc Mon Sep 17 00:00:00 2001 From: Ice3man543 Date: Fri, 27 Aug 2021 02:38:15 +0530 Subject: [PATCH 2/2] Fixed urlencode/decode with queryescape --- v2/pkg/operators/common/dsl/dsl.go | 4 ++-- v2/pkg/operators/common/dsl/dsl_test.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 v2/pkg/operators/common/dsl/dsl_test.go diff --git a/v2/pkg/operators/common/dsl/dsl.go b/v2/pkg/operators/common/dsl/dsl.go index 5c6871c6..b33d6b73 100644 --- a/v2/pkg/operators/common/dsl/dsl.go +++ b/v2/pkg/operators/common/dsl/dsl.go @@ -87,10 +87,10 @@ var functions = map[string]govaluate.ExpressionFunction{ return base64.StdEncoding.DecodeString(types.ToString(args[0])) }, "url_encode": func(args ...interface{}) (interface{}, error) { - return url.PathEscape(types.ToString(args[0])), nil + return url.QueryEscape(types.ToString(args[0])), nil }, "url_decode": func(args ...interface{}) (interface{}, error) { - return url.PathUnescape(types.ToString(args[0])) + return url.QueryUnescape(types.ToString(args[0])) }, "hex_encode": func(args ...interface{}) (interface{}, error) { return hex.EncodeToString([]byte(types.ToString(args[0]))), nil diff --git a/v2/pkg/operators/common/dsl/dsl_test.go b/v2/pkg/operators/common/dsl/dsl_test.go new file mode 100644 index 00000000..bf2c5bfe --- /dev/null +++ b/v2/pkg/operators/common/dsl/dsl_test.go @@ -0,0 +1,19 @@ +package dsl + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestDSLURLEncodeDecode(t *testing.T) { + functions := HelperFunctions() + + encoded, err := functions["url_encode"]("&test\"") + require.Nil(t, err, "could not url encode") + require.Equal(t, "%26test%22", encoded, "could not get url encoded data") + + decoded, err := functions["url_decode"]("%26test%22") + require.Nil(t, err, "could not url encode") + require.Equal(t, "&test\"", decoded, "could not get url decoded data") +}