From ffe85d99aac1f84ecadd5087f34f1293bc3062dc Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Thu, 19 Dec 2024 09:47:29 +0100 Subject: [PATCH 1/4] add base64Encode --- internal/transformations/base64encode.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 internal/transformations/base64encode.go diff --git a/internal/transformations/base64encode.go b/internal/transformations/base64encode.go new file mode 100644 index 000000000..493122035 --- /dev/null +++ b/internal/transformations/base64encode.go @@ -0,0 +1,12 @@ +// Copyright 2022 Juan Pablo Tosso and the OWASP Coraza contributors +// SPDX-License-Identifier: Apache-2.0 + +package transformations + +import ( + "encoding/base64" +) + +func base64Encode(data string) (string, bool, error) { + return base64.StdEncoding.EncodeToString([]byte(data)), true, nil +} From 7636f7fad6bdca2f1428d2d573a53cb8f0980801 Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Thu, 19 Dec 2024 09:57:26 +0100 Subject: [PATCH 2/4] follow code style --- internal/transformations/base64encode.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/transformations/base64encode.go b/internal/transformations/base64encode.go index 493122035..60dfa8db7 100644 --- a/internal/transformations/base64encode.go +++ b/internal/transformations/base64encode.go @@ -8,5 +8,7 @@ import ( ) func base64Encode(data string) (string, bool, error) { - return base64.StdEncoding.EncodeToString([]byte(data)), true, nil + src := []byte(data) + + return base64.StdEncoding.EncodeToString(src), true, nil } From c2487529e49e432056fc25c5528baa41cce04b4d Mon Sep 17 00:00:00 2001 From: Roman Suvorov Date: Thu, 19 Dec 2024 10:42:50 +0100 Subject: [PATCH 3/4] change a method name according to code style, register method --- internal/transformations/base64encode.go | 2 +- internal/transformations/transformations.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/transformations/base64encode.go b/internal/transformations/base64encode.go index 60dfa8db7..168880d93 100644 --- a/internal/transformations/base64encode.go +++ b/internal/transformations/base64encode.go @@ -7,7 +7,7 @@ import ( "encoding/base64" ) -func base64Encode(data string) (string, bool, error) { +func base64encode(data string) (string, bool, error) { src := []byte(data) return base64.StdEncoding.EncodeToString(src), true, nil diff --git a/internal/transformations/transformations.go b/internal/transformations/transformations.go index 704e04ad1..69aad6a1b 100644 --- a/internal/transformations/transformations.go +++ b/internal/transformations/transformations.go @@ -30,6 +30,7 @@ func GetTransformation(name string) (plugintypes.Transformation, error) { func init() { Register("base64Decode", base64decode) Register("base64DecodeExt", base64decodeext) + Register("base64Encode", base64encode) Register("cmdLine", cmdLine) Register("compressWhitespace", compressWhitespace) Register("cssDecode", cssDecode) From fdaf31fda2f40d51f8762f9716fb07b9372ab4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Zipitr=C3=ADa?= <3012076+fzipi@users.noreply.github.com> Date: Thu, 19 Dec 2024 11:43:24 -0300 Subject: [PATCH 4/4] Update internal/transformations/base64encode.go --- internal/transformations/base64encode.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/transformations/base64encode.go b/internal/transformations/base64encode.go index 168880d93..cb96d90f3 100644 --- a/internal/transformations/base64encode.go +++ b/internal/transformations/base64encode.go @@ -1,4 +1,4 @@ -// Copyright 2022 Juan Pablo Tosso and the OWASP Coraza contributors +// Copyright 2024 Juan Pablo Tosso and the OWASP Coraza contributors // SPDX-License-Identifier: Apache-2.0 package transformations