diff --git a/internal/transformations/base64encode.go b/internal/transformations/base64encode.go new file mode 100644 index 000000000..cb96d90f3 --- /dev/null +++ b/internal/transformations/base64encode.go @@ -0,0 +1,14 @@ +// Copyright 2024 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) { + 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)